def test_capitals(self): input = { "Israel": "Jerusalem", "Austria": "Vienna", "Palestine": "Jerusalem", "Sweden": "Stockholm" } self.assertEqual(s.reversed_dict(input)['Stockholm'], 'Sweden') self.assertEqual(s.reversed_dict(input)['Vienna'], 'Austria') self.assertIn('Jerusalem', s.reversed_dict(input))
def test_teams(self): input = {'Milan': 'Italy', 'Levski': 'Bulgaria', 'Borussia': 'Germany', 'Atletico': 'Spain', 'Arsenal': 'England', 'PSG': 'France'} output = {'Italy': 'Milan', 'Bulgaria': 'Levski', 'Germany': 'Borussia', 'Spain': 'Atletico', 'England': 'Arsenal', 'France': 'PSG'} self.assertEqual(s.reversed_dict(input), output)
def test_reversed_dict_repeating_values(self): answer = solution.reversed_dict( {'Nibbler': 3, 'Fillip': 2, 'Turanga': 1, 'Amy': 2}) self.assertEqual(answer[1], 'Turanga') self.assertTrue(answer[2] in ['Fillip', 'Amy']) self.assertEqual(answer[3], 'Nibbler') self.assertTrue(len(answer), 3)
def test_animals(self): input_ = {"cat": 2, "dog": 1, "monkey": 1, "gopher": 3} input_ = {'minh': 'cat', 'ivan': 'dog', 'jess': 'parrot', 'plamen': 'rabbit', 'stoqn': 'cat', 'dari': 'cat'} output = solution.reversed_dict(input_) self.assertEqual(output['dog'], 'ivan') self.assertEqual(output['rabbit'], 'plamen') self.assertEqual(output['parrot'], "jess") self.assertIn(output['cat'], ['minh', 'stoqn', 'dari'])
def test_fruits_menu(self): input_ = { ('apple', 'orange'): 'first', ('apple', 'cherry'): 'second', ('cherry', 'orange'): 'third' } output = { 'first': ('apple', 'orange'), 'second': ('apple', 'cherry'), 'third': ('cherry', 'orange') } self.assertEqual(s.reversed_dict(input_), output)
def setUp(self): self.data = { 'Sofia': 'Bulgaria', 'New York': 'USA', 'Berlin': 'Germany', 'London': 'Great Britain', 'Plovdiv': 'Bulgaria', 'Frankfurt': 'Germany', 'Washington': 'USA', 'Moscow': 'Russia' } self.expected = s.reversed_dict(self.data)
def test_sports(self): input = { 'Football': '1', 'Volleyball': '3', 'Basketball': '4', 'Tennis': '2', 'Soccer': 'wtf' } output = { '1': 'Football', '2': 'Tennis', '3': 'Volleyball', '4': 'Basketball', 'wtf': 'Soccer' } self.assertEqual(solution.reversed_dict(input), output)
def test_teams(self): input = { 'Milan': 'Italy', 'Levski': 'Bulgaria', 'Borussia': 'Germany', 'Atletico': 'Spain', 'Arsenal': 'England', 'PSG': 'France' } output = { 'Italy': 'Milan', 'Bulgaria': 'Levski', 'Germany': 'Borussia', 'Spain': 'Atletico', 'England': 'Arsenal', 'France': 'PSG' } self.assertEqual(solution.reversed_dict(input), output)
def test_teams(self): input = { "Milan": "Italy", "Levski": "Bulgaria", "Borussia": "Germany", "Atletico": "Spain", "Arsenal": "England", "PSG": "France", } output = { "Italy": "Milan", "Bulgaria": "Levski", "Germany": "Borussia", "Spain": "Atletico", "England": "Arsenal", "France": "PSG", } self.assertEqual(solution.reversed_dict(input), output)
def test_sports(self): input = {'Football': '1', 'Volleyball': '3', 'Basketball': '4', 'Tennis': '2', 'Soccer': 'wtf'} output = {'1': 'Football', '2': 'Tennis', '3': 'Volleyball', '4': 'Basketball', 'wtf': 'Soccer'} self.assertEqual(s.reversed_dict(input), output)
def test_animals(self): input_ = {"cat": 2, "dog": 1, "monkey": 1, "gopher": 3} output = s.reversed_dict(input_) self.assertEqual(output[2], "cat") self.assertEqual(output[3], "gopher") self.assertIn(1, output)
def test_food(self): input = {'Cake': '11', 'Rice': '312', 'Noodle': 'yuck!', 'Bread': '24', 'Eggs': '21', 'Cheese': 'yummy'} output = {'11': 'Cake', '21': 'Eggs', '312': 'Rice', 'yuck!': 'Noodle', '24': 'Bread', 'yummy': 'Cheese'} self.assertEqual(solution.reversed_dict(input), output)
def test_empty_dict(self): self.assertEqual({}, s.reversed_dict({}))
def test_reversed_dict_no_repeating_values(self): self.assertEqual( solution.reversed_dict({'Nibbler': 3, 'Fillip': 2, 'Turanga': 1}), {3: 'Nibbler', 2: 'Fillip', 1: 'Turanga'})
def test_fruits_menu(self): input_ = {('apple', 'orange'): 'first', ('apple', 'cherry'): 'second', ('cherry', 'orange'): 'third'} output = {'first': ('apple', 'orange'), 'second': ('apple', 'cherry'), 'third': ('cherry', 'orange')} self.assertEqual(s.reversed_dict(input_), output)
def test_sports(self): input = {"Football": "1", "Volleyball": "3", "Basketball": "4", "Tennis": "2", "Soccer": "wtf"} output = {"1": "Football", "2": "Tennis", "3": "Volleyball", "4": "Basketball", "wtf": "Soccer"} self.assertEqual(solution.reversed_dict(input), output)
def test_champions(self): input = {'adc': 'ashe', 'mid': 'veigar', 'top': 'fiora', 'support': 'braum', 'jungle': 'fizz'} output = {'ashe': 'adc', 'veigar': 'mid', 'fiora': 'top', 'braum': 'support', 'fizz': 'jungle'} self.assertEqual(solution.reversed_dict(input), output)
def test_reversed_dict_repeating_values_only(self): value = solution.reversed_dict({'Amy': 2, 'Zapp': 2, 'Kif': 2})[2] self.assertTrue(any(_ is value for _ in ['Amy', 'Zapp', 'Kif']))
def test_gender(self): result = solution.reversed_dict({'ivan': 'M', 'jodie': 'F', 'jack': 'M', 'jessy': 'F', 'bianca': 'F'}) self.assertIn('F', result.keys()) self.assertIn(result['M'], ['ivan', 'jack']) self.assertIn(result['F'], ['jessy', 'bianca', 'jodie'])
def test_with_duplicated_values(self): result = s.reversed_dict({'foo': 'bar', 'baz': 'bar', 'fizz': 'buzz'}) self.assertIn('bar', result.keys()) self.assertIn('buzz', result.keys()) self.assertIn('fizz', result.values()) self.assertIn(result['bar'], ['foo', 'baz'])
def test_empty(self): self.assertEqual({}, solution.reversed_dict({}))