Esempio n. 1
0
    def test_when_add_member_from_wrong_type_return_exception(self):
        member = Player("Pesho")
        member_type_string = "Acer"
        team = Team("Wolf")

        with self.assertRaises(TypeError):
            team.add_team_members([member, member_type_string])
Esempio n. 2
0
    def test_team_jsonable(self):
        player1 = Player("Marto")
        player2 = Player("Pesho")

        team1 = Team("Wolf")
        team1.add_team_members([player1, player2])

        self.assertEqual(
            team1.to_json(),
            json.dumps(
                {
                    "Wolf": [{
                        "Marto": {
                            "points": 0,
                            "announcements": [],
                            "cards": []
                        }
                    }, {
                        "Pesho": {
                            "points": 0,
                            "announcements": [],
                            "cards": []
                        }
                    }]
                },
                cls=OurEncoder))
Esempio n. 3
0
    def test_when_add_more_members_from_2_exception(self):
        member1 = Player("Pesho")
        member2 = Player("Gosho")
        member3 = Player("Thosho")
        team = Team("Wolf")

        with self.assertRaises(ValueError):
            team.add_team_members([member1, member2, member3])
Esempio n. 4
0
    def test_when_add_two_members_to_team_return_correctly(self):
        member1 = Player("Pesho")
        member2 = Player("Gosho")
        team = Team("Wolf")

        team.add_team_members([member1, member2])

        self.assertEqual(len(team.players), 2)
        self.assertTrue(team.players.__contains__(member1))
        self.assertTrue(team.players.__contains__(member2))
Esempio n. 5
0
    def test_game_jsonable(self):
        player1 = Player("Marto")
        player2 = Player("Pesho")
        player3 = Player("Nasko")
        player4 = Player("Petko")

        team1 = Team("Wolf")
        team2 = Team("Lion")
        team1.add_team_members([player1, player2])
        team2.add_team_members([player3, player4])

        round1 = Round("All trumps", 1)
        round1.add_round_members([team1, team2])

        game = Game([team1, team2], 1)
        game.rounds.append(round1)

        self.assertEqual(
            game.to_json(),
            json.dumps(
                {
                    "game 1": [{
                        "round 1": [{
                            "Wolf": [{
                                "Marto": {
                                    "points": 0,
                                    "announcements": [],
                                    "cards": []
                                }
                            }, {
                                "Pesho": {
                                    "points": 0,
                                    "announcements": [],
                                    "cards": []
                                }
                            }]
                        }, {
                            "Lion": [{
                                "Nasko": {
                                    "points": 0,
                                    "announcements": [],
                                    "cards": []
                                }
                            }, {
                                "Petko": {
                                    "points": 0,
                                    "announcements": [],
                                    "cards": []
                                }
                            }]
                        }]
                    }]
                },
                cls=OurEncoder))
Esempio n. 6
0
    def test_create_new_game(self):
        player1 = Player("Marto")
        player2 = Player("Pesho")
        player3 = Player("Nasko")
        player4 = Player("Petko")

        team1 = Team("Wolf")
        team2 = Team("Lion")
        team1.add_team_members([player1, player2])
        team2.add_team_members([player3, player4])

        game = Game([team1, team2], 1)

        self.assertEqual(game.rounds, [])
        self.assertEqual(game.game_number, 1)
        self.assertEqual(game.winner, False)
        self.assertEqual(game.current_round, 1)