Esempio n. 1
0
 def test_show_rankings(self):
     soccer_league = SoccerLeague()
     self.assertIsNone(soccer_league.output)
     soccer_league.update(self.fixtures)
     self.assertFalse(os.path.exists(self.output_filename))
     for standing in soccer_league.show_rankings():
         self.assertTrue(standing.strip() in self.expected_output)
Esempio n. 2
0
 def test_show_rankings_to_output_file(self):
     soccer_league = SoccerLeague(self.output_filename)
     self.assertEqual(soccer_league.output, self.output_filename)
     soccer_league.update(self.fixtures)
     soccer_league.show_rankings()
     self.assertTrue(os.path.exists(self.output_filename))
     with open(self.output_filename) as fd:
         for standing in fd:
             self.assertTrue(standing.strip() in self.expected_output)
Esempio n. 3
0
    def test_update(self):
        soccer_league = SoccerLeague()
        self.assertIsNone(soccer_league.output)
        soccer_league.update(self.fixtures)
        self.assertFalse(os.path.exists(self.output_filename))
        for standing in soccer_league.show_rankings():
            self.assertTrue(standing.strip() in self.expected_output)

        expected_output = [
            "1. Lions, 6 pts",
            "1. Tarantulas, 6 pts",
            "3. FC Awesome, 2 pts",
            "3. Snakes, 2 pts",
            "5. Grouches, 1 pts",
        ]
        soccer_league.update(StringIO.StringIO("Lions 3, Snakes 3"))
        soccer_league.update(StringIO.StringIO("FC Awesome 0, Grouches 0"))
        for standing in soccer_league.show_rankings():
            self.assertTrue(standing.strip() in expected_output)