def test_client_not_invoked(self, mock_client): """ Call `comment_post_save()` with a comment that has not been modified, and assert that `client.set()` was not invoked. """ # Create a new public comment comment = self._create_comment() # Programatically set the `__pub_info` data on the comment (but DON'T CHANGE ANYTHING) setattr(comment, '__pub_info', { 'is_public': True, 'is_removed': False, }) # Pass this comment to the `comment_post_save()` signal handler listing_handlers.comment_post_save(comment) # Assert that the `set` method was NOT called tools.assert_false(mock_client.set.called)
def test_client_invoked(self, mock_client): """ Call `comment_post_save()` with a comment that has been modified, and assert that the client was not invoked. """ # Create a new public comment comment = self._create_comment() # Programatically set the `__pub_info` data on the comment setattr(comment, '__pub_info', { 'is_public': False, 'is_removed': True, }) # Pass this comment to the `comment_post_save()` signal handler listing_handlers.comment_post_save(comment) # Assert that that client.set() was called w/ the appropriate args mock_client.set.assert_called_with( self._build_publishable_comment_count_key(self.publishable), 1 )