def test_RepoUpdate_NotFound(self): repo = InMemoryRepository() class TestModel(Model): def __init__(self): self.verified = False super().__init__() model = TestModel() repo.add(model) self.assertIsNone(model.updated_at) self.assertFalse(model.verified) newModel = Model() affectedRows = repo.update(newModel) self.assertEqual(0, affectedRows) notUpdatedModel = repo.getById(model.id) self.assertIsNone(notUpdatedModel.updated_at) self.assertFalse(notUpdatedModel.verified)
def test_RepoUpdate_ok(self): repo = InMemoryRepository() class TestModel(Model): def __init__(self): self.verified = False super().__init__() model = TestModel() repo.add(model) self.assertIsNone(model.updated_at) self.assertFalse(model.verified) model.verified = True affectedRows = repo.update(model) self.assertEqual(1, affectedRows) updatedModel = repo.getById(model.id) self.assertIsNotNone(updatedModel.updated_at) self.assertTrue(updatedModel.verified)