def test_config_store_deepcopy(self): config_store = ConfigValueStore() config_store.set_config_provider('foo', ConstantProvider('bar')) config_store_copy = copy.deepcopy(config_store) config_store_copy.set_config_provider('fizz', ConstantProvider('buzz')) assert config_store.get_config_variable('fizz') is None assert config_store_copy.get_config_variable('foo') == 'bar'
def test_can_set_config_provider(self): foo_value_provider = mock.Mock(spec=BaseProvider) foo_value_provider.provide.return_value = 'foo' provider = ConfigValueStore(mapping={ 'fake_variable': foo_value_provider, }) value = provider.get_config_variable('fake_variable') self.assertEqual(value, 'foo') bar_value_provider = mock.Mock(spec=BaseProvider) bar_value_provider.provide.return_value = 'bar' provider.set_config_provider('fake_variable', bar_value_provider) value = provider.get_config_variable('fake_variable') self.assertEqual(value, 'bar')
def test_can_set_config_provider(self): foo_value_provider = mock.Mock(spec=BaseProvider) foo_value_provider.provide.return_value = 'foo' provider = ConfigValueStore(mapping={ 'fake_variable': foo_value_provider, }) value = provider.get_config_variable('fake_variable') self.assertEqual(value, 'foo') bar_value_provider = mock.Mock(spec=BaseProvider) bar_value_provider.provide.return_value = 'bar' provider.set_config_provider('fake_variable', bar_value_provider) value = provider.get_config_variable('fake_variable') self.assertEqual(value, 'bar')