dbtest_extract_component_from_section.py 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. #!/usr/bin/env python
  2. from db_test import DBDakTestCase
  3. import unittest
  4. from daklib.utils import extract_component_from_section
  5. class ExtractComponentTestCase(DBDakTestCase):
  6. """
  7. prefix: non-US
  8. component: main, contrib, non-free
  9. section: games, admin, libs, [...]
  10. [1] Order is as above.
  11. [2] Prefix is optional for the default archive, but mandatory when
  12. uploads are going anywhere else.
  13. [3] Default component is main and may be omitted.
  14. [4] Section is optional.
  15. [5] Prefix is case insensitive
  16. [6] Everything else is case sensitive.
  17. """
  18. def assertExtract(self, input, output):
  19. self.setup_components()
  20. self.assertEqual(
  21. extract_component_from_section(input, self.session)[1],
  22. output,
  23. )
  24. def test_1(self):
  25. # Validate #3
  26. self.assertExtract('utils', 'main')
  27. def test_2(self):
  28. # Err, whoops? should probably be 'utils', 'main'...
  29. self.assertExtract('main/utils', 'main')
  30. def test_3(self):
  31. self.assertExtract('non-free/libs', 'non-free')
  32. def test_4(self):
  33. self.assertExtract('contrib/net', 'contrib')
  34. def test_5(self):
  35. # Validate #4
  36. self.assertExtract('main', 'main')
  37. def test_6(self):
  38. self.assertExtract('contrib', 'contrib')
  39. def test_7(self):
  40. self.assertExtract('non-free', 'non-free')
  41. def test_8(self):
  42. # Validate #6 (section)
  43. self.assertExtract('utIls', 'main')
  44. if __name__ == '__main__':
  45. unittest.main()