本文整理汇总了Python中models.team.Team类的典型用法代码示例。如果您正苦于以下问题:Python Team类的具体用法?Python Team怎么用?Python Team使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Team类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: TestTeamMediaApiController
class TestTeamMediaApiController(unittest2.TestCase):
def setUp(self):
app = webapp2.WSGIApplication([webapp2.Route(r'/<team_key:>/<year:>', ApiTeamMediaController, methods=['GET'])], debug=True)
self.testapp = webtest.TestApp(app)
self.testbed = testbed.Testbed()
self.testbed.activate()
self.testbed.init_datastore_v3_stub()
self.testbed.init_urlfetch_stub()
self.testbed.init_memcache_stub()
self.testbed.init_taskqueue_stub(root_path=".")
self.team = Team(
id="frc254",
name="very long name",
team_number=254,
nickname="Teh Chezy Pofs",
address="Greenville, SC, USA"
)
self.team.put()
self.cdmedia = Media(
key=ndb.Key('Media', 'cdphotothread_39894'),
details_json=u'{"image_partial": "fe3/fe38d320428adf4f51ac969efb3db32c_l.jpg"}',
foreign_key=u'39894',
media_type_enum=1,
references=[ndb.Key('Team', 'frc254')],
year=2014)
self.cdmedia.put()
self.cddetails = dict()
self.cddetails["image_partial"] = "fe3/fe38d320428adf4f51ac969efb3db32c_l.jpg"
self.ytmedia = Media(
key=ndb.Key('Media', 'youtube_aFZy8iibMD0'),
details_json=None,
foreign_key=u'aFZy8iibMD0',
media_type_enum=0,
references=[ndb.Key('Team', 'frc254')],
year=2014)
self.ytmedia.put()
def tearDown(self):
self.testbed.deactivate()
def testTeamMediaApi(self):
response = self.testapp.get('/frc254/2014', headers={"X-TBA-App-Id": "tba-tests:team_media-controller-test:v01"})
media = json.loads(response.body)
self.assertEqual(len(media), 2)
cd = media[0]
self.assertEqual(cd["type"], "cdphotothread")
self.assertEqual(cd["foreign_key"], "39894")
self.assertEqual(cd["details"], self.cddetails)
yt = media[1]
self.assertEqual(yt["type"], "youtube")
self.assertEqual(yt["foreign_key"], "aFZy8iibMD0")
self.assertEqual(yt["details"], {})
示例2: _upload_stats
def _upload_stats(team_name, stats):
query = Team.all()
query.filter('name =', team_name)
result = query.fetch(1)
if len(result) > 0:
for team in result:
team.year = Const.LAST_YEAR
team.offense_passing = stats['offense']['pass']
team.offense_rushing = stats['offense']['rush']
team.offense_first_down = stats['offense']['first_down']
team.defense_passing = stats['defense']['pass']
team.defense_rushing = stats['defense']['rush']
team.defense_first_down = stats['defense']['first_down']
team.put()
else:
team = Team(name = team_name,
year = Const.LAST_YEAR,
offense_passing = stats['offense']['pass'],
offense_rushing = stats['offense']['rush'],
offense_first_down = stats['offense']['first_down'],
defense_passing = stats['defense']['pass'],
defense_rushing = stats['defense']['rush'],
defense_first_down = stats['defense']['first_down'])
team.put()
示例3: get
def get(self, page_num=0):
self._require_admin()
page_num = int(page_num)
if page_num < self.MAX_PAGE:
start = self.PAGE_SIZE * page_num
end = start + self.PAGE_SIZE
teams = Team.query(Team.team_number >= start, Team.team_number < end).order(Team.team_number).fetch()
else:
start = self.PAGE_SIZE * self.MAX_PAGE
teams = Team.query(Team.team_number >= start).order(Team.team_number).fetch()
page_labels = []
for page in xrange(self.MAX_PAGE):
if page == 0:
page_labels.append('1-999')
else:
page_labels.append('{}\'s'.format(1000 * page))
page_labels.append('{}+'.format(1000 * self.MAX_PAGE))
self.template_values.update({
"teams": teams,
"num_teams": Team.query().count(),
"page_num": page_num,
"page_labels": page_labels,
})
path = os.path.join(os.path.dirname(__file__), '../../templates/admin/team_list.html')
self.response.out.write(template.render(path, self.template_values))
示例4: setUp
def setUp(self):
self.testbed = testbed.Testbed()
self.testbed.activate()
self.testbed.init_datastore_v3_stub()
self.testbed.init_memcache_stub()
event = Event(
id="2011ct",
end_date=datetime.datetime(2011, 4, 2, 0, 0),
event_short="ct",
event_type_enum=EventType.REGIONAL,
first_eid="5561",
name="Northeast Utilities FIRST Connecticut Regional",
start_date=datetime.datetime(2011, 3, 31, 0, 0),
year=2011,
venue_address="Connecticut Convention Center\r\n100 Columbus Blvd\r\nHartford, CT 06103\r\nUSA",
website="http://www.ctfirst.org/ctr"
)
event.put()
team = Team(
id="frc177",
team_number=177,
website="http://www.bobcatrobotics.org"
)
team.put()
event_team = EventTeam(
id="%s_%s" % (event.key.id(), team.key.id()),
event=event.key,
team=team.key,
year=None)
event_team.put()
示例5: setUp
def setUp(self):
app = webapp2.WSGIApplication([webapp2.Route(r'/<page_num:([0-9]*)>', ApiTeamListController, methods=['GET'])], debug=True)
self.testapp = webtest.TestApp(app)
self.testbed = testbed.Testbed()
self.testbed.activate()
self.testbed.init_datastore_v3_stub()
self.testbed.init_urlfetch_stub()
self.testbed.init_memcache_stub()
self.testbed.init_taskqueue_stub(root_path=".")
self.team1 = Team(
id="frc123",
name="SomeName",
team_number=123,
nickname="SomeNickname",
address="San Jose, CA, USA",
website="www.website.com",
)
self.team2 = Team(
id="frc4567",
name="SomeName",
team_number=4567,
nickname="SomeNickname",
address="San Jose, CA, USA",
website="www.website.com",
)
self.team1.put()
self.team2.put()
示例6: create_client
def create_client(user, params):
name = params.get("name", "")
if not name or len(name) > 30:
return {"error_code":20251, "msg":"name invalid"}
#team = Team.select().where(Team.user == user, Team.name == name).first()
team = Team.select().where(Team.user == user).first()
if team:
return {"error_code":20252, "msg":"team is exists and must one"}
team_id = GUID.guid()
team = Team()
team.id = team_id
team.user = user
team.name = name
team.status = "normal"
team.team_type = 'client'
team.logo = widget.logo()
team.save(force_insert=True)
user.to_req = True
user.identify = "c%s" % team.id
user.save()
team_profile = TeamProfile()
team_profile.team = team
team_profile.save()
#Member.create(user=user, team=team, mtype='owner')
return {"error_code":0, "msg":"ok"}
示例7: get
def get(self, key_name):
df = DatafeedUsfirst()
legacy_df = DatafeedUsfirstLegacy()
team = df.getTeamDetails(Team.get_by_id(key_name))
if not team:
logging.warning("getTeamDetails with DatafeedUsfirst for event id {} failed. Retrying with DatafeedUsfirstLegacy.".format(key_name))
team = legacy_df.getTeamDetails(Team.get_by_id(key_name))
else:
legacy_team = legacy_df.getTeamDetails(Team.get_by_id(key_name))
if legacy_team is not None:
team.rookie_year = legacy_team.rookie_year # only available on legacy df
if team:
team = TeamManipulator.createOrUpdate(team)
success = True
else:
success = False
template_values = {
'key_name': key_name,
'team': team,
'success': success,
}
path = os.path.join(os.path.dirname(__file__), '../templates/datafeeds/usfirst_team_details_get.html')
self.response.out.write(template.render(path, template_values))
示例8: _render
def _render(self, *args, **kw):
team_a = Team.get_by_id(self._team_key_a) if self._team_key_a else None
team_b = Team.get_by_id(self._team_key_b) if self._team_key_b else None
self.template_values.update({
'team_a': team_a,
'team_b': team_b,
})
return jinja2_engine.render('2champs.html', self.template_values)
示例9: TestDistrictTeamsApiController
class TestDistrictTeamsApiController(unittest2.TestCase):
def setUp(self):
app = webapp2.WSGIApplication(
[webapp2.Route(r"/<district_abbrev:>/<year:([0-9]*)>", ApiDistrictTeamsController, methods=["GET"])],
debug=True,
)
self.testapp = webtest.TestApp(app)
self.testbed = testbed.Testbed()
self.testbed.activate()
self.testbed.init_datastore_v3_stub()
self.testbed.init_urlfetch_stub()
self.testbed.init_memcache_stub()
ndb.get_context().clear_cache() # Prevent data from leaking between tests
self.testbed.init_taskqueue_stub(root_path=".")
self.team = Team(
id="frc281",
name="Michelin / Caterpillar / Greenville Technical College /\
jcpenney / Baldor / ASME / Gastroenterology Associates /\
Laserflex South & Greenville County Schools & Greenville\
Technical Charter High School",
team_number=281,
nickname="EnTech GreenVillians",
city="Greenville",
state_prov="SC",
country="USA",
website="www.entech.org",
motto="Infiltrating Young Minds One Robot at a Time",
)
self.district_team = DistrictTeam(id="2015ne_frc281", team=self.team.key, year=2015, district=3)
self.team.put()
self.district_team.put()
def tearDown(self):
self.testbed.deactivate()
def assertTeamJson(self, team):
team = team[0]
self.assertEqual(team["key"], self.team.key_name)
self.assertEqual(team["team_number"], self.team.team_number)
self.assertEqual(team["nickname"], self.team.nickname)
self.assertEqual(team["location"], self.team.location)
self.assertEqual(team["locality"], "Greenville")
self.assertEqual(team["country_name"], "USA")
self.assertEqual(team["region"], "SC")
self.assertEqual(team["website"], self.team.website)
self.assertEqual(team["motto"], self.team.motto)
def testDistrictsApi(self):
response = self.testapp.get(
"/ne/2015", headers={"X-TBA-App-Id": "tba-tests:team-districts-controller-test:v01"}
)
teams = json.loads(response.body)
self.assertTeamJson(teams)
示例10: TestTeamListApiController
class TestTeamListApiController(unittest2.TestCase):
def setUp(self):
app = webapp2.WSGIApplication([webapp2.Route(r'/<page_num:([0-9]*)>', ApiTeamListController, methods=['GET'])], debug=True)
self.testapp = webtest.TestApp(app)
self.testbed = testbed.Testbed()
self.testbed.activate()
self.testbed.init_datastore_v3_stub()
self.testbed.init_urlfetch_stub()
self.testbed.init_memcache_stub()
self.testbed.init_taskqueue_stub(root_path=".")
self.team1 = Team(
id="frc123",
name="SomeName",
team_number=123,
nickname="SomeNickname",
address="San Jose, CA, USA",
website="www.website.com",
)
self.team2 = Team(
id="frc4567",
name="SomeName",
team_number=4567,
nickname="SomeNickname",
address="San Jose, CA, USA",
website="www.website.com",
)
self.team1.put()
self.team2.put()
def tearDown(self):
self.testbed.deactivate()
def assertTeam1Json(self, team):
self.assertEqual(team["key"], self.team1.key_name)
self.assertEqual(team["name"], self.team1.name)
self.assertEqual(team["team_number"], self.team1.team_number)
def assertTeam2Json(self, team):
self.assertEqual(team["key"], self.team2.key_name)
self.assertEqual(team["name"], self.team2.name)
self.assertEqual(team["team_number"], self.team2.team_number)
def testTeamListApi(self):
response = self.testapp.get('/0', headers={"X-TBA-App-Id": "tba-tests:team_list-controller-test:v01"})
team_list = json.loads(response.body)
self.assertTeam1Json(team_list[0])
response = self.testapp.get('/9', headers={"X-TBA-App-Id": "tba-tests:team_list-controller-test:v01"})
team_list = json.loads(response.body)
self.assertTeam2Json(team_list[0])
response = self.testapp.get('/10', headers={"X-TBA-App-Id": "tba-tests:team_list-controller-test:v01"})
team_list = json.loads(response.body)
self.assertEqual(team_list, [])
示例11: create_entry_from_params
def create_entry_from_params(self, params):
new_team = Team(title = params["title"],
description = params["description"],
location = params["location"],
league = params["league"],
ref_id = params["ref_id"])
new_team.put()
return new_team
示例12: TestDatafeedUsfirstLegacyTeams
class TestDatafeedUsfirstLegacyTeams(unittest2.TestCase):
def setUp(self):
self.testbed = testbed.Testbed()
self.testbed.activate()
self.testbed.init_urlfetch_stub()
self.testbed.init_datastore_v3_stub()
self.testbed.init_memcache_stub()
self.datafeed = DatafeedUsfirstLegacy()
self.team177 = Team(
id="frc177",
team_number=177,
first_tpid=211521,
first_tpid_year=2014,
)
self.team177.put()
def tearDown(self):
self.testbed.deactivate()
def test_getTeamDetails(self):
team = self.datafeed.getTeamDetails(self.team177)
self.assertEqual(team.key.id(), 'frc177')
self.assertEqual(team.name, "United Technologies / ClearEdge Power / Gain Talent / EBA&D & South Windsor High School")
self.assertEqual(team.address, u"South Windsor, CT\xa0 USA")
self.assertEqual(team.nickname, "Bobcat Robotics")
self.assertEqual(team.rookie_year, 1995)
self.assertEqual(team.website, "http://www.bobcatrobotics.org")
def test_getTeamsTpids(self):
Team(
id="frc4409",
team_number=4409,
first_tpid=0, # should be 74735
first_tpid_year=2011
).put()
# We can skip 2000 records, paginate, and still get frc4409 and frc4410 in 2012
self.datafeed.getTeamsTpids(2012, skip=2000)
# Check new team insertion
frc4410 = Team.get_by_id("frc4410")
self.assertEqual(frc4410.team_number, 4410)
self.assertEqual(frc4410.first_tpid, 74193)
self.assertEqual(frc4410.first_tpid_year, 2012)
# Check old team updating
frc4409 = Team.get_by_id("frc4409")
self.assertEqual(frc4409.team_number, 4409)
self.assertEqual(frc4409.first_tpid, 74735)
self.assertEqual(frc4409.first_tpid_year, 2012)
示例13: get
def get(self, key_name):
# Combines data from three datafeeds with priorities:
# 1) DatafeedFMSAPI
# 2) DatafeedUsfirst (missing rookie year)
# 3) DatafeedUsfirstLegacy (has all info)
legacy_df = DatafeedUsfirstLegacy()
usfirst_df = DatafeedUsfirst()
fms_df = DatafeedFMSAPI('v2.0')
# Start with lowest priority
legacy_team = legacy_df.getTeamDetails(Team.get_by_id(key_name))
usfirst_team = usfirst_df.getTeamDetails(Team.get_by_id(key_name))
fms_details = fms_df.getTeamDetails(tba_config.MAX_YEAR, key_name)
# Separate out the multiple models returned from FMSAPI call
# Since we're only hitting one team at a time, the response won't
# ever be paginated so we can ignore the possibility
if fms_details and fms_details[0]:
models, more_pages = fms_details
fms_team, district_team, robot = models[0]
else:
fms_team = None
district_team = None
robot = None
team = None
if usfirst_team:
team = TeamManipulator.updateMergeBase(usfirst_team, legacy_team)
if fms_team:
team = TeamManipulator.updateMergeBase(fms_team, team)
if district_team:
district_team = DistrictTeamManipulator.createOrUpdate(district_team)
if robot:
robot = RobotManipulator.createOrUpdate(robot)
if team:
team = TeamManipulator.createOrUpdate(team)
success = True
else:
success = False
logging.warning("getTeamDetails failed for team: {}".format(key_name))
template_values = {
'key_name': key_name,
'team': team,
'success': success,
'district': district_team,
'robot': robot,
}
path = os.path.join(os.path.dirname(__file__), '../templates/datafeeds/usfirst_team_details_get.html')
self.response.out.write(template.render(path, template_values))
示例14: TestDatafeedUsfirstTeams
class TestDatafeedUsfirstTeams(unittest2.TestCase):
def setUp(self):
self.testbed = testbed.Testbed()
self.testbed.activate()
self.testbed.init_urlfetch_stub()
self.testbed.init_datastore_v3_stub()
self.testbed.init_memcache_stub()
self.datafeed = DatafeedUsfirst()
self.team177 = Team(
id="frc177",
team_number=177,
first_tpid=61771,
first_tpid_year=2012
)
self.team177.put()
def tearDown(self):
self.testbed.deactivate()
def test_getTeamDetails(self):
team = self.datafeed.getTeamDetails(self.team177)
## Broken as result of FIRST website redesign -gregmarra 20151122
# self.assertEqual(team.name, "UTC Power/Ensign Bickford Aerospace & Defense & South Windsor High School")
# self.assertEqual(team.address, u"South Windsor, CT, USA")
# self.assertEqual(team.nickname, "Bobcat Robotics")
# self.assertEqual(team.website, "http://www.bobcatrobotics.org")
def test_getTeamsTpids(self):
Team(
id="frc4409",
team_number=4409,
first_tpid=0, # should be 74735
first_tpid_year=2011
).put()
# We can skip 2000 records, paginate, and still get frc4409 and frc4410 in 2012
self.datafeed.getTeamsTpids(2012, skip=2000)
# Check new team insertion
frc4410 = Team.get_by_id("frc4410")
self.assertEqual(frc4410.team_number, 4410)
self.assertEqual(frc4410.first_tpid, 74193)
self.assertEqual(frc4410.first_tpid_year, 2012)
# Check old team updating
frc4409 = Team.get_by_id("frc4409")
self.assertEqual(frc4409.team_number, 4409)
self.assertEqual(frc4409.first_tpid, 74735)
self.assertEqual(frc4409.first_tpid_year, 2012)
示例15: store_team
def store_team(data):
team = Team(id=data['key'])
team.team_number = data['team_number']
team.nickname = data['nickname']
team.name = data['name']
team.website = data['website']
team.rookie_year = data['rookie_year']
team.motto = data['motto']
team.city = data['city']
team.state_prov = data['state_prov']
team.country = data['country']
TeamManipulator.createOrUpdate(team)
return team