Beispiel #1
0
    def test_find_path_nonexistent(self):
        graph = graph_module.DependencyGraph(self.PACKAGE)

        path = graph.find_path(upstream=Module('foo.four'),
                               downstream=Module('foo.one'))

        assert path is None
Beispiel #2
0
    def test_find_path_direct(self):
        graph = graph_module.DependencyGraph(self.PACKAGE)

        path = graph.find_path(upstream=Module('foo.one'),
                               downstream=Module('foo.two'))

        assert path == (Module('foo.two'), Module('foo.one'))
Beispiel #3
0
    def test_get_descendants_nested(self):

        graph = graph_module.DependencyGraph(self.PACKAGE)

        assert set(graph.get_descendants(Module('foo.one'))) == {
            Module('foo.one.alpha'),
            Module('foo.one.beta'),
            Module('foo.one.beta.green'),
        }
Beispiel #4
0
    def test_indirect_ignore_path_is_ignored(self):
        ignore_paths = (ImportPath(
            importer=Module('foo.three'),
            imported=Module('foo.two'),
        ), )
        graph = graph_module.DependencyGraph(self.PACKAGE)

        path = graph.find_path(upstream=Module('foo.one'),
                               downstream=Module('foo.four'),
                               ignore_paths=ignore_paths)

        assert path is None
Beispiel #5
0
    def test_contains(self):
        graph = graph_module.DependencyGraph(self.PACKAGE)

        assert Module('foo.one.alpha') in graph
        assert Module('foo.one.omega') not in graph
Beispiel #6
0
    def test_dependency_count(self):
        graph = graph_module.DependencyGraph(self.PACKAGE)

        # Should be number of ImportPaths returned by DependencyAnalyzer.determine_import_paths.
        assert graph.dependency_count == 3
Beispiel #7
0
    def test_module_count(self):
        graph = graph_module.DependencyGraph(self.PACKAGE)

        # Assert the module count is the number of modules returned by
        # PackageScanner.scan_for_modules.
        assert graph.module_count == 6
Beispiel #8
0
    def test_get_descendants_none(self):
        graph = graph_module.DependencyGraph(self.PACKAGE)

        assert graph.get_descendants(Module('foo.two')) == []