def test_deserialize(self, patching, Model): django_apps = patching('thorn.django.utils.apps') assert (deserialize_model(serialize_model(Model)) is django_apps.get_model.return_value) django_apps.get_model.assert_called_with( Model._meta.app_label, Model._meta.model_name, )
def test_dispatch(self): self.dispatch( self.instance, pk_set={31, 123}, model=self.related_model, ) self.fun.assert_called_with(self.instance, context={ 'instance': self.instance.pk, 'model': serialize_model(self.related_model), 'pk_set': [31, 123], })
def test_deserialize(self, django_apps): self.assertIs( deserialize_model(serialize_model(self.Model)), django_apps.get_model.return_value, ) django_apps.get_model.assert_called_with( self.Model._meta.app_label, self.Model._meta.model_name, )
def test_dispatch(self, Dispatcher): dispatch = Dispatcher(self.fun, *self.dispatcher_args) self.instance = Mock(name='instance') dispatch( self.instance, pk_set={31, 123}, model=self.related_model, ) self.fun.assert_called_with(self.instance, context={ 'instance': self.instance.pk, 'model': serialize_model(self.related_model), 'pk_set': [31, 123], })
def test_deserialize__functional_from_instance(self): instance = Article(title='foo') assert deserialize_model(serialize_model(instance)) == Article
def test_deserialize__functional_from_class(self): assert deserialize_model(serialize_model(Article)) == Article
def test_serialize(self, Model): assert serialize_model(Model) == { 'app_label': Model._meta.app_label, 'model_name': Model._meta.model_name, }
def test_deserialize__functional_from_instance(self): instance = Article(title='foo') self.assertIs(deserialize_model(serialize_model(instance)), Article)
def test_deserialize__functional_from_class(self): self.assertIs(deserialize_model(serialize_model(Article)), Article)
def test_serialize(self): self.assertDictEqual(serialize_model(self.Model), { 'app_label': self.Model._meta.app_label, 'model_name': self.Model._meta.model_name, })