]> git.decadent.org.uk Git - dak.git/blob - tests/test_extract_component_from_section.py
Update pickle file for DB tests.
[dak.git] / tests / test_extract_component_from_section.py
1 #!/usr/bin/env python
2
3 from base_test import DakTestCase
4
5 import unittest
6
7 from daklib.utils import extract_component_from_section
8
9 class ExtractComponentTestCase(DakTestCase):
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.assertEqual(
26             extract_component_from_section(input)[1],
27             output,
28         )
29
30     def test_1(self):
31         # Validate #3
32         self.assertExtract('utils', 'main')
33
34     def test_2(self):
35         # Err, whoops?  should probably be 'utils', 'main'...
36         self.assertExtract('main/utils', 'main')
37
38     def test_3(self):
39         self.assertExtract('non-free/libs', 'non-free')
40
41     def test_4(self):
42         self.assertExtract('contrib/net', 'contrib')
43
44     def test_5(self):
45         # Validate #4
46         self.assertExtract('main', 'main')
47
48     def test_6(self):
49         self.assertExtract('contrib', 'contrib')
50
51     def test_7(self):
52         self.assertExtract('non-free', 'non-free')
53
54     def test_8(self):
55         # Validate #6 (section)
56         self.assertExtract('utIls', 'main')
57
58 if __name__ == '__main__':
59     unittest.main()