def test_validate_keys_unknown_log_keys_only(self):
     with mock.patch('staticconf.config.log') as mock_log:
         self.namespace.validate_keys(
             self.config_data,
             False,
             log_keys_only=True,
         )
         assert_equal(len(mock_log.info.mock_calls), 1)
         log_msg = mock_log.info.call_args[0][0]
         unknown = config.remove_by_keys(
             self.config_data,
             self.namespace.get_known_keys(),
         )
         for k, v in unknown:
             # Have to cast to strings here, since log_msg is a string
             key_string, val_string = str(k), str(v)
             assert key_string in log_msg
             assert val_string not in log_msg
Beispiel #2
0
 def test_validate_keys_unknown_log_keys_only(self):
     with mock.patch('staticconf.config.log') as mock_log:
         self.namespace.validate_keys(
             self.config_data,
             False,
             log_keys_only=True,
         )
         assert_equal(len(mock_log.info.mock_calls), 1)
         log_msg = mock_log.info.call_args[0][0]
         unknown = config.remove_by_keys(
             self.config_data,
             self.namespace.get_known_keys(),
         )
         for k, v in unknown:
             # Have to cast to strings here, since log_msg is a string
             key_string, val_string = str(k), str(v)
             assert key_string in log_msg
             assert val_string not in log_msg
 def test_overlap(self):
     keys = [1, 3, 5, 7]
     map = dict(enumerate(range(8)))
     expected = [(0, 0), (2, 2), (4, 4), (6, 6)]
     assert_equal(expected, config.remove_by_keys(map, keys))
 def test_no_keys(self):
     keys = []
     map = dict(enumerate(range(3)))
     assert_equal(map.items(), config.remove_by_keys(map, keys))
 def test_empty_dict(self):
     keys = range(3)
     assert_equal([], config.remove_by_keys({}, keys))
 def test_overlap(self):
     keys = [1, 3, 5 ,7]
     map = dict(enumerate(range(8)))
     expected = [(0,0), (2, 2), (4, 4), (6, 6)]
     assert_equal(expected, config.remove_by_keys(map, keys))
 def test_no_keys(self):
     keys = []
     map = dict(enumerate(range(3)))
     assert_equal(map.items(), config.remove_by_keys(map, keys))
 def test_empty_dict(self):
     keys = range(3)
     assert_equal([], config.remove_by_keys({}, keys))