]> git.decadent.org.uk Git - dak.git/commitdiff
ValidatorTestCase: test before_update, too.
authorTorsten Werner <twerner@debian.org>
Mon, 24 Jan 2011 06:51:30 +0000 (07:51 +0100)
committerTorsten Werner <twerner@debian.org>
Mon, 24 Jan 2011 06:51:30 +0000 (07:51 +0100)
Signed-off-by: Torsten Werner <twerner@debian.org>
tests/dbtest_validation.py

index 597097c959a45db00b187772def698b52e87737a..32f47eb8fcd724fcc31d6c31abfb46ffeb987472 100755 (executable)
@@ -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()