def test_callback_not_called_on_reverse_add_without_watch(self):
     new_instance = ProjectFactory()
     add_instance = ArticleFactory()
     new_instance.article = add_instance
     new_instance.save()
     # have not watched, thus callback should not be called
     self.assertFalse(self.callback.called)
Example #2
0
 def test_callback_not_called_on_reverse_add_without_watch(self):
     new_instance = ProjectFactory()
     add_instance = ArticleFactory()
     new_instance.article = add_instance
     new_instance.save()
     # have not watched, thus callback should not be called
     self.assertFalse(self.callback.called)
 def test_callback_called_on_reverse_add_with_watch(self):
     new_instance = ProjectFactory()
     add_instance = ArticleFactory()
     self.watcher.watch()
     new_instance.article = add_instance
     new_instance.save()
     # callback should be called with instance modification
     self.callback.assert_called_once_with(
         obj=add_instance, attr=self.attr, sender=self.watcher)
Example #4
0
 def test_callback_called_on_reverse_add_with_watch(self):
     new_instance = ProjectFactory()
     add_instance = ArticleFactory()
     self.watcher.watch()
     new_instance.article = add_instance
     new_instance.save()
     # callback should be called with instance modification
     self.callback.assert_called_once_with(obj=add_instance,
                                           attr=self.attr,
                                           sender=self.watcher)
Example #5
0
 def setUp(self):
     self.projects = (
         ProjectFactory(),
         ProjectFactory(),
         ProjectFactory(),
         ProjectFactory(),
         ProjectFactory(),
     )
     self.model = Article
     self.attr = 'projects'
     self.callback = MagicMock()
     self.watcher = ManyRelatedWatcher(self.model, self.attr, self.callback)
     self.addCleanup(self.watcher.unwatch)
Example #6
0
 def test_callback_called_on_add_with_watch(self):
     new_instance = ArticleFactory(projects=self.projects)
     self.watcher.watch()
     new_instance.projects.add(ProjectFactory())
     # callback should be called with instance modification
     self.callback.assert_called_once_with(obj=new_instance,
                                           attr=self.attr,
                                           sender=self.watcher)
Example #7
0
 def test_callback_not_called_on_add_without_watch(self):
     new_instance = ArticleFactory(projects=self.projects)
     new_instance.projects.add(ProjectFactory())
     # have not watched, thus callback should not be called
     self.assertFalse(self.callback.called)