当前位置: 首页>>代码示例>>Python>>正文


Python event_details.EventDetails类代码示例

本文整理汇总了Python中models.event_details.EventDetails的典型用法代码示例。如果您正苦于以下问题:Python EventDetails类的具体用法?Python EventDetails怎么用?Python EventDetails使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了EventDetails类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: TestListDistrictsController

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])
开发者ID:CarterFendley,项目名称:the-blue-alliance,代码行数:60,代码来源:test_apiv2_district_controller.py

示例2: _process_request

    def _process_request(self, request, event_key):
        rankings = JSONRankingsParser.parse(request.body)

        event_details = EventDetails(
            id=event_key,
            rankings=rankings
        )
        if event_details.year >= 2017:  # TODO: Temporary fix. Should directly parse request into rankings2
            event_details.rankings2 = RankingsHelper.convert_rankings(event_details)
        EventDetailsManipulator.createOrUpdate(event_details)

        self.response.out.write(json.dumps({'Success': "Rankings successfully updated"}))
开发者ID:fangeugene,项目名称:the-blue-alliance,代码行数:12,代码来源:api_trusted_controller.py

示例3: TestEventStatsApiController

class TestEventStatsApiController(unittest2.TestCase):
    def setUp(self):
        app = webapp2.WSGIApplication([webapp2.Route(r'/<event_key:>', ApiEventStatsController, 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.matchstats = {
            "dprs": {"971": 10.52178695299036, "114": 23.7313645955704, "115": 29.559784481082044},
            "oprs": {"971": 91.42946669932006, "114": 59.27751047482864, "115": 13.285278757495144},
            "ccwms": {"971": 80.90767974632955, "114": 35.54614587925829, "115": -16.27450572358693},
        }

        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,
                city="Clemson",
                state_prov="SC",
                country="USA",
                start_date=datetime(2010, 03, 24)
        )
        self.event.put()

        self.event_details = EventDetails(
            id=self.event.key.id(),
            matchstats=self.matchstats
        )
        self.event_details.put()

    def tearDown(self):
        self.testbed.deactivate()

    def testEventStatsApi(self):
        response = self.testapp.get('/2010sc', headers={"X-TBA-App-Id": "tba-tests:event-controller-test:v01"})

        matchstats = json.loads(response.body)
        self.assertEqual(self.matchstats, matchstats)
开发者ID:CarlColglazier,项目名称:the-blue-alliance,代码行数:50,代码来源:test_apiv2_event_controller.py

示例4: setUp

    def setUp(self):
        app = webapp2.WSGIApplication([webapp2.Route(r'/<event_key:>', ApiEventRankingsController, 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.rankings = [
            ["Rank", "Team", "QS", "ASSIST", "AUTO", "T&C", "TELEOP", "Record (W-L-T)", "DQ", "PLAYED"],
            ["1", "1126", "20.00", "240.00", "480.00", "230.00", "478.00", "10-2-0", "0", "12"],
            ["2", "5030", "20.00", "200.00", "290.00", "220.00", "592.00", "10-2-0", "0", "12"],
            ["3", "250", "20.00", "70.00", "415.00", "220.00", "352.00", "10-2-0", "0", "12"]
            ]

        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,
                city="Clemson",
                state_prov="SC",
                country="USA",
                start_date=datetime(2010, 03, 24)
        )
        self.event.put()

        self.event_details = EventDetails(
            id=self.event.key.id(),
            rankings=self.rankings
        )
        self.event_details.put()

        self.eventNoRanks = Event(
                id="2010ct",
                name="Palmetto Regional",
                event_type_enum=EventType.REGIONAL,
                short_name="Palmetto",
                event_short="ct",
                year=2010,
                end_date=datetime(2010, 03, 27),
                official=True,
                city="Clemson",
                state_prov="SC",
                country="USA",
                start_date=datetime(2010, 03, 24),
        )
        self.eventNoRanks.put()
开发者ID:CarlColglazier,项目名称:the-blue-alliance,代码行数:57,代码来源:test_apiv2_event_controller.py

示例5: setUp

    def setUp(self):
        app = webapp2.WSGIApplication([webapp2.Route(r'/<district_abbrev:>/<year:>', ApiDistrictEventsController, 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.district = District(
            id='2010ne',
            year=2010,
            abbreviation='ne',
            display_name='New England',
        )
        self.district.put()

        self.event = Event(
                id="2010sc",
                name="Palmetto Regional",
                event_type_enum=EventType.DISTRICT_CMP,
                district_key=ndb.Key(District, '2010ne'),
                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()
开发者ID:CarlColglazier,项目名称:the-blue-alliance,代码行数:56,代码来源:test_apiv2_district_controller.py

示例6: setUp

    def setUp(self):
        self.testbed = testbed.Testbed()
        self.testbed.activate()
        self.testbed.init_datastore_v3_stub()
        self.testbed.init_taskqueue_stub(root_path=".")
        self.testbed.init_memcache_stub()
        ndb.get_context().clear_cache()  # Prevent data from leaking between tests

        self.maxDiff = None

        with open('test_data/usfirst_html/usfirst_event_rankings_2012ct.html', 'r') as f:
            good_rankings, _ = UsfirstEventRankingsParser.parse(f.read())

        with open('test_data/usfirst_html/usfirst_event_rankings_2012ct_bad.html', 'r') as f:
            bad_rankings, _ = UsfirstEventRankingsParser.parse(f.read())

        self.old_alliance_selections = {
            '1': {'picks': ['frc254', 'frc469', 'frc2848', 'frc74'], 'declines':[] },
            '2': {'picks': ['frc1718', 'frc2451', 'frc573', 'frc2016'], 'declines':[] },
            '3': {'picks': ['frc2928', 'frc2013', 'frc1311', 'frc842'], 'declines':[] },
            '4': {'picks': ['frc180', 'frc125', 'frc1323', 'frc2468'], 'declines':[] },
            '5': {'picks': ['frc118', 'frc359', 'frc4334', 'frc865'], 'declines':[] },
            '6': {'picks': ['frc135', 'frc1241', 'frc11', 'frc68'], 'declines':[] },
            '7': {'picks': ['frc3478', 'frc177', 'frc294', 'frc230'], 'declines':[] },
            '8': {'picks': ['frc624', 'frc987', 'frc3476', 'frc123'], 'declines':[] },
        }

        self.new_alliance_selections = {
            '1': {'picks': ['frc254', 'frc469', 'frc2848', 'frc74'], 'declines':[] },
            '2': {'picks': ['frc1718', 'frc2451', 'frc573', 'frc2016'], 'declines':[] },
            '3': {'picks': ['frc2928', 'frc2013', 'frc1311', 'frc842'], 'declines':[] },
            '4': {'picks': ['frc180', 'frc125', 'frc1323', 'frc2468'], 'declines':[] },
            '5': {'picks': ['frc118', 'frc359', 'frc4334', 'frc865'], 'declines':[] },
            '6': {'picks': ['frc135', 'frc1241', 'frc11', 'frc68'], 'declines':[] },
            '7': {'picks': ['frc3478', 'frc177', 'frc294', 'frc230'], 'declines':[] },
            '8': {'picks': ['frc624', 'frc987', 'frc3476', 'frc3015'], 'declines':[] },
        }

        self.old_event_details = EventDetails(
            id='2011ct',
            rankings=good_rankings,
            alliance_selections=self.old_alliance_selections,
        )

        self.new_event_details = EventDetails(
            id='2011ct',
            rankings=bad_rankings,
            alliance_selections=self.new_alliance_selections,
            matchstats={'oprs': {'4255': 7.4877151786460301, '2643': 27.285682906835952, '852': 10.452538750544525, '4159': 25.820137009871139, '581': 18.513816255143144}}
        )
开发者ID:CarlColglazier,项目名称:the-blue-alliance,代码行数:50,代码来源:test_event_details_manipulator.py

示例7: setUp

    def setUp(self):
        app = webapp2.WSGIApplication([webapp2.Route(r'/<event_key:>', ApiEventController, 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,
                event_district_enum=DistrictType.NO_DISTRICT,
                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",
                timezone_id="America/New_York",
                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()
开发者ID:CarterFendley,项目名称:the-blue-alliance,代码行数:47,代码来源:test_apiv2_event_controller.py

示例8: TestEventApiController

class TestEventApiController(unittest2.TestCase):
    def setUp(self):
        app = webapp2.WSGIApplication([webapp2.Route(r'/<event_key:>', ApiEventController, 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.event = Event(
                id="2010sc",
                name="Palmetto Regional",
                event_type_enum=EventType.REGIONAL,
                district_key=None,
                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",
                timezone_id="America/New_York",
                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 assertEventJson(self, event):
        self.assertEqual(event["key"], self.event.key_name)
        self.assertEqual(event["name"], self.event.name)
        self.assertEqual(event["short_name"], self.event.short_name)
        self.assertEqual(event["official"], self.event.official)
        self.assertEqual(event["event_type_string"], self.event.event_type_str)
        self.assertEqual(event["event_type"], self.event.event_type_enum)
        self.assertEqual(event["event_district_string"], self.event.event_district_str)
        self.assertEqual(event["event_district"], self.event.event_district_enum)
        self.assertEqual(event["start_date"], self.event.start_date.date().isoformat())
        self.assertEqual(event["end_date"], self.event.end_date.date().isoformat())
        self.assertEqual(event["location"], self.event.location)
        self.assertEqual(event["venue_address"], self.event.venue_address.replace('\r\n', '\n'))
        self.assertEqual(event["webcast"], json.loads(self.event.webcast_json))
        self.assertEqual(event["alliances"], self.event.alliance_selections)
        self.assertEqual(event["website"], self.event.website)
        self.assertEqual(event["timezone"], self.event.timezone_id)

    def testEventApi(self):
        response = self.testapp.get('/2010sc', headers={"X-TBA-App-Id": "tba-tests:event-controller-test:v01"})

        event_dict = json.loads(response.body)
        self.assertEventJson(event_dict)
开发者ID:CarlColglazier,项目名称:the-blue-alliance,代码行数:77,代码来源:test_apiv2_event_controller.py

示例9: _query_async

 def _query_async(self):
     event_key = self._query_args[0]
     event_details = yield EventDetails.get_by_id_async(event_key)
     raise ndb.Return(event_details)
开发者ID:CarlColglazier,项目名称:the-blue-alliance,代码行数:4,代码来源:event_details_query.py

示例10: generateTeamAtEventStatusAsync

    def generateTeamAtEventStatusAsync(cls, team_key, event):
        """
        Generate [email protected] status items
        :return: a tuple future <long summary string, qual record, qual ranking, playoff status>
        """
        team_number = team_key[3:]
        matches, event_details = yield TeamEventMatchesQuery(team_key, event.key.id()).fetch_async(), EventDetails.get_by_id_async(event.key.id())
        matches = MatchHelper.organizeMatches(matches)

        # Compute alliances
        alliance_number = cls._get_alliance_number(team_key, event_details)

        # Playoff Status
        status, short_playoff_status = cls._get_playoff_status(team_key, matches, alliance_number)

        # Still in quals or team did not make it to elims
        # Compute qual W-L-T
        wins, losses, ties, unplayed_qual = cls._get_qual_wlt(team_key, matches)
        if wins == 0 and losses == 0 and ties == 0:
            # No matches played yet
            status = "Team {} has not played any matches yet.".format(team_number) if not status else status

        # Compute rank & num_teams
        # Gets record from ranking data to account for surrogate matches
        rank, ranking_points, record, num_teams = cls._get_rank(team_number, event_details)
        rank_str = "Rank {} with {} RP".format(rank, ranking_points)

        # Compute final long status for nightbot, if one isn't already there
        if unplayed_qual > 0 and not status:
            if rank is not None:
                status = "Team {} is currently rank {}/{} with a record of {} and {} ranking points.".format(team_number, rank, num_teams, record, ranking_points)
            else:
                status = "Team {} currently has a record of {}.".format(team_number, record)
        elif not status:
            if alliance_number is None:
                status = "Team {} ended qualification matches at rank {}/{} with a record of {}.".format(team_number, rank, num_teams, record)
            elif alliance_number == 0:
                status = "Team {} ended qualification matches at rank {}/{} with a record of {} and was not picked for playoff matches.".format(team_number, rank, num_teams, record)
            else:
                status = "Team {} will be competing in the playoff matches on alliance #{}.".format(team_number, alliance_number)

        raise ndb.Return(status, record, rank_str, short_playoff_status)
开发者ID:CarterFendley,项目名称:the-blue-alliance,代码行数:42,代码来源:event_team_status_helper.py

示例11: TestEventRankingsApiController

class TestEventRankingsApiController(unittest2.TestCase):
    def setUp(self):
        app = webapp2.WSGIApplication([webapp2.Route(r'/<event_key:>', ApiEventRankingsController, 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.rankings = [
            ["Rank", "Team", "QS", "ASSIST", "AUTO", "T&C", "TELEOP", "Record (W-L-T)", "DQ", "PLAYED"],
            ["1", "1126", "20.00", "240.00", "480.00", "230.00", "478.00", "10-2-0", "0", "12"],
            ["2", "5030", "20.00", "200.00", "290.00", "220.00", "592.00", "10-2-0", "0", "12"],
            ["3", "250", "20.00", "70.00", "415.00", "220.00", "352.00", "10-2-0", "0", "12"]
            ]

        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,
                city="Clemson",
                state_prov="SC",
                country="USA",
                start_date=datetime(2010, 03, 24)
        )
        self.event.put()

        self.event_details = EventDetails(
            id=self.event.key.id(),
            rankings=self.rankings
        )
        self.event_details.put()

        self.eventNoRanks = Event(
                id="2010ct",
                name="Palmetto Regional",
                event_type_enum=EventType.REGIONAL,
                short_name="Palmetto",
                event_short="ct",
                year=2010,
                end_date=datetime(2010, 03, 27),
                official=True,
                city="Clemson",
                state_prov="SC",
                country="USA",
                start_date=datetime(2010, 03, 24),
        )
        self.eventNoRanks.put()

    def tearDown(self):
        self.testbed.deactivate()

    def testEventRankingsApi(self):
        response = self.testapp.get('/2010sc', headers={"X-TBA-App-Id": "tba-tests:event-controller-test:v01"})

        rankings = json.loads(response.body)
        self.assertEqual(self.rankings, rankings)

    def testEventNoRankingsApi(self):
        response = self.testapp.get('/2010ct', headers={"X-TBA-App-Id": "tba-tests:event-controller-test:v01"})

        self.assertEqual("[]", response.body)
开发者ID:CarterFendley,项目名称:the-blue-alliance,代码行数:70,代码来源:test_apiv2_event_controller.py

示例12: test_createOrUpdate

 def test_createOrUpdate(self):
     EventDetailsManipulator.createOrUpdate(self.old_event_details)
     self.assertOldEventDetails(EventDetails.get_by_id('2011ct'))
     EventDetailsManipulator.createOrUpdate(self.new_event_details)
     self.assertMergedEventDetails(EventDetails.get_by_id('2011ct'))
开发者ID:CarterFendley,项目名称:the-blue-alliance,代码行数:5,代码来源:test_event_details_manipulator.py

示例13: generateTeamAtEventStatusAsync

    def generateTeamAtEventStatusAsync(cls, team_key, event):
        """
        Generate [email protected] status items
        :return: a tuple future <long summary string, qual record, qual ranking, playoff status>
        """
        team_number = team_key[3:]
        # We need all the event's playoff matches here to properly account for backup teams
        matches, event_details = yield EventMatchesQuery(event.key.id()).fetch_async(), EventDetails.get_by_id_async(event.key.id())
        qual_match_count = 0
        playoff_match_count = 0
        playoff_matches = []
        for match in matches:
            if match.comp_level in Match.ELIM_LEVELS:
                playoff_match_count += 1
                playoff_matches.append(match)
            else:
                qual_match_count += 1
        matches = MatchHelper.organizeMatches(playoff_matches)

        team_status = cls.generate_team_at_event_status(team_key, event, matches)
        rank_status = team_status.get('rank', None)
        alliance_status = team_status.get('alliance', None)
        playoff_status = team_status.get('playoff', None)

        # Playoff Status
        status, short_playoff_status = cls._get_playoff_status_string(team_key, alliance_status, playoff_status)

        # Still in quals or team did not make it to elims
        if not rank_status or rank_status.get('played', 0) == 0:
            # No matches played yet
            status = "Team {} has not played any matches yet.".format(team_number) if not status else status
            record = '?'
            rank_str = '?'
        else:
            # Compute rank & num_teams
            # Gets record from ranking data to account for surrogate matches
            rank = rank_status.get('rank', '?')
            ranking_points = rank_status.get('first_sort', '?')
            record = rank_status.get('record', '?')
            num_teams = rank_status.get('total', '?')
            rank_str = "Rank {} with {} RP".format(rank, ranking_points)
            alliance_name = alliance_status.get('name', '?') if alliance_status else '?'

            # Compute final long status for nightbot, if one isn't already there
            matches_per_team = qual_match_count // rank_status.get('total', 1)
            if rank_status.get('played', 0) - matches_per_team > 0 and not status:
                if rank is not None:
                    status = "Team {} is currently rank {}/{} with a record of {} and {} ranking points.".format(team_number, rank, num_teams, record, ranking_points)
                else:
                    status = "Team {} currently has a record of {}.".format(team_number, record)
            elif not status:
                if alliance_status is None and playoff_match_count == 0:
                    status = "Team {} ended qualification matches at rank {}/{} with a record of {}.".format(team_number, rank, num_teams, record)
                elif alliance_status is None and playoff_match_count > 0:
                    status = "Team {} ended qualification matches at rank {}/{} with a record of {} and was not picked for playoff matches.".format(team_number, rank, num_teams, record)
                else:
                    status = "Team {} will be competing in the playoff matches on {}.".format(team_number, alliance_name)

        raise ndb.Return(status, record, rank_str, short_playoff_status)
开发者ID:brycematsuda,项目名称:the-blue-alliance,代码行数:59,代码来源:event_team_status_helper.py

示例14: setUp

    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

        app = webapp2.WSGIApplication([
            RedirectRoute(r'/event/<event_key>', EventDetail, 'event-detail'),
            RedirectRoute(r'/event/<event_key>/insights', EventInsights, 'event-insights'),
            RedirectRoute(r'/events/<year:[0-9]+>', EventList, 'event-list-year'),
            RedirectRoute(r'/events', EventList, 'event-list'),
        ])
        self.testapp = webtest.TestApp(app)

        self.event1 = Event(
                id="2016necmp",
                name="New England District Championship",
                event_type_enum=EventType.DISTRICT_CMP,
                event_district_enum=DistrictType.NEW_ENGLAND,
                short_name="New England",
                event_short="necmp",
                year=2016,
                end_date=datetime(2016, 03, 27),
                official=True,
                city='Hartford',
                state_prov='CT',
                country='USA',
                venue="Some Venue",
                venue_address="Some Venue, Hartford, CT, USA",
                timezone_id="America/New_York",
                start_date=datetime(2016, 03, 24),
                webcast_json="[{\"type\": \"twitch\", \"channel\": \"frcgamesense\"}]",
                website="http://www.firstsv.org",
        )
        this_year = datetime.now().year
        self.event2 = Event(
                id="2016necmp",
                name="New England District Championship",
                event_type_enum=EventType.DISTRICT_CMP,
                event_district_enum=DistrictType.NEW_ENGLAND,
                short_name="New England",
                event_short="necmp",
                year=this_year,
                end_date=datetime(this_year, 03, 27),
                official=True,
                city='Hartford',
                state_prov='CT',
                country='USA',
                venue="Some Venue",
                venue_address="Some Venue, Hartford, CT, USA",
                timezone_id="America/New_York",
                start_date=datetime(this_year, 03, 24),
                webcast_json="[{\"type\": \"twitch\", \"channel\": \"frcgamesense\"}]",
                website="http://www.firstsv.org",
        )
        self.event1.put()
        self.event2.put()

        self.event1_details = EventDetails(
            id=self.event1.key.id(),
            predictions={"ranking_prediction_stats": None, "match_predictions": None, "ranking_predictions": None, "match_prediction_stats": None}
        )
        self.event1_details.put()

        self.event2_details = EventDetails(
            id=self.event2.key.id(),
            predictions={"ranking_prediction_stats": None, "match_predictions": None, "ranking_predictions": None, "match_prediction_stats": None}
        )
        self.event2_details.put()
开发者ID:brycematsuda,项目名称:the-blue-alliance,代码行数:70,代码来源:test_event_controller.py

示例15: details

 def details(self):
     if self._details is None:
         self._details = EventDetails.get_by_id(self.key.id())
     return self._details
开发者ID:CarterFendley,项目名称:the-blue-alliance,代码行数:4,代码来源:event.py


注:本文中的models.event_details.EventDetails类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。