Exemplo 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)
Exemplo 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)
Exemplo n.º 3
0
 def test_get_score(self):
     score = SoccerLeague.get_score("Grouches 1, Lions 0")
     self.assertTrue(isinstance(score, list))
     for item in score:
         self.assertTrue(isinstance(item, dict))
         self.assertTrue('name' in item)
         self.assertTrue('score' in item)
     self.assertEqual(score[0], {'name': 'Grouches', 'score': 1})
     self.assertEqual(score[1], {'name': 'Lions', 'score': 0})
Exemplo n.º 4
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)