diff options
author | Scott Moser <smoser@ubuntu.com> | 2015-07-28 16:15:10 -0400 |
---|---|---|
committer | Scott Moser <smoser@ubuntu.com> | 2015-07-28 16:15:10 -0400 |
commit | c33b3becebfa7bf3f6e2ee67ea7bc3def6feeb8c (patch) | |
tree | 19a41d3160b3536e212342154f3c10e0f35c62ec /tests/unittests/test_registry.py | |
parent | 55472eb02eaa5b88676a96e006f6838020f8ffe3 (diff) | |
download | vyos-cloud-init-c33b3becebfa7bf3f6e2ee67ea7bc3def6feeb8c.tar.gz vyos-cloud-init-c33b3becebfa7bf3f6e2ee67ea7bc3def6feeb8c.zip |
pull from 2.0 trunk @ a433358bbcf4e8a771b80cae34468409ed5a811d
Diffstat (limited to 'tests/unittests/test_registry.py')
-rw-r--r-- | tests/unittests/test_registry.py | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/tests/unittests/test_registry.py b/tests/unittests/test_registry.py new file mode 100644 index 00000000..bcf01475 --- /dev/null +++ b/tests/unittests/test_registry.py @@ -0,0 +1,28 @@ +from cloudinit.registry import DictRegistry + +from .helpers import (mock, TestCase) + + +class TestDictRegistry(TestCase): + + def test_added_item_included_in_output(self): + registry = DictRegistry() + item_key, item_to_register = 'test_key', mock.Mock() + registry.register_item(item_key, item_to_register) + self.assertEqual({item_key: item_to_register}, + registry.registered_items) + + def test_registry_starts_out_empty(self): + self.assertEqual({}, DictRegistry().registered_items) + + def test_modifying_registered_items_isnt_exposed_to_other_callers(self): + registry = DictRegistry() + registry.registered_items['test_item'] = mock.Mock() + self.assertEqual({}, registry.registered_items) + + def test_keys_cannot_be_replaced(self): + registry = DictRegistry() + item_key = 'test_key' + registry.register_item(item_key, mock.Mock()) + self.assertRaises(ValueError, + registry.register_item, item_key, mock.Mock()) |