3 from db_test import DBDakTestCase
5 from daklib.dbconn import DBConn, BinContents, OverrideType, get_override_type, \
6 Section, get_section, get_sections, Priority, get_priority, get_priorities
8 from sqlalchemy.exc import FlushError, IntegrityError
11 class ContentsTestCase(DBDakTestCase):
13 This TestCase checks the behaviour of contents generation.
16 def test_duplicates1(self):
18 Test the BinContents class for duplication problems.
21 contents1 = BinContents(file = 'usr/bin/hello', \
22 binary = self.binary['hello_2.2-1_i386'])
23 self.session.add(contents1)
26 contents2 = BinContents(file = 'usr/bin/hello', \
27 binary = self.binary['hello_2.2-1_i386'])
28 self.session.add(contents2)
29 self.assertRaises(FlushError, self.session.flush)
31 def test_duplicates2(self):
33 Test the BinContents class for more duplication problems.
36 contents1 = BinContents(file = 'usr/bin/hello', \
37 binary = self.binary['hello_2.2-1_i386'])
38 self.session.add(contents1)
39 contents2 = BinContents(file = 'usr/bin/gruezi', \
40 binary = self.binary['hello_2.2-1_i386'])
41 self.session.add(contents2)
44 contents2.file = 'usr/bin/hello'
45 self.assertRaises(IntegrityError, self.session.flush)
47 def test_duplicates3(self):
49 Test the BinContents class even more.
52 contents1 = BinContents(file = 'usr/bin/hello', \
53 binary = self.binary['hello_2.2-1_i386'])
54 self.session.add(contents1)
55 # same file in different binary packages should be okay
56 contents2 = BinContents(file = 'usr/bin/hello', \
57 binary = self.binary['gnome-hello_2.2-1_i386'])
58 self.session.add(contents2)
61 def test_overridetype(self):
63 Test the OverrideType class.
65 self.setup_overridetypes()
66 self.assertEqual('deb', self.otype['deb'].overridetype)
67 self.assertEqual(0, self.otype['deb'].overrides.count())
68 self.assertEqual(self.otype['deb'], get_override_type('deb', self.session))
70 def test_section(self):
75 self.assertEqual('python', self.section['python'].section)
76 self.assertEqual('python', self.section['python'])
77 self.assertTrue(self.section['python'] != 'java')
78 self.assertEqual(self.section['python'], get_section('python', self.session))
79 all_sections = get_sections(self.session)
80 self.assertEqual(self.section['python'].section_id, all_sections['python'])
81 self.assertEqual(0, self.section['python'].overrides.count())
83 def test_priority(self):
87 self.setup_priorities()
88 self.assertEqual('standard', self.prio['standard'].priority)
89 self.assertEqual(7, self.prio['standard'].level)
90 self.assertEqual('standard', self.prio['standard'])
91 self.assertTrue(self.prio['standard'] != 'extra')
92 self.assertEqual(self.prio['standard'], get_priority('standard', self.session))
93 all_priorities = get_priorities(self.session)
94 self.assertEqual(self.prio['standard'].priority_id, all_priorities['standard'])
95 self.assertEqual(0, self.prio['standard'].overrides.count())
97 if __name__ == '__main__':