Refactor the registry into a dictionary object

This commit is contained in:
Jeremy Stretch
2020-03-18 12:00:31 -04:00
parent 00afe7aa94
commit 043b1c28d2
3 changed files with 63 additions and 27 deletions

View File

@@ -0,0 +1,33 @@
from django.test import TestCase
from extras.registry import Registry
class RegistryTest(TestCase):
def test_add_store(self):
reg = Registry()
reg['foo'] = 123
self.assertEqual(reg['foo'], 123)
def test_manipulate_store(self):
reg = Registry()
reg['foo'] = [1, 2]
reg['foo'].append(3)
self.assertListEqual(reg['foo'], [1, 2, 3])
def test_overwrite_store(self):
reg = Registry()
reg['foo'] = 123
with self.assertRaises(Exception):
reg['foo'] = 456
def test_delete_store(self):
reg = Registry()
reg['foo'] = 123
with self.assertRaises(Exception):
del(reg['foo'])