def test_create_character_with_positive_integer(self, mock_input): """Test create_character function the length of name with positive integer. The result is expected the name is two times of argument """ new_character = dungeonsanddragons.create_character(2) self.assertTrue(len(new_character['Name']) == 4)
def test_create_character_order(self, mock_input): """Test create_character function if the key is stored in order properly. The result is expected True """ my_keys = [ 'Name', 'Class', 'Hp', 'Strength', 'Dexterity', 'Constitution', 'Intelligence', 'Wisdom', 'Charisma', 'Xp', 'Inventory' ] mock_value = [i for i in range(0, len(my_keys))] mock_dict = dict(zip(my_keys, mock_value)) my_character = dungeonsanddragons.create_character(3) for i in range(0, len(my_keys)): self.assertEqual(mock_dict.keys(), my_character.keys())
def test_attack(self, mock_class, mock_race): char_one = create_character(4) char_two = create_character(4) actual_value = attack(char_one, char_two)
def test_create_character_length(self, mock_input): actual_value = create_character(10) self.assertTrue(len(actual_value) == 12)
def test_create_character_empty_inventory(self, mock_input): actual_value = create_character(10) inventory = actual_value['Inventory'] expected_value = [] self.assertEqual(inventory, expected_value)
def test_create_character_attributes(self, mock_input): attributes = ['Name', 'Race', 'Class', 'HP', 'Strength', 'Dexterity', 'Constitution', 'Intelligence', 'Wisdom', 'Charisma', 'XP', 'Inventory'] actual_value = create_character(10) for key in range(0, len(attributes)): self.assertTrue(attributes[key] in actual_value)
def test_create_character(self, mock_class): self.assertIsNone(dungeonsanddragons.create_character(0)) # Tests that 0 syllables returns None
def test_create_character4(self, mock_class): random.seed(2) self.assertEqual({'Name': 'Cadi', 'Class': 'blood hunter', 'Health': 7,'Strength': 8, 'Dexterity': 12, 'Constitution': 11, 'Intelligence': 9, 'Wisdom': 4, 'Charisma': 8, 'XP': 0, 'Inventory': []} , dungeonsanddragons.create_character(2)) random.seed() # Tests output for random creation of character
def test_create_character3(self, mock_class): self.assertEqual(11, len(dungeonsanddragons.create_character(5))) # Tests that length of output equals 10
def test_create_character2(self, mock_class): self.assertEqual(dict, type(dungeonsanddragons.create_character(4))) # Tests that output is of type list
def test_create_character_length_dictionary(self, mock_input): """Test create_character function if the output has correct number of keys and values. The result is expected True """ self.assertTrue(len(dungeonsanddragons.create_character(3)) == 11)
def test_create_character_with_zero(self, mock_input): """Test create_character function if it returns None when argument is zero. The result is expected True """ self.assertIsNone(dungeonsanddragons.create_character(0))
def test_create_character_with_negative_integer(self, mock_input): """Test create_character function if it returns None when argument is a negative integer. The result is expected True """ self.assertIsNone(dungeonsanddragons.create_character(-1))
def test_create_character_type(self, mock_input): """Test create_character function if type of output is dictionary. The result is expected True """ self.assertTrue(type(dungeonsanddragons.create_character(3)) == dict)