Example #1
0
 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,
     )
Example #2
0
 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,
     )
Example #3
0
 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],
     })
Example #4
0
 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,
     )
Example #5
0
 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],
     })
Example #6
0
 def test_deserialize__functional_from_instance(self):
     instance = Article(title='foo')
     assert deserialize_model(serialize_model(instance)) == Article
Example #7
0
 def test_deserialize__functional_from_class(self):
     assert deserialize_model(serialize_model(Article)) == Article
Example #8
0
 def test_serialize(self, Model):
     assert serialize_model(Model) == {
         'app_label': Model._meta.app_label,
         'model_name': Model._meta.model_name,
     }
Example #9
0
 def test_deserialize__functional_from_instance(self):
     instance = Article(title='foo')
     self.assertIs(deserialize_model(serialize_model(instance)), Article)
Example #10
0
 def test_deserialize__functional_from_class(self):
     self.assertIs(deserialize_model(serialize_model(Article)), Article)
Example #11
0
 def test_serialize(self):
     self.assertDictEqual(serialize_model(self.Model), {
         'app_label': self.Model._meta.app_label,
         'model_name': self.Model._meta.model_name,
     })
Example #12
0
 def test_deserialize__functional_from_class(self):
     assert deserialize_model(serialize_model(Article)) == Article
Example #13
0
 def test_serialize(self, Model):
     assert serialize_model(Model) == {
         'app_label': Model._meta.app_label,
         'model_name': Model._meta.model_name,
     }