mirror of
https://github.com/django-components/django-components.git
synced 2025-08-03 22:08:17 +00:00
Contain all registry logic in helper methods.
This commit is contained in:
parent
ecba6e3ed9
commit
b2726a6832
4 changed files with 22 additions and 8 deletions
|
@ -13,7 +13,7 @@ class ComponentRegistryTest(unittest.TestCase):
|
|||
def test_simple_register(self):
|
||||
self.registry.register(name="testcomponent", component=MockComponent)
|
||||
self.assertEqual(
|
||||
self.registry._registry,
|
||||
self.registry.all(),
|
||||
{"testcomponent": MockComponent}
|
||||
)
|
||||
|
||||
|
@ -21,8 +21,11 @@ class ComponentRegistryTest(unittest.TestCase):
|
|||
self.registry.register(name="testcomponent", component=MockComponent)
|
||||
self.registry.register(name="testcomponent2", component=MockComponent)
|
||||
self.assertEqual(
|
||||
self.registry._registry,
|
||||
{"testcomponent": MockComponent, "testcomponent2": MockComponent}
|
||||
self.registry.all(),
|
||||
{
|
||||
"testcomponent": MockComponent,
|
||||
"testcomponent2": MockComponent,
|
||||
}
|
||||
)
|
||||
|
||||
def test_prevent_registering_twice(self):
|
||||
|
@ -33,7 +36,7 @@ class ComponentRegistryTest(unittest.TestCase):
|
|||
def test_simple_unregister(self):
|
||||
self.registry.register(name="testcomponent", component=MockComponent)
|
||||
self.registry.unregister(name="testcomponent")
|
||||
self.assertEqual(self.registry._registry, {})
|
||||
self.assertEqual(self.registry.all(), {})
|
||||
|
||||
def test_raises_on_failed_unregister(self):
|
||||
with self.assertRaises(component.NotRegistered):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue