Example #1
0
 def test_value_of_first_key_is_returned(self):
     test_dict = {'a': 1, 'b': 2}
     test_list = ['b', 'a']
     result = get_first_from_list_or_default(test_dict, test_list)
     self.assertEqual(2, result)
Example #2
0
 def test_default_value_is_returned_for_empty_list(self):
     test_dict = {'a': 1, 'b': 2}
     test_list = []
     result = get_first_from_list_or_default(test_dict, test_list, 10)
     self.assertEqual(10, result)
Example #3
0
 def test_value_is_returned_when_only_the_last_key_is_present_in_the_dict(
         self):
     test_dict = {'a': 1, 'b': 2, 'c': 3}
     test_list = ['d', 'e', 'c']
     result = get_first_from_list_or_default(test_dict, test_list)
     self.assertEqual(3, result)
Example #4
0
 def test_default_value_is_returned_when_no_keys_from_list_are_present_in_the_dict(
         self):
     test_dict = {'a': 1, 'b': 2}
     test_list = ['c', 'd']
     result = get_first_from_list_or_default(test_dict, test_list, 10)
     self.assertEqual(10, result)