Beispiel #1
0
 def testProcessing(self):
     """ test event processing """
     country1 = entities.Country("Canada", "CAN")
     athlete1 = entities.Athlete("12345", "John", "Smith", country1)
     athlete2 = entities.Athlete("12346", "David", "Smith", country1)
     athlete3 = entities.Athlete("12347", "Thomas", "Jones", country1)
     event1 = entities.Event("Skiing 2000m", True, [])
     result1 = entities.Result(28.4)
     result2 = entities.Result(60.47)
     result3 = entities.Result(174.3)
     result1.set_place(8)
     result2.set_place(5)
     result3.set_place(10)
     athlete1.add_event(event1)
     athlete2.add_event(event1)
     athlete3.add_event(event1)
     athlete1.add_result(event1, result1)
     athlete2.add_result(event1, result2)
     athlete3.add_result(event1, result3)
     event1.add_athlete(athlete1)
     event1.add_athlete(athlete2)
     event1.add_athlete(athlete3)
     eventProcessing = processing.EventResults(event1)
     eventProcessing.process()
     self.assertEqual(eventProcessing.get_results(),
                      [athlete2, athlete1, athlete3])
Beispiel #2
0
    def testProcessing(self):
        """ test data processing from loaded file"""
        for event in entities.all_events.get_items():
            processing.DeterminePlaces(event).process()

        countryProcessing = processing.CountryResults(
            entities.all_countries.find_item("GER"))
        countryProcessing.process()
        self.assertEqual(countryProcessing.get_results(), [1, 1, 1, 3])

        eventProcessing = processing.EventResults(
            entities.all_events.find_item("Men's Speedskating 5000m"))
        eventProcessing.process()
        self.assertEqual(eventProcessing.get_results(), [
            entities.all_athletes.find_item("60"),
            entities.all_athletes.find_item("54"),
            entities.all_athletes.find_item("61")
        ])

        athlete50 = entities.all_athletes.find_item("50")
        athleteProcessing = processing.AthleteResults(athlete50)
        athleteProcessing.process()
        self.assertEqual(athleteProcessing.get_results(), [
            athlete50.get_result(
                entities.all_events.find_item("Men's Speedskating 500m")),
            athlete50.get_result(
                entities.all_events.find_item("Men's Speedskating 1000m"))
        ])
Beispiel #3
0
 def testGetResults(self):
     """ test get_results"""
     eventResults = processing.EventResults(entities.Event("Skiing", False, []))
     with self.assertRaises(ValueError):
         eventResults.get_results()