]> git.decadent.org.uk Git - dak.git/blob - tests/dbtest_extract_component_from_section.py
Merge remote-tracking branch 'jcristau/formatone-no-tar-sig'
[dak.git] / tests / dbtest_extract_component_from_section.py
1 #!/usr/bin/env python
2
3 from db_test import DBDakTestCase
4
5 import unittest
6
7 from daklib.utils import extract_component_from_section
8
9 class ExtractComponentTestCase(DBDakTestCase):
10     """
11     prefix: non-US
12     component: main, contrib, non-free
13     section: games, admin, libs, [...]
14
15     [1] Order is as above.
16     [2] Prefix is optional for the default archive, but mandatory when
17         uploads are going anywhere else.
18     [3] Default component is main and may be omitted.
19     [4] Section is optional.
20     [5] Prefix is case insensitive
21     [6] Everything else is case sensitive.
22     """
23
24     def assertExtract(self, input, output):
25         self.setup_components()
26         self.assertEqual(
27             extract_component_from_section(input, self.session)[1],
28             output,
29         )
30
31     def test_1(self):
32         # Validate #3
33         self.assertExtract('utils', 'main')
34
35     def test_2(self):
36         # Err, whoops?  should probably be 'utils', 'main'...
37         self.assertExtract('main/utils', 'main')
38
39     def test_3(self):
40         self.assertExtract('non-free/libs', 'non-free')
41
42     def test_4(self):
43         self.assertExtract('contrib/net', 'contrib')
44
45     def test_5(self):
46         # Validate #4
47         self.assertExtract('main', 'main')
48
49     def test_6(self):
50         self.assertExtract('contrib', 'contrib')
51
52     def test_7(self):
53         self.assertExtract('non-free', 'non-free')
54
55     def test_8(self):
56         # Validate #6 (section)
57         self.assertExtract('utIls', 'main')
58
59 if __name__ == '__main__':
60     unittest.main()