def test_register_ok(self): registry = CacheRegistry() registry.register(TestSerializer) expected_registry = { TestModel: [TestSerializer], } self.assertEqual(registry._registry, expected_registry)
def setUp(self): self.registry = CacheRegistry() self.registry.register(TestCachedSerializer) self.registry.register(TestCachedSerializer2) self.instance = instance = TestModel() instance.id = 1000 instance.save() self.serializer = TestCachedSerializer(instance) self.key = self.registry.get_cache_key(self.instance, TestCachedSerializer) self.expected_data = {"id": 1000, "name": ""}
def setUp(self): self.registry = CacheRegistry() self.registry.register(TestSerializer) self.registry.register(TestSerializer2)
def test_alread_registered(self): registry = CacheRegistry() registry.register(TestSerializer) with self.assertRaises(AlreadyRegistered): registry.register(TestSerializer)
def test_empty_registry(self): registry = CacheRegistry() self.assertEqual(registry._registry, {})