Esempio n. 1
0
class Angrydice_print_winner_test(unittest.TestCase):
    def setUp(self):
        self.angrygame = AngryDiceGame()

    def tearDown(self):
        del self.angrygame

    @patch('sys.stdout', new_callable=StringIO)
    def test_winner(self, mock_stdout):

        winner_text = "You've won! Calm down!\n"

        self.angrygame.winner()
        self.assertEqual(mock_stdout.getvalue(), winner_text)
Esempio n. 2
0
class Angrydice_cheat_test(unittest.TestCase):

    def setUp(self):
        self.angrygame = AngryDiceGame()

    def tearDown(self):
        del self.angrygame

    @patch('sys.stdout', new_callable=StringIO)
    def test_cheat_check_input_a(self, mock_stdout):

        self.angrygame.die_a.currentValue = "6"
        self.angrygame.die_a.value = 6
        self.angrygame.die_b.currentValue = "5"
        self.angrygame.die_b.value = 5
        self.angrygame.current_stage = 3

        cheat_text = "HA! That is cheating. Roll again!\n"

        self.angrygame.cheat_check("a")

        self.assertNotEqual(mock_stdout.getvalue(), cheat_text)
        self.assertEqual(self.angrygame.current_stage, 3)

    @patch('sys.stdout', new_callable=StringIO)
    def test_cheat_check_input_b(self, mock_stdout):

        self.angrygame.die_a.currentValue = "5"
        self.angrygame.die_a.value = 5
        self.angrygame.die_b.currentValue = "6"
        self.angrygame.die_b.value = 6
        self.angrygame.current_stage = 3

        cheat_text = "HA! That is cheating. Roll again!\n"

        self.angrygame.cheat_check("b")

        self.assertNotEqual(mock_stdout.getvalue(), cheat_text)
        self.assertEqual(self.angrygame.current_stage, 3)
Esempio n. 3
0
class Angrydice_cheat_test(unittest.TestCase):
    def setUp(self):
        self.angrygame = AngryDiceGame()

    def tearDown(self):
        del self.angrygame

    @patch('sys.stdout', new_callable=StringIO)
    def test_cheat_check_input_a(self, mock_stdout):

        self.angrygame.die_a.currentValue = "6"
        self.angrygame.die_a.value = 6
        self.angrygame.die_b.currentValue = "5"
        self.angrygame.die_b.value = 5
        self.angrygame.current_stage = 3

        cheat_text = "HA! That is cheating. Roll again!\n"

        self.angrygame.cheat_check("a")

        self.assertNotEqual(mock_stdout.getvalue(), cheat_text)
        self.assertEqual(self.angrygame.current_stage, 3)

    @patch('sys.stdout', new_callable=StringIO)
    def test_cheat_check_input_b(self, mock_stdout):

        self.angrygame.die_a.currentValue = "5"
        self.angrygame.die_a.value = 5
        self.angrygame.die_b.currentValue = "6"
        self.angrygame.die_b.value = 6
        self.angrygame.current_stage = 3

        cheat_text = "HA! That is cheating. Roll again!\n"

        self.angrygame.cheat_check("b")

        self.assertNotEqual(mock_stdout.getvalue(), cheat_text)
        self.assertEqual(self.angrygame.current_stage, 3)
Esempio n. 4
0
class Angrydice_user_roll_test(unittest.TestCase):
    def setUp(self):
        self.angrygame = AngryDiceGame()

    def tearDown(self):
        del self.angrygame

    @patch('builtins.input', return_value='ab')
    @patch('sys.stdout', new_callable=StringIO)
    def test_user_roll(self, mock_stdout, inputted_value):

        roll_dice_text = """You rolled:
            a = [  {}  ]
            b = [  {}  ]

            You are in Stage {}\n""".format(self.angrygame.die_a.currentValue,
                                            self.angrygame.die_b.currentValue,
                                            self.angrygame.current_stage)

        userInput = self.angrygame.user_roll()

        self.assertEqual(mock_stdout.getvalue(), roll_dice_text)
        self.assertEqual(userInput, "ab")
 def setUp(self):
     self.angrygame = AngryDiceGame()
class Angrydice_check_stage_Three_test(unittest.TestCase):
    def setUp(self):
        self.angrygame = AngryDiceGame()

    def tearDown(self):
        del self.angrygame

    @patch('sys.stdout', new_callable=StringIO)
    def test_die_a_is_five_and_die_b_is_six(self, mock_stdout):
        self.angrygame.die_a.currentValue = "5"
        self.angrygame.die_a.value = 5
        self.angrygame.die_b.currentValue = "6"
        self.angrygame.die_b.value = 6
        self.angrygame.current_stage = 3

        self.cheating = False

        roll_dice_text = """You rolled:
                a = [  {}  ]
                b = [  {}  ]

                You are in Stage {}\n
You've won! Calm down!\n""".format(self.angrygame.die_a.currentValue,
                                   self.angrygame.die_b.currentValue,
                                   self.angrygame.current_stage)

        self.angrygame.stage_Three()

        self.assertEqual(self.angrygame.current_stage, 4)
        self.assertEqual(mock_stdout.getvalue(), roll_dice_text)

    @patch('sys.stdout', new_callable=StringIO)
    def test_die_a_is_six_and_die_b_is_five(self, mock_stdout):
        self.angrygame.die_a.currentValue = "6"
        self.angrygame.die_a.value = 6
        self.angrygame.die_b.currentValue = "5"
        self.angrygame.die_b.value = 5
        self.angrygame.current_stage = 3

        self.cheating = False

        roll_dice_text = """You rolled:
                a = [  {}  ]
                b = [  {}  ]


You've won! Calm down!\n""".format(self.angrygame.die_a.currentValue,
                                   self.angrygame.die_b.currentValue,
                                   self.angrygame.current_stage)

        self.angrygame.stage_Three()

        self.assertEqual(self.angrygame.current_stage, 4)
        self.assertEqual(mock_stdout.getvalue(), roll_dice_text)

    def test_die_a_is_five_and_die_b_not_valid(self):
        self.angrygame.die_a.currentValue = "5"
        self.angrygame.die_a.value = 5
        self.angrygame.die_b.currentValue = "6"
        self.angrygame.die_b.value = 6
        self.angrygame.current_stage = 3

        self.cheating = True

        self.angrygame.stage_Three()

        self.assertNotEqual(self.angrygame.current_stage, 3)

    def test_die_b_is_five_and_die_a_not_valid(self):
        self.angrygame.die_a.currentValue = "6"
        self.angrygame.die_a.value = 6
        self.angrygame.die_b.currentValue = "5"
        self.angrygame.die_b.value = 5
        self.angrygame.current_stage = 3

        self.cheating = True

        self.angrygame.stage_Three()

        self.assertNotEqual(self.angrygame.current_stage, 3)

    def test_die_a_and_die_b_not_valid_values(self):
        self.angrygame.die_a.currentValue = "6"
        self.angrygame.die_a.value = 6
        self.angrygame.die_b.currentValue = "6"
        self.angrygame.die_b.value = 6
        self.angrygame.current_stage = 3

        self.cheating = True

        self.angrygame.stage_Three()

        self.assertEqual(self.angrygame.current_stage, 3)
Esempio n. 7
0
class Angrydice_check_stage_One_test(unittest.TestCase):
    def setUp(self):
        self.angrygame = AngryDiceGame()

    def tearDown(self):
        del self.angrygame

    def test_die_a_is_one_and_die_b_is_two(self):
        self.angrygame.die_a.currentValue = "1"
        self.angrygame.die_a.value = 1
        self.angrygame.die_b.currentValue = "2"
        self.angrygame.die_b.value = 2
        self.angrygame.current_stage = 1

        self.angrygame.stage_One()

        self.assertEqual(self.angrygame.current_stage, 2)

    def test_die_b_one_die_a_is_two(self):
        self.angrygame.die_a.currentValue = "2"
        self.angrygame.die_a.value = 2
        self.angrygame.die_b.currentValue = "1"
        self.angrygame.die_b.value = 1
        self.angrygame.current_stage = 1

        self.angrygame.stage_One()

        self.assertEqual(self.angrygame.current_stage, 2)

    def test_die_a_is_one_and_die_b_not_valid(self):
        self.angrygame.die_a.currentValue = "1"
        self.angrygame.die_a.value = 1
        self.angrygame.die_b.currentValue = "1"
        self.angrygame.die_b.value = 1
        self.angrygame.current_stage = 1

        self.assertNotEqual(self.angrygame.current_stage, 2)

    def test_die_a_is_two_and_die_b_not_valid(self):
        self.angrygame.die_a.currentValue = "2"
        self.angrygame.die_a.value = 2
        self.angrygame.die_b.currentValue = "2"
        self.angrygame.die_b.value = 2
        self.angrygame.current_stage = 1

        self.angrygame.stage_One()

        self.assertNotEqual(self.angrygame.current_stage, 2)

    def test_die_b_is_one_die_a_not_valid(self):
        self.angrygame.die_a.currentValue = "1"
        self.angrygame.die_a.value = 1
        self.angrygame.die_b.currentValue = "1"
        self.angrygame.die_b.value = 1
        self.angrygame.current_stage = 1

        self.angrygame.stage_One()

        self.assertNotEquals(self.angrygame.current_stage, 2)

    def test_die_b_is_two_die_a_not_valid(self):
        self.angrygame.die_a.currentValue = "2"
        self.angrygame.die_a.value = 2
        self.angrygame.die_b.currentValue = "2"
        self.angrygame.die_b.value = 2
        self.angrygame.current_stage = 1

        self.angrygame.stage_One()

        self.assertNotEqual(self.angrygame.current_stage, 2)

    def test_die_a_die_b_not_valid_values(self):
        self.angrygame.die_a.currentValue = "5"
        self.angrygame.die_a.value = 5
        self.angrygame.die_b.currentValue = "5"
        self.angrygame.die_b.value = 5
        self.angrygame.current_stage = 1

        self.angrygame.stage_One()

        self.assertNotEqual(self.angrygame.current_stage, 2)
Esempio n. 8
0
 def setUp(self):
     self.angrygame = AngryDiceGame()
Esempio n. 9
0
class Angrydice_check_stage_One_test(unittest.TestCase):
    def setUp(self):
        self.angrygame = AngryDiceGame()

    def tearDown(self):
        del self.angrygame

    def test_die_a_is_one_and_die_b_is_two(self):
        self.angrygame.die_a.currentValue = "1"
        self.angrygame.die_a.value = 1
        self.angrygame.die_b.currentValue = "2"
        self.angrygame.die_b.value = 2
        self.angrygame.current_stage = 1

        self.angrygame.stage_One()

        self.assertEqual(self.angrygame.current_stage, 2)

    def test_die_b_one_die_a_is_two(self):
        self.angrygame.die_a.currentValue = "2"
        self.angrygame.die_a.value = 2
        self.angrygame.die_b.currentValue = "1"
        self.angrygame.die_b.value = 1
        self.angrygame.current_stage = 1

        self.angrygame.stage_One()

        self.assertEqual(self.angrygame.current_stage, 2)

    def test_die_a_is_one_and_die_b_not_valid(self):
        self.angrygame.die_a.currentValue = "1"
        self.angrygame.die_a.value = 1
        self.angrygame.die_b.currentValue = "1"
        self.angrygame.die_b.value = 1
        self.angrygame.current_stage = 1

        self.assertNotEqual(self.angrygame.current_stage, 2)

    def test_die_a_is_two_and_die_b_not_valid(self):
        self.angrygame.die_a.currentValue = "2"
        self.angrygame.die_a.value = 2
        self.angrygame.die_b.currentValue = "2"
        self.angrygame.die_b.value = 2
        self.angrygame.current_stage = 1

        self.angrygame.stage_One()

        self.assertNotEqual(self.angrygame.current_stage, 2)

    def test_die_b_is_one_die_a_not_valid(self):
        self.angrygame.die_a.currentValue = "1"
        self.angrygame.die_a.value = 1
        self.angrygame.die_b.currentValue = "1"
        self.angrygame.die_b.value = 1
        self.angrygame.current_stage = 1

        self.angrygame.stage_One()

        self.assertNotEquals(self.angrygame.current_stage, 2)

    def test_die_b_is_two_die_a_not_valid(self):
        self.angrygame.die_a.currentValue = "2"
        self.angrygame.die_a.value = 2
        self.angrygame.die_b.currentValue = "2"
        self.angrygame.die_b.value = 2
        self.angrygame.current_stage = 1

        self.angrygame.stage_One()

        self.assertNotEqual(self.angrygame.current_stage, 2)

    def test_die_a_die_b_not_valid_values(self):
        self.angrygame.die_a.currentValue = "5"
        self.angrygame.die_a.value = 5
        self.angrygame.die_b.currentValue = "5"
        self.angrygame.die_b.value = 5
        self.angrygame.current_stage = 1

        self.angrygame.stage_One()

        self.assertNotEqual(self.angrygame.current_stage, 2)
Esempio n. 10
0
class Angrydice_check_angry_test(unittest.TestCase):
    def setUp(self):
        self.angrygame = AngryDiceGame()

    def tearDown(self):
        del self.angrygame

    # Mocks being sys.stdout and will store what is print()'d
    # into mock_stdout
    @patch('sys.stdout', new_callable=StringIO)
    def test_both_dice_angry(self, mock_stdout):
        """This test checks if both die are equal to three to equal ANGRY"""

        self.angrygame.die_a.currentValue = "ANGRY"
        self.angrygame.die_a.value = 3
        self.angrygame.die_b.currentValue = "ANGRY"
        self.angrygame.die_b.value = 3
        self.angrygame.current_stage = 2

        angry_text = "WOAH! Enhance your calm, John Spartan. Go back to stage 1!\n"

        self.angrygame.check_angry()

        self.assertEqual(mock_stdout.getvalue(), angry_text)
        self.assertEqual(self.angrygame.current_stage, 1)

    def test_die_a_angry(self):
        """This test checks if both die are equal to three to equal angry"""

        self.angrygame.die_a.currentValue = "ANGRY"
        self.angrygame.die_a.value = 3
        self.angrygame.die_b.currentValue = "5"
        self.angrygame.die_b.value = 5
        self.angrygame.current_stage = 2

        self.angrygame.check_angry()

        self.assertNotEqual(self.angrygame.current_stage, 1)

    def test_die_b_angry(self):
        """This test checks if both die are equal to three to equal angry"""
        self.angrygame.die_a.currentValue = "1"
        self.angrygame.die_a.value = 1
        self.angrygame.die_b.currentValue = "ANGRY"
        self.angrygame.die_b.value = 3
        self.angrygame.current_stage = 3

        self.angrygame.check_angry()

        self.assertNotEqual(self.angrygame.current_stage, 1)

    def test_die_a_die_b_not_angry(self):
        """ This test checks is both die are not equal to angry"""
        self.angrygame.die_a.currentValue = "1"
        self.angrygame.die_a.value = 1
        self.angrygame.die_b.currentValue = "6"
        self.angrygame.die_b.value = 6
        self.angrygame.current_stage = 2

        self.angrygame.check_angry()

        self.assertEqual(self.angrygame.current_stage, 2)
Esempio n. 11
0
class Angrydice_check_angry_test(unittest.TestCase):

    def setUp(self):
        self.angrygame = AngryDiceGame()

    def tearDown(self):
        del self.angrygame

    # Mocks being sys.stdout and will store what is print()'d
    # into mock_stdout
    @patch('sys.stdout', new_callable=StringIO)
    def test_both_dice_angry(self, mock_stdout):
        """This test checks if both die are equal to three to equal ANGRY"""

        self.angrygame.die_a.currentValue = "ANGRY"
        self.angrygame.die_a.value = 3
        self.angrygame.die_b.currentValue = "ANGRY"
        self.angrygame.die_b.value = 3
        self.angrygame.current_stage = 2

        angry_text = "WOAH! Enhance your calm, John Spartan. Go back to stage 1!\n"

        self.angrygame.check_angry()

        self.assertEqual(mock_stdout.getvalue(), angry_text)
        self.assertEqual(self.angrygame.current_stage, 1)

    def test_die_a_angry(self):
        """This test checks if both die are equal to three to equal angry"""

        self.angrygame.die_a.currentValue = "ANGRY"
        self.angrygame.die_a.value = 3
        self.angrygame.die_b.currentValue = "5"
        self.angrygame.die_b.value = 5
        self.angrygame.current_stage = 2

        self.angrygame.check_angry()

        self.assertNotEqual(self.angrygame.current_stage, 1)

    def test_die_b_angry(self):
        """This test checks if both die are equal to three to equal angry"""
        self.angrygame.die_a.currentValue = "1"
        self.angrygame.die_a.value = 1
        self.angrygame.die_b.currentValue = "ANGRY"
        self.angrygame.die_b.value = 3
        self.angrygame.current_stage = 3

        self.angrygame.check_angry()

        self.assertNotEqual(self.angrygame.current_stage, 1)

    def test_die_a_die_b_not_angry(self):
        """ This test checks is both die are not equal to angry"""
        self.angrygame.die_a.currentValue = "1"
        self.angrygame.die_a.value = 1
        self.angrygame.die_b.currentValue = "6"
        self.angrygame.die_b.value = 6
        self.angrygame.current_stage = 2

        self.angrygame.check_angry()

        self.assertEqual(self.angrygame.current_stage, 2)
Esempio n. 12
0
class Angrydice_check_stage_Two_test(unittest.TestCase):

    def setUp(self):
        self.angrygame = AngryDiceGame()

    def tearDown(self):
        del self.angrygame

    def test_die_a_is_ANGRY_and_die_b_is_four(self):
        self.angrygame.die_a.currentValue = "ANGRY"
        self.angrygame.die_a.value = 3
        self.angrygame.die_b.currentValue = "4"
        self.angrygame.die_b.value = 4
        self.angrygame.current_stage = 2

        self.angrygame.stage_Two()

        self.assertEqual(self.angrygame.current_stage, 3)

    def test_die_b_ANGRY_die_a_is_four(self):
        self.angrygame.die_a.currentValue = "4"
        self.angrygame.die_a.value = 4
        self.angrygame.die_b.currentValue = "ANGRY"
        self.angrygame.die_b.value = 3
        self.angrygame.current_stage = 2

        self.angrygame.stage_Two()

        self.assertEqual(self.angrygame.current_stage, 3)

    def test_die_a_is_ANGRY_and_die_b_not_valid(self):
        self.angrygame.die_a.currentValue = "ANGRY"
        self.angrygame.die_a.value = 3
        self.angrygame.die_b.currentValue = "ANGRY"
        self.angrygame.die_b.value = 3
        self.angrygame.current_stage = 2

        self.angrygame.stage_Two()

        self.assertNotEqual(self.angrygame.current_stage, 3)

    def test_die_a_is_four_and_die_b_not_valid(self):
        self.angrygame.die_a.currentValue = "4"
        self.angrygame.die_a.value = 4
        self.angrygame.die_b.currentValue = "4"
        self.angrygame.die_b.value = 4
        self.angrygame.current_stage = 2

        self.angrygame.stage_Two()

        self.assertNotEqual(self.angrygame.current_stage, 3)

    def test_die_b_is_ANGRY_die_a_not_valid(self):
        self.angrygame.die_a.currentValue = "2"
        self.angrygame.die_a.value = 2
        self.angrygame.die_b.currentValue = "ANGRY"
        self.angrygame.die_b.value = 3
        self.angrygame.current_stage = 2

        self.angrygame.stage_Two()

        self.assertNotEquals(self.angrygame.current_stage, 3)

    def test_die_b_is_four_die_a_not_valid(self):
        self.angrygame.die_a.currentValue = "4"
        self.angrygame.die_a.value = 4
        self.angrygame.die_b.currentValue = "4"
        self.angrygame.die_b.value = 4
        self.angrygame.current_stage = 2

        self.angrygame.stage_Two()

        self.assertNotEqual(self.angrygame.current_stage, 3)

    def test_die_a_die_b_not_valid_values(self):
        self.angrygame.die_a.currentValue = "5"
        self.angrygame.die_a.value = 5
        self.angrygame.die_b.currentValue = "1"
        self.angrygame.die_b.value = 1
        self.angrygame.current_stage = 2

        self.angrygame.stage_Two()

        self.assertNotEqual(self.angrygame.current_stage, 3)
Esempio n. 13
0
class Angrydice_check_stage_Two_test(unittest.TestCase):
    def setUp(self):
        self.angrygame = AngryDiceGame()

    def tearDown(self):
        del self.angrygame

    def test_die_a_is_ANGRY_and_die_b_is_four(self):
        self.angrygame.die_a.currentValue = "ANGRY"
        self.angrygame.die_a.value = 3
        self.angrygame.die_b.currentValue = "4"
        self.angrygame.die_b.value = 4
        self.angrygame.current_stage = 2

        self.angrygame.stage_Two()

        self.assertEqual(self.angrygame.current_stage, 3)

    def test_die_b_ANGRY_die_a_is_four(self):
        self.angrygame.die_a.currentValue = "4"
        self.angrygame.die_a.value = 4
        self.angrygame.die_b.currentValue = "ANGRY"
        self.angrygame.die_b.value = 3
        self.angrygame.current_stage = 2

        self.angrygame.stage_Two()

        self.assertEqual(self.angrygame.current_stage, 3)

    def test_die_a_is_ANGRY_and_die_b_not_valid(self):
        self.angrygame.die_a.currentValue = "ANGRY"
        self.angrygame.die_a.value = 3
        self.angrygame.die_b.currentValue = "ANGRY"
        self.angrygame.die_b.value = 3
        self.angrygame.current_stage = 2

        self.angrygame.stage_Two()

        self.assertNotEqual(self.angrygame.current_stage, 3)

    def test_die_a_is_four_and_die_b_not_valid(self):
        self.angrygame.die_a.currentValue = "4"
        self.angrygame.die_a.value = 4
        self.angrygame.die_b.currentValue = "4"
        self.angrygame.die_b.value = 4
        self.angrygame.current_stage = 2

        self.angrygame.stage_Two()

        self.assertNotEqual(self.angrygame.current_stage, 3)

    def test_die_b_is_ANGRY_die_a_not_valid(self):
        self.angrygame.die_a.currentValue = "2"
        self.angrygame.die_a.value = 2
        self.angrygame.die_b.currentValue = "ANGRY"
        self.angrygame.die_b.value = 3
        self.angrygame.current_stage = 2

        self.angrygame.stage_Two()

        self.assertNotEquals(self.angrygame.current_stage, 3)

    def test_die_b_is_four_die_a_not_valid(self):
        self.angrygame.die_a.currentValue = "4"
        self.angrygame.die_a.value = 4
        self.angrygame.die_b.currentValue = "4"
        self.angrygame.die_b.value = 4
        self.angrygame.current_stage = 2

        self.angrygame.stage_Two()

        self.assertNotEqual(self.angrygame.current_stage, 3)

    def test_die_a_die_b_not_valid_values(self):
        self.angrygame.die_a.currentValue = "5"
        self.angrygame.die_a.value = 5
        self.angrygame.die_b.currentValue = "1"
        self.angrygame.die_b.value = 1
        self.angrygame.current_stage = 2

        self.angrygame.stage_Two()

        self.assertNotEqual(self.angrygame.current_stage, 3)
Esempio n. 14
0
class Angrydice_roll_test(unittest.TestCase):

    def setUp(self):
        self.angrygame = AngryDiceGame()

    def tearDown(self):
        del self.angrygame


    def test_input_a_and_b(self):

        self.angrygame.die_a.value = 8
        self.angrygame.die_b.value = 8

        self.angrygame.roll("ab")

        self.assertNotEqual(self.angrygame.die_a.value, 8)
        self.assertNotEqual(self.angrygame.die_b.value, 8)

    def test_input_a(self):
        self.angrygame.die_a.value = 8

        self.angrygame.roll("a")

        self.assertNotEqual(self.angrygame.die_a.value, 8)
        self.assertNotEqual(self.angrygame.die_b.value, 8)

    def test_input_b(self):
        self.angrygame.die_b.value = 8

        self.angrygame.roll("b")

        self.assertNotEqual(self.angrygame.die_a.value, 8)
        self.assertNotEqual(self.angrygame.die_b.value, 8)

    def test_input_b_and_a(self):
        self.angrygame.die_a.value = 8
        self.angrygame.die_b.value = 8

        self.angrygame.roll("ba")

        self.assertNotEqual(self.angrygame.die_a.value, 8)
        self.assertNotEqual(self.angrygame.die_b.value, 8)

    def test_input_nothing(self):
        self.angrygame.die_a.value = 8
        self.angrygame.die_b.value = 8

        self.angrygame.roll("")

        self.assertEqual(self.angrygame.die_a.value, 8)
        self.assertEqual(self.angrygame.die_b.value, 8)

    def test_input_gibberish(self):
        self.angrygame.die_a.value = 8
        self.angrygame.die_b.value = 8

        self.angrygame.roll("wtf")

        self.assertEqual(self.angrygame.die_a.value, 8)
        self.assertEqual(self.angrygame.die_b.value, 8)

    def test_input_gibberish_with_die_a(self):
        self.angrygame.die_a.value = 8
        self.angrygame.die_b.value = 8

        self.angrygame.roll("watf")

        self.assertNotEqual(self.angrygame.die_a.value, 8)
        self.assertEqual(self.angrygame.die_b.value, 8)
Esempio n. 15
0
class Angrydice_check_stage_Three_test(unittest.TestCase):

    def setUp(self):
        self.angrygame = AngryDiceGame()

    def tearDown(self):
        del self.angrygame

    @patch('sys.stdout', new_callable=StringIO)
    def test_die_a_is_five_and_die_b_is_six(self, mock_stdout):
        self.angrygame.die_a.currentValue = "5"
        self.angrygame.die_a.value = 5
        self.angrygame.die_b.currentValue = "6"
        self.angrygame.die_b.value = 6
        self.angrygame.current_stage = 3

        self.cheating = False



        roll_dice_text = """You rolled:
                a = [  {}  ]
                b = [  {}  ]

                You are in Stage {}\n
You've won! Calm down!\n""".format(self.angrygame.die_a.currentValue, self.angrygame.die_b.currentValue, self.angrygame.current_stage)



        self.angrygame.stage_Three()

        self.assertEqual(self.angrygame.current_stage, 4)
        self.assertEqual(mock_stdout.getvalue(), roll_dice_text)

    @patch('sys.stdout', new_callable=StringIO)
    def test_die_a_is_six_and_die_b_is_five(self,mock_stdout):
        self.angrygame.die_a.currentValue = "6"
        self.angrygame.die_a.value = 6
        self.angrygame.die_b.currentValue = "5"
        self.angrygame.die_b.value = 5
        self.angrygame.current_stage = 3

        self.cheating = False

        roll_dice_text = """You rolled:
                a = [  {}  ]
                b = [  {}  ]


You've won! Calm down!\n""".format(self.angrygame.die_a.currentValue, self.angrygame.die_b.currentValue, self.angrygame.current_stage)



        self.angrygame.stage_Three()

        self.assertEqual(self.angrygame.current_stage, 4)
        self.assertEqual(mock_stdout.getvalue(), roll_dice_text)

    def test_die_a_is_five_and_die_b_not_valid(self):
        self.angrygame.die_a.currentValue = "5"
        self.angrygame.die_a.value = 5
        self.angrygame.die_b.currentValue = "6"
        self.angrygame.die_b.value = 6
        self.angrygame.current_stage = 3

        self.cheating = True

        self.angrygame.stage_Three()

        self.assertNotEqual(self.angrygame.current_stage, 3)

    def test_die_b_is_five_and_die_a_not_valid(self):
        self.angrygame.die_a.currentValue = "6"
        self.angrygame.die_a.value = 6
        self.angrygame.die_b.currentValue = "5"
        self.angrygame.die_b.value = 5
        self.angrygame.current_stage = 3

        self.cheating = True

        self.angrygame.stage_Three()

        self.assertNotEqual(self.angrygame.current_stage, 3)

    def test_die_a_and_die_b_not_valid_values(self):
        self.angrygame.die_a.currentValue = "6"
        self.angrygame.die_a.value = 6
        self.angrygame.die_b.currentValue = "6"
        self.angrygame.die_b.value = 6
        self.angrygame.current_stage = 3

        self.cheating = True

        self.angrygame.stage_Three()

        self.assertEqual(self.angrygame.current_stage, 3)