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
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])
def testGetMedal(self): """ test get_medal """ res1 = entities.Result(542) with self.assertRaises(RuntimeError): res1.get_medal() res1.set_place(3) self.assertEqual(res1.get_medal(), "Bronze")
def testGetPlace(self): """ test get_place """ res1 = entities.Result(4.4) with self.assertRaises(RuntimeError): res1.get_place() res1.set_place(4) self.assertEqual(res1.get_place(), "4")
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)
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])
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")
def testPlacesDetermined(self): """ test places_determined """ res1 = entities.Result(4.2) self.assertFalse(res1.places_determined()) res1.set_place(4) self.assertTrue(res1.places_determined())
def testGetResult(self): """ test get_result """ self.assertEqual(entities.Result(1.3).get_result(), "1.3")