| Total Complexity | 5 |
| Total Lines | 40 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | from pathlib import Path |
||
| 2 | from unittest import TestCase |
||
| 3 | |||
| 4 | from barentsz._discover import discover_packages |
||
| 5 | |||
| 6 | |||
| 7 | class TestDiscoverPackages(TestCase): |
||
| 8 | |||
| 9 | def test_discover_packages(self): |
||
| 10 | # SETUP |
||
| 11 | path_to_resources = (Path(__file__).parent.parent / 'test_resources' |
||
| 12 | / 'examples_for_tests') |
||
| 13 | expected_package0 = 'examples_for_tests' |
||
| 14 | expected_package1 = 'examples_for_tests.level2' |
||
| 15 | |||
| 16 | # EXECUTE |
||
| 17 | packages = discover_packages(path_to_resources) |
||
| 18 | |||
| 19 | # VERIFY |
||
| 20 | self.assertEqual(2, len(packages)) |
||
| 21 | self.assertIn(expected_package0, packages) |
||
| 22 | self.assertIn(expected_package1, packages) |
||
| 23 | |||
| 24 | def test_discover_packages_with_dir_thats_no_package(self): |
||
| 25 | # SETUP |
||
| 26 | path_to_resources = (Path(__file__).parent.parent / 'test_resources' |
||
| 27 | / 'examples_for_tests' / 'not_a_package') |
||
| 28 | |||
| 29 | # EXECUTE & VERIFY |
||
| 30 | with self.assertRaises(ValueError): |
||
| 31 | discover_packages(path_to_resources) |
||
| 32 | |||
| 33 | def test_discover_packages_with_dir_thats_doesnt_exist(self): |
||
| 34 | # SETUP |
||
| 35 | path_to_resources = (Path(__file__).parent.parent / 'test_resources' |
||
| 36 | / 'examples_for_tests' / 'does_not_exist') |
||
| 37 | # EXECUTE & VERIFY |
||
| 38 | with self.assertRaises(ValueError): |
||
| 39 | discover_packages(path_to_resources) |
||
| 40 |