示例#1
0
 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))
示例#2
0
 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)
示例#3
0
    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)
示例#4
0
 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'])
示例#5
0
 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)
示例#6
0
 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)
示例#7
0
 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)
示例#8
0
 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)
示例#9
0
 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)
示例#10
0
 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)
示例#11
0
 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)
示例#12
0
 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)
示例#13
0
 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)
示例#14
0
 def test_empty_dict(self):
     self.assertEqual({}, s.reversed_dict({}))
示例#15
0
 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'})
示例#16
0
 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)
示例#17
0
 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)
示例#18
0
 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)
示例#19
0
 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)
示例#20
0
 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']))
示例#21
0
 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'])
示例#22
0
 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'])
示例#23
0
 def test_empty(self):
     self.assertEqual({}, solution.reversed_dict({}))