本文整理汇总了Python中models.event.Event.put方法的典型用法代码示例。如果您正苦于以下问题:Python Event.put方法的具体用法?Python Event.put怎么用?Python Event.put使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.event.Event
的用法示例。
在下文中一共展示了Event.put方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: TestEventMatchApiController
# 需要导入模块: from models.event import Event [as 别名]
# 或者: from models.event.Event import put [as 别名]
class TestEventMatchApiController(unittest2.TestCase):
def setUp(self):
app = webapp2.WSGIApplication([webapp2.Route(r'/<event_key:>', ApiEventMatchesController, 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.event = Event(
id="2010sc",
name="Palmetto Regional",
event_type_enum=EventType.REGIONAL,
short_name="Palmetto",
event_short="sc",
year=2010,
end_date=datetime(2010, 03, 27),
official=True,
location='Clemson, SC',
start_date=datetime(2010, 03, 24),
)
self.event.put()
self.match = Match(
id="2010sc_qm1",
alliances_json="""{"blue": {"score": 57, "teams": ["frc3464", "frc20", "frc1073"]}, "red": {"score": 74, "teams": ["frc281", "frc571", "frc176"]}}""",
comp_level="qm",
event=self.event.key,
year=2010,
set_number=1,
match_number=1,
team_key_names=[u'frc281', u'frc571', u'frc176', u'frc3464', u'frc20', u'frc1073'],
youtube_videos=["94UGXIq6jUA"],
tba_videos=[".mp4"],
time=datetime.fromtimestamp(1409527874)
)
self.match.put()
def tearDown(self):
self.testbed.deactivate()
def assertMatchJson(self, matches):
match = matches[0]
self.assertEqual(str(match["key"]), self.match.key.string_id())
self.assertEqual(match["comp_level"], self.match.comp_level)
self.assertEqual(match["event_key"], self.match.event.string_id())
self.assertEqual(match["set_number"], self.match.set_number)
self.assertEqual(match["match_number"], self.match.match_number)
self.assertEqual(match["videos"], self.match.videos)
self.assertEqual(match["time_string"], self.match.time_string)
self.assertEqual(match["time"], 1409527874)
def testEventMatchApi(self):
response = self.testapp.get('/2010sc', headers={"X-TBA-App-Id": "tba-tests:event-controller-test:v01"})
match_json = json.loads(response.body)
self.assertMatchJson(match_json)
示例2: setUp
# 需要导入模块: from models.event import Event [as 别名]
# 或者: from models.event.Event import put [as 别名]
def setUp(self):
self.testbed = testbed.Testbed()
self.testbed.activate()
self.testbed.init_datastore_v3_stub()
self.testbed.init_memcache_stub()
past_event = Event(
id="2011tstupdaterpast",
end_date=datetime.datetime.now() - datetime.timedelta(days=1),
event_short="tstupdaterpast",
event_type_enum=EventType.REGIONAL,
start_date=datetime.datetime.now() - datetime.timedelta(days=2),
year=2011,
)
past_event.put()
past_event_matches = set_up_matches(
'test_data/usfirst_html/usfirst_event_matches_2012ct.html',
past_event)
ndb.put_multi(past_event_matches)
future_event = Event(
id="2011tstupdaterfuture",
end_date=datetime.datetime.now() + datetime.timedelta(days=2),
event_short="tstupdaterfuture",
event_type_enum=EventType.REGIONAL,
start_date=datetime.datetime.now() + datetime.timedelta(days=1),
year=2011,
)
future_event.put()
future_event_matches = set_up_matches(
'test_data/usfirst_html/usfirst_event_matches_2012ct.html',
future_event)
ndb.put_multi(future_event_matches)
示例3: setUp
# 需要导入模块: from models.event import Event [as 别名]
# 或者: from models.event.Event import put [as 别名]
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()
示例4: TestDatafeedUsfirstTeams
# 需要导入模块: from models.event import Event [as 别名]
# 或者: from models.event.Event import put [as 别名]
class TestDatafeedUsfirstTeams(unittest2.TestCase):
def setUp(self):
self.testbed = testbed.Testbed()
self.testbed.activate()
self.testbed.init_datastore_v3_stub()
self.testbed.init_memcache_stub()
self.event = Event(
id="2010sc",
name="Palmetto Regional",
event_type_enum=EventType.REGIONAL,
short_name="Palmetto",
event_short="sc",
year=2010,
end_date=datetime.datetime(2010, 03, 27),
official=True,
location='Clemson, SC',
start_date=datetime.datetime(2010, 03, 24),
)
self.event.put()
self.match = Match(
id="2010sc_qm1",
alliances_json="""{"blue": {"score": -1, "teams": ["frc3464", "frc20", "frc1073"]}, "red": {"score": -1, "teams": ["frc69", "frc571", "frc176"]}}""",
comp_level="qm",
event=self.event.key,
year=2010,
set_number=1,
match_number=1,
team_key_names=[u'frc69', u'frc571', u'frc176', u'frc3464', u'frc20', u'frc1073']
)
self.match.put()
def tearDown(self):
self.testbed.deactivate()
示例5: test_webcast_good_date
# 需要导入模块: from models.event import Event [as 别名]
# 或者: from models.event.Event import put [as 别名]
def test_webcast_good_date(self):
event = Event(id="2016test", name="Test Event", event_short="Test Event", year=2016, event_type_enum=EventType.OFFSEASON)
event.put()
status = SuggestionCreator.createEventWebcastSuggestion(
self.account.key,
"http://twitch.tv/frcgamesense",
"2017-02-28",
"2016test")
self.assertEqual(status, 'success')
suggestions = Suggestion.query().fetch()
self.assertIsNotNone(suggestions)
self.assertEqual(len(suggestions), 1)
suggestion = suggestions[0]
self.assertIsNotNone(suggestion)
self.assertEqual(suggestion.target_key, "2016test")
self.assertEqual(suggestion.author, self.account.key)
self.assertEqual(suggestion.review_state, Suggestion.REVIEW_PENDING)
self.assertIsNotNone(suggestion.contents)
self.assertEqual(suggestion.contents.get('webcast_url'), "http://twitch.tv/frcgamesense")
self.assertIsNotNone(suggestion.contents.get('webcast_dict'))
self.assertEqual(suggestion.contents.get('webcast_date'), "2017-02-28")
示例6: setUp
# 需要导入模块: from models.event import Event [as 别名]
# 或者: from models.event.Event import put [as 别名]
def setUp(self):
self.testbed = testbed.Testbed()
self.testbed.activate()
self.testbed.init_datastore_v3_stub()
self.testbed.init_memcache_stub()
ndb.get_context().clear_cache() # Prevent data from leaking between tests
self.account = Account.get_or_insert(
"123",
email="[email protected]",
registered=True)
self.account.put()
self.account_banned = Account.get_or_insert(
"456",
email="[email protected]",
registered=True,
shadow_banned=True,
)
self.account_banned.put()
event = Event(id="2016test", name="Test Event", event_short="Test Event", year=2016, event_type_enum=EventType.OFFSEASON)
event.put()
self.match = Match(id="2016test_f1m1", event=ndb.Key(Event, "2016test"), year=2016, comp_level="f", set_number=1, match_number=1, alliances_json='')
self.match.put()
示例7: TestEventListApiController
# 需要导入模块: from models.event import Event [as 别名]
# 或者: from models.event.Event import put [as 别名]
class TestEventListApiController(unittest2.TestCase):
def setUp(self):
app = webapp2.WSGIApplication([webapp2.Route(r'/<year:>', ApiEventListController, 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()
self.event = Event(
id="2010sc",
name="Palmetto Regional",
event_type_enum=EventType.REGIONAL,
short_name="Palmetto",
event_short="sc",
year=2010,
end_date=datetime(2010, 03, 27),
official=True,
location='Clemson, SC',
start_date=datetime(2010, 03, 24),
)
self.event.put()
def tearDown(self):
self.testbed.deactivate()
def testEventListApi(self):
response = self.testapp.get('/2010', headers={"X-TBA-App-Id": "tba-tests:event-controller-test:v01"})
event_dict = json.loads(response.body)
self.assertEqual(event_dict[0], self.event.key_name)
示例8: testInsertEvent
# 需要导入模块: from models.event import Event [as 别名]
# 或者: from models.event.Event import put [as 别名]
def testInsertEvent(self):
event = Event(parent=ndb.Key('Group', 'Agile'))
event.date = datetime.now()
event.description = 'An event'
event.capacity = 20
event.put()
self.assertEqual(1, len(Event.query().fetch(2)))
示例9: TestListDistrictsController
# 需要导入模块: from models.event import Event [as 别名]
# 或者: from models.event.Event import put [as 别名]
class TestListDistrictsController(unittest2.TestCase):
def setUp(self):
app = webapp2.WSGIApplication([webapp2.Route(r'/<year:>', ApiDistrictListController, 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.event = Event(
id="2010sc",
name="Palmetto Regional",
event_type_enum=EventType.DISTRICT_CMP,
event_district_enum=DistrictType.NEW_ENGLAND,
short_name="Palmetto",
event_short="sc",
year=2010,
end_date=datetime(2010, 03, 27),
official=True,
city="Clemson",
state_prov="SC",
country="USA",
venue="Long Beach Arena",
venue_address="Long Beach Arena\r\n300 East Ocean Blvd\r\nLong Beach, CA 90802\r\nUSA",
start_date=datetime(2010, 03, 24),
webcast_json="[{\"type\": \"twitch\", \"channel\": \"frcgamesense\"}]",
website="http://www.firstsv.org",
)
self.event.put()
self.event_details = EventDetails(
id=self.event.key.id(),
alliance_selections=[
{"declines": [], "picks": ["frc971", "frc254", "frc1662"]},
{"declines": [], "picks": ["frc1678", "frc368", "frc4171"]},
{"declines": [], "picks": ["frc2035", "frc192", "frc4990"]},
{"declines": [], "picks": ["frc1323", "frc846", "frc2135"]},
{"declines": [], "picks": ["frc2144", "frc1388", "frc668"]},
{"declines": [], "picks": ["frc1280", "frc604", "frc100"]},
{"declines": [], "picks": ["frc114", "frc852", "frc841"]},
{"declines": [], "picks": ["frc2473", "frc3256", "frc1868"]}
]
)
self.event_details.put()
def tearDown(self):
self.testbed.deactivate()
def assertDistrictKeys(self, district):
self.assertEqual(district["key"], DistrictType.type_abbrevs[DistrictType.NEW_ENGLAND])
self.assertEqual(district["name"], DistrictType.type_names[DistrictType.NEW_ENGLAND])
def testDistrictApi(self):
response = self.testapp.get('/{}'.format(self.event.year), headers={"X-TBA-App-Id": "tba-tests:disstrict-controller-test:v01"})
districts = json.loads(response.body)
self.assertDistrictKeys(districts[0])
示例10: create_event
# 需要导入模块: from models.event import Event [as 别名]
# 或者: from models.event.Event import put [as 别名]
def create_event(self, capacity=20, event_date=datetime.now() + timedelta(days=5), registration_window=5):
event = Event(parent=ndb.Key('Group', 'AgileYorkshire'))
event.date = event_date
event.description = 'An event'
event.capacity = capacity
event.registration_window = registration_window
event.put()
return event
示例11: test_no_role
# 需要导入模块: from models.event import Event [as 别名]
# 或者: from models.event.Event import put [as 别名]
def test_no_role(self):
event = Event(id="2016test", name="Test Event", event_short="Test Event", year=2016, event_type_enum=EventType.OFFSEASON)
event.put()
status = SuggestionCreator.createApiWriteSuggestion(
self.account.key,
"2016test",
"",
[1, 2, 3])
self.assertEqual(status, 'no_affiliation')
示例12: get
# 需要导入模块: from models.event import Event [as 别名]
# 或者: from models.event.Event import put [as 别名]
def get(self):
# Add some guardians
new_guardian = Guardian(guardian_id=6781,
firstname="A.J.",
preposition="van",
lastname="Brandsma")
new_guardian.put()
new_guardian = Guardian(guardian_id=6900,
firstname="M.",
lastname="Tervuure")
new_guardian.put()
# Add an event
new_event = Event(tables=40,
talk_time=15)
new_event.put()
# Add some days to the aforementioned event
new_day = Day(date=datetime.datetime(year=2011, month=11, day=11, hour=20, minute=00),
talks=12,
event=new_event)
new_day.put()
new_day = Day(date=datetime.datetime(year=2011, month=11, day=12, hour=20, minute=00),
talks=12,
event=new_event)
new_day.put()
new_day = Day(date=datetime.datetime(year=2011, month=11, day=13, hour=20, minute=00),
talks=12,
event=new_event)
new_day.put()
# Add an event
new_event = Event(tables=40,
talk_time=15)
new_event.put()
# Add some days to the aforementioned event
new_day = Day(date=datetime.datetime(year=2011, month=11, day=20, hour=19, minute=30),
talks=12,
event=new_event)
new_day.put()
new_day = Day(date=datetime.datetime(year=2011, month=11, day=21, hour=20, minute=00),
talks=12,
event=new_event)
new_day.put()
new_day = Day(date=datetime.datetime(year=2011, month=11, day=22, hour=19, minute=45),
talks=12,
event=new_event)
new_day.put()
示例13: TestMatchSuggestionAccepter
# 需要导入模块: from models.event import Event [as 别名]
# 或者: from models.event.Event import put [as 别名]
class TestMatchSuggestionAccepter(unittest2.TestCase):
def setUp(self):
self.testbed = testbed.Testbed()
self.testbed.activate()
self.testbed.init_datastore_v3_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.account = Account(
email="[email protected]",
)
self.account.put()
self.suggestion = Suggestion(
author=self.account.key,
contents_json="{\"youtube_videos\":[\"123456\"]}",
target_key="2012ct_qm1",
target_model="match"
)
self.suggestion.put()
self.event = Event(
id="2012ct",
event_short="ct",
year=2012,
event_type_enum=EventType.REGIONAL,
)
self.event.put()
self.match = Match(
id="2012ct_qm1",
alliances_json="""{"blue": {"score": -1, "teams": ["frc3464", "frc20", "frc1073"]}, "red": {"score": -1, "teams": ["frc69", "frc571", "frc176"]}}""",
comp_level="qm",
event=self.event.key,
year=2012,
set_number=1,
match_number=1,
team_key_names=[u'frc69', u'frc571', u'frc176', u'frc3464', u'frc20', u'frc1073'],
youtube_videos=["abcdef"]
)
self.match.put()
def tearDown(self):
self.testbed.deactivate()
def test_accept_suggestions(self):
MatchSuggestionAccepter.accept_suggestion(self.match, self.suggestion)
match = Match.get_by_id("2012ct_qm1")
self.assertTrue("abcdef" in match.youtube_videos)
self.assertTrue("123456" in match.youtube_videos)
示例14: TestDatafeedUsfirstTeams
# 需要导入模块: from models.event import Event [as 别名]
# 或者: from models.event.Event import put [as 别名]
class TestDatafeedUsfirstTeams(unittest2.TestCase):
def setUp(self):
self.testbed = testbed.Testbed()
self.testbed.activate()
self.testbed.init_datastore_v3_stub()
self.testbed.init_memcache_stub()
self.event = Event(
id = "2010sc",
name = "Palmetto Regional",
event_type = "Regional",
short_name = "Palmetto",
event_short = "sc",
year = 2010,
end_date = datetime.datetime(2010, 03, 27),
official = True,
location = 'Clemson, SC',
start_date = datetime.datetime(2010, 03, 24),
)
self.event.put()
self.match = Match(
id = "2010sc_qm1",
alliances_json = """{"blue": {"score": -1, "teams": ["frc3464", "frc20", "frc1073"]}, "red": {"score": -1, "teams": ["frc69", "frc571", "frc176"]}}""",
comp_level = "qm",
event = self.event.key,
game = "frc_2010_bkwy",
set_number = 1,
match_number = 1,
team_key_names = [u'frc69', u'frc571', u'frc176', u'frc3464', u'frc20', u'frc1073']
)
self.match.put()
def tearDown(self):
self.testbed.deactivate()
def test_doEventTeamUpdate(self):
# call EventTeamUpdate with 2010sc
eventteamupdate = EventTeamUpdate()
eventteamupdate.response = Response()
eventteamupdate.get("2010sc")
# Teams were generated by EventTeamUpdate, make sure EventTeams
# exist and feature Team Keys
event_team_from_match_one = EventTeam.get_by_id("2010sc_frc69")
self.assertEqual(event_team_from_match_one.event, self.event.key)
self.assertEqual(event_team_from_match_one.team, ndb.Key(Team, "frc69"))
event_team_from_match_two = EventTeam.get_by_id("2010sc_frc20")
self.assertEqual(event_team_from_match_two.event, self.event.key)
self.assertEqual(event_team_from_match_two.team, ndb.Key(Team, "frc20"))
示例15: test_2017scmb_sequence
# 需要导入模块: from models.event import Event [as 别名]
# 或者: from models.event.Event import put [as 别名]
def test_2017scmb_sequence(self):
event = Event(
id='2017scmb',
event_short='scmb',
year=2017,
event_type_enum=0,
timezone_id='America/New_York'
)
event.put()
event_code = 'scmb'
file_prefix = 'frc-api-response/v2.0/2017/schedule/{}/playoff/hybrid/'.format(event_code)
context = ndb.get_context()
result = context.urlfetch('https://www.googleapis.com/storage/v1/b/bucket/o?bucket=tbatv-prod-hrd.appspot.com&prefix={}'.format(file_prefix)).get_result()
for item in json.loads(result.content)['items']:
filename = item['name']
time_str = filename.replace(file_prefix, '').replace('.json', '').strip()
file_time = datetime.datetime.strptime(time_str, "%Y-%m-%d %H:%M:%S.%f")
query_time = file_time + datetime.timedelta(seconds=30)
MatchManipulator.createOrUpdate(DatafeedFMSAPI('v2.0', sim_time=query_time).getMatches('2017{}'.format(event_code)), run_post_update_hook=False)
MatchHelper.deleteInvalidMatches(event.matches, event)
qf_matches = Match.query(Match.event == ndb.Key(Event, '2017scmb'), Match.comp_level == 'qf').fetch()
self.assertEqual(len(qf_matches), 11)
sf_matches = Match.query(Match.event == ndb.Key(Event, '2017scmb'), Match.comp_level == 'sf').fetch()
self.assertEqual(len(sf_matches), 4)
f_matches = Match.query(Match.event == ndb.Key(Event, '2017scmb'), Match.comp_level == 'f').fetch()
self.assertEqual(len(f_matches), 3)
self.assertEqual(Match.get_by_id('2017scmb_qf4m1').alliances['red']['score'], 305)
self.assertEqual(Match.get_by_id('2017scmb_qf4m1').alliances['blue']['score'], 305)
self.assertEqual(Match.get_by_id('2017scmb_qf4m1').score_breakdown['red']['totalPoints'], 305)
self.assertEqual(Match.get_by_id('2017scmb_qf4m1').score_breakdown['blue']['totalPoints'], 305)
self.assertEqual(Match.get_by_id('2017scmb_qf4m2').alliances['red']['score'], 213)
self.assertEqual(Match.get_by_id('2017scmb_qf4m2').alliances['blue']['score'], 305)
self.assertEqual(Match.get_by_id('2017scmb_qf4m2').score_breakdown['red']['totalPoints'], 213)
self.assertEqual(Match.get_by_id('2017scmb_qf4m2').score_breakdown['blue']['totalPoints'], 305)
self.assertEqual(Match.get_by_id('2017scmb_qf4m3').alliances['red']['score'], 312)
self.assertEqual(Match.get_by_id('2017scmb_qf4m3').alliances['blue']['score'], 255)
self.assertEqual(Match.get_by_id('2017scmb_qf4m3').score_breakdown['red']['totalPoints'], 312)
self.assertEqual(Match.get_by_id('2017scmb_qf4m3').score_breakdown['blue']['totalPoints'], 255)
self.assertEqual(Match.get_by_id('2017scmb_qf4m4').alliances['red']['score'], 310)
self.assertEqual(Match.get_by_id('2017scmb_qf4m4').alliances['blue']['score'], 306)
self.assertEqual(Match.get_by_id('2017scmb_qf4m4').score_breakdown['red']['totalPoints'], 310)
self.assertEqual(Match.get_by_id('2017scmb_qf4m4').score_breakdown['blue']['totalPoints'], 306)