def test_doesnt_insert_unsaved_object(self, backend): obj = models.Book(title="Test", publication_date=date(2017, 10, 18), number_of_pages=100) backend().reset_mock() index.insert_or_update_object(obj) self.assertFalse(backend().add.mock_calls)
def test_removes_unsaved_object(self, backend): obj = models.Book(title="Test", publication_date=date(2017, 10, 18), number_of_pages=100) backend().reset_mock() index.remove_object(obj) backend().delete.assert_called_with(obj)