Example #1
0
 def testAthletes(self):
     """ test add_athlete and get_athletes"""
     country1 = entities.Country("Canada", "CAN")
     ath1 = entities.Athlete("1635", "John", "Smith", country1)
     self.assertEqual(country1.get_athletes(), [])
     country1.add_athlete(ath1)
     self.assertEqual(country1.get_athletes(), [ath1])
Example #2
0
 def _processing_setup(self) :
     """ Create a country with athletes and results to test 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(2)
     result2.set_place(3)
     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)
     country1.add_athlete(athlete1)
     country1.add_athlete(athlete2)
     country1.add_athlete(athlete3)
     event1.add_athlete(athlete1)
     event1.add_athlete(athlete2)
     event1.add_athlete(athlete3)
     return country1
Example #3
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])
Example #4
0
 def testGetResults(self):
     """ test get_results"""
     athleteResults = processing.AthleteResults(
         entities.Athlete("12345", "John", "Smith",
                          entities.Country("Canada", "CAN")))
     with self.assertRaises(ValueError):
         athleteResults.get_results()
Example #5
0
 def testAthlete(self):
     """ test add_athlete and get_athletes"""
     country1 = entities.Country("Canada", "CAN")
     athlete1 = entities.Athlete("1635", "John", "Smith", country1)
     event1 = entities.Event("Skiing", True, [])
     self.assertEqual(event1.get_athletes(), [])
     event1.add_athlete(athlete1)
     self.assertEqual(event1.get_athletes(), [athlete1])
Example #6
0
 def testEvents(self):
     """ test get_events and add_event"""
     country1 = entities.Country("Canada", "CAN")
     athlete1 = entities.Athlete("12345", "John", "Smith", country1)
     self.assertEqual(athlete1.get_events(), [])
     event1 = entities.Event("Skiing", False, [])
     athlete1.add_event(event1)
     self.assertEqual(athlete1.get_events(), [event1])
Example #7
0
 def testResults(self):
     """ test get_result and add_result"""
     country1 = entities.Country("Canada", "CAN")
     athlete1 = entities.Athlete("12345", "John", "Smith", country1)
     event1 = entities.Event("Skiing", False, [])
     athlete1.add_event(event1)
     result1 = entities.Result(15.1)
     athlete1.add_result(event1, result1)
     self.assertEqual(athlete1.get_result(event1), result1)
Example #8
0
 def testProcessing(self):
     """ test athlete processing """
     country1 = entities.Country("Canada", "CAN")
     athlete1 = entities.Athlete("12345", "John", "Smith", country1)
     event1 = entities.Event("Skiing 2000m", True, [athlete1])
     event2 = entities.Event("Skiing 4000m", True, [athlete1])
     event3 = entities.Event("Asking 6000m", True, [athlete1])
     athlete1.add_event(event1)
     athlete1.add_event(event2)
     athlete1.add_event(event3)
     result1 = entities.Result(28.4)
     result2 = entities.Result(60.47)
     result3 = entities.Result(174.3)
     result1.set_place(15)
     result2.set_place(7)
     result3.set_place(12)
     athlete1.add_result(event1, result1)
     athlete1.add_result(event2, result2)
     athlete1.add_result(event3, result3)
     athleteProcessing = processing.AthleteResults(athlete1)
     athleteProcessing.process()
     self.assertEqual(athleteProcessing.get_results(),
                      [result2, result3, result1])
Example #9
0
 def testProcessing(self):
     """ test place 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(128.4)
     result2 = entities.Result(60.47)
     result3 = entities.Result(174.3)
     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)
     places = processing.DeterminePlaces(event1)
     places.process()
     self.assertEqual(places.get_results(), [athlete2, athlete1, athlete3])
     self.assertEqual(result1.get_place(), "2")
     self.assertEqual(result2.get_place(), "1")
Example #10
0
 def testGetResults(self):
     """ Test get_results fails before processing is called. """
     countryResults = processing.CountryResults(entities.Country("Canada", "CAN"))
     with self.assertRaises(ValueError):
         countryResults.get_results()
Example #11
0
 def testCountry(self):
     """ test get_country"""
     country1 = entities.Country("Canada", "CAN")
     self.assertEqual(entities.Athlete("12345", "John", "Smith", country1).get_country(), country1)
Example #12
0
 def testName(self):
     """ test get_full_name"""
     country1 = entities.Country("Canada", "CAN")
     self.assertEqual(entities.Athlete("12345", "John", "Smith", country1).get_full_name(),
                      "John Smith")
Example #13
0
 def testGetCountryCode(self):
     """ test get_country_code"""
     self.assertEqual(entities.Country("Australia", "AUS").get_country_code(), "AUS")
Example #14
0
 def testGetName(self):
     """ test get_name"""
     self.assertEqual(entities.Country("Canada", "CAN").get_name(), "Canada")