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, \
9 from sqlalchemy.exc import FlushError, IntegrityError
12 class ContentsTestCase(DBDakTestCase):
14 This TestCase checks the behaviour of contents generation.
17 def test_duplicates1(self):
19 Test the BinContents class for duplication problems.
22 contents1 = BinContents(file = 'usr/bin/hello', \
23 binary = self.binary['hello_2.2-1_i386'])
24 self.session.add(contents1)
27 contents2 = BinContents(file = 'usr/bin/hello', \
28 binary = self.binary['hello_2.2-1_i386'])
29 self.session.add(contents2)
30 self.assertRaises(FlushError, self.session.flush)
32 def test_duplicates2(self):
34 Test the BinContents class for more duplication problems.
37 contents1 = BinContents(file = 'usr/bin/hello', \
38 binary = self.binary['hello_2.2-1_i386'])
39 self.session.add(contents1)
40 contents2 = BinContents(file = 'usr/bin/gruezi', \
41 binary = self.binary['hello_2.2-1_i386'])
42 self.session.add(contents2)
45 contents2.file = 'usr/bin/hello'
46 self.assertRaises(IntegrityError, self.session.flush)
48 def test_duplicates3(self):
50 Test the BinContents class even more.
53 contents1 = BinContents(file = 'usr/bin/hello', \
54 binary = self.binary['hello_2.2-1_i386'])
55 self.session.add(contents1)
56 # same file in different binary packages should be okay
57 contents2 = BinContents(file = 'usr/bin/hello', \
58 binary = self.binary['gnome-hello_2.2-1_i386'])
59 self.session.add(contents2)
62 def test_overridetype(self):
64 Test the OverrideType class.
66 self.setup_overridetypes()
67 self.assertEqual('deb', self.otype['deb'].overridetype)
68 self.assertEqual(0, self.otype['deb'].overrides.count())
69 self.assertEqual(self.otype['deb'], get_override_type('deb', self.session))
71 def test_section(self):
76 self.assertEqual('python', self.section['python'].section)
77 self.assertEqual('python', self.section['python'])
78 self.assertTrue(self.section['python'] != 'java')
79 self.assertEqual(self.section['python'], get_section('python', self.session))
80 all_sections = get_sections(self.session)
81 self.assertEqual(self.section['python'].section_id, all_sections['python'])
82 self.assertEqual(0, self.section['python'].overrides.count())
84 def test_priority(self):
88 self.setup_priorities()
89 self.assertEqual('standard', self.prio['standard'].priority)
90 self.assertEqual(7, self.prio['standard'].level)
91 self.assertEqual('standard', self.prio['standard'])
92 self.assertTrue(self.prio['standard'] != 'extra')
93 self.assertEqual(self.prio['standard'], get_priority('standard', self.session))
94 all_priorities = get_priorities(self.session)
95 self.assertEqual(self.prio['standard'].priority_id, all_priorities['standard'])
96 self.assertEqual(0, self.prio['standard'].overrides.count())
98 def test_override(self):
102 self.setup_overrides()
103 list = get_override('hello', session = self.session)
104 self.assertEqual(3, len(list))
105 self.assertTrue(self.override['hello_sid_main_udeb'] in list)
106 self.assertTrue(self.override['hello_squeeze_main_deb'] in list)
107 list = get_override('hello', suite = 'sid', session = self.session)
108 self.assertEqual([self.override['hello_sid_main_udeb']], list)
109 list = get_override('hello', suite = ['sid'], session = self.session)
110 self.assertEqual([self.override['hello_sid_main_udeb']], list)
111 list = get_override('hello', component = 'contrib', session = self.session)
112 self.assertEqual([self.override['hello_lenny_contrib_deb']], list)
113 list = get_override('hello', component = ['contrib'], session = self.session)
114 self.assertEqual([self.override['hello_lenny_contrib_deb']], list)
115 list = get_override('hello', overridetype = 'deb', session = self.session)
116 self.assertEqual(2, len(list))
117 self.assertTrue(self.override['hello_sid_main_udeb'] not in list)
118 self.assertTrue(self.override['hello_squeeze_main_deb'] in list)
119 list = get_override('hello', overridetype = ['deb'], session = self.session)
120 self.assertEqual(2, len(list))
121 self.assertTrue(self.override['hello_sid_main_udeb'] not in list)
122 self.assertTrue(self.override['hello_squeeze_main_deb'] in list)
124 self.assertEqual(self.override['hello_sid_main_udeb'], \
125 self.suite['sid'].overrides.one())
126 self.assertEqual(2, self.comp['main'].overrides.count())
127 self.assertEqual(self.override['hello_sid_main_udeb'], \
128 self.comp['main'].overrides.filter_by(suite = self.suite['sid']).one())
129 self.assertEqual(self.override['hello_sid_main_udeb'], \
130 self.otype['udeb'].overrides.one())
132 if __name__ == '__main__':