3 from db_test import DBDakTestCase
5 from daklib.dbconn import DBConn, BinContents, OverrideType
7 from sqlalchemy.exc import FlushError, IntegrityError
10 class ContentsTestCase(DBDakTestCase):
12 This TestCase checks the behaviour of contents generation.
15 def test_duplicates1(self):
17 Test the BinContents class for duplication problems.
20 contents1 = BinContents(file = 'usr/bin/hello', \
21 binary = self.binary['hello_2.2-1_i386'])
22 self.session.add(contents1)
25 contents2 = BinContents(file = 'usr/bin/hello', \
26 binary = self.binary['hello_2.2-1_i386'])
27 self.session.add(contents2)
28 self.assertRaises(FlushError, self.session.flush)
30 def test_duplicates2(self):
32 Test the BinContents class for more duplication problems.
35 contents1 = BinContents(file = 'usr/bin/hello', \
36 binary = self.binary['hello_2.2-1_i386'])
37 self.session.add(contents1)
38 contents2 = BinContents(file = 'usr/bin/gruezi', \
39 binary = self.binary['hello_2.2-1_i386'])
40 self.session.add(contents2)
43 contents2.file = 'usr/bin/hello'
44 self.assertRaises(IntegrityError, self.session.flush)
46 def test_duplicates3(self):
48 Test the BinContents class even more.
51 contents1 = BinContents(file = 'usr/bin/hello', \
52 binary = self.binary['hello_2.2-1_i386'])
53 self.session.add(contents1)
54 # same file in different binary packages should be okay
55 contents2 = BinContents(file = 'usr/bin/hello', \
56 binary = self.binary['gnome-hello_2.2-1_i386'])
57 self.session.add(contents2)
60 def test_overridetype(self):
62 Test the OverrideType class.
64 debtype = OverrideType(overridetype = 'deb')
65 self.session.add(debtype)
67 self.assertEqual('deb', debtype.overridetype)
68 self.assertEqual(0, debtype.overrides.count())
70 if __name__ == '__main__':