From: Torsten Werner Date: Mon, 24 Jan 2011 06:51:30 +0000 (+0100) Subject: ValidatorTestCase: test before_update, too. X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5f8f5260c4403a438fba32735a689037fe982403;p=dak ValidatorTestCase: test before_update, too. Signed-off-by: Torsten Werner --- diff --git a/tests/dbtest_validation.py b/tests/dbtest_validation.py index 597097c9..32f47eb8 100755 --- a/tests/dbtest_validation.py +++ b/tests/dbtest_validation.py @@ -12,26 +12,22 @@ class ValidatorTestCase(DBDakTestCase): The ValidatorTestCase tests the validation mechanism. """ - def must_fail(self): - '''' - This function must fail with DBUpdateError because arch_string is not - set. It rolls back the transaction before re-raising the exception. - ''' - try: - architecture = Architecture() - self.session.add(architecture) - self.session.flush() - except: - self.session.rollback() - raise - def test_validation(self): 'tests validate()' - self.assertRaises(DBUpdateError, self.must_fail) + + # before_insert validation should fail + architecture = Architecture() + self.session.add(architecture) + self.assertRaises(DBUpdateError, self.session.flush) + self.session.rollback() # should not fail architecture = Architecture('i386') self.session.add(architecture) self.session.flush() + # before_update validation should fail + architecture.arch_string = '' + self.assertRaises(DBUpdateError, self.session.flush) + self.session.rollback() if __name__ == '__main__': unittest.main()