]> git.decadent.org.uk Git - dak.git/blob - tests/dbtest_validation.py
dak rm: read binary metadata from db
[dak.git] / tests / dbtest_validation.py
1 #!/usr/bin/env python
2
3 from db_test import DBDakTestCase
4
5 from daklib.dbconn import Architecture
6 from daklib.dak_exceptions import DBUpdateError
7
8 import unittest
9
10 class ValidatorTestCase(DBDakTestCase):
11     """
12     The ValidatorTestCase tests the validation mechanism.
13     """
14
15     def test_validation(self):
16         'tests validate()'
17
18         # before_insert validation should fail
19         architecture = Architecture()
20         self.session.add(architecture)
21         self.assertRaises(DBUpdateError, self.session.flush)
22         self.session.rollback()
23         # should not fail
24         architecture = Architecture('i386')
25         self.session.add(architecture)
26         self.session.flush()
27         # before_update validation should fail
28         architecture.arch_string = None
29         self.assertRaises(DBUpdateError, self.session.flush)
30         self.session.rollback()
31
32 if __name__ == '__main__':
33     unittest.main()