Ejemplo n.º 1
0
 def create_build_use_case(self) -> BuildConfigurationUC:
     """
     Plumbing to make build use case working.
     """
     configuration_io = YamlConfigurationIO(self.args.output)
     code_parser = PythonParser()
     source_files = source_file_iterator(self.args.root_dir)
     return BuildConfigurationUC(configuration_io, code_parser, source_files)
Ejemplo n.º 2
0
 def create_build_use_case(self) -> BuildConfigurationUC:
     """
     Plumbing to make build use case working.
     """
     configuration_io = YamlConfigurationIO(self.args.output)
     code_parser = (PythonParser()
                    if self.args.lang in ["py", "python"] else GoParser())
     source_files = source_file_iterator(self.args.root_dir,
                                         self.args.lang[:2])
     return BuildConfigurationUC(configuration_io, code_parser,
                                 source_files, self.args.lang)
Ejemplo n.º 3
0
    def create_graph_use_case(self) -> DrawGraphUC:
        """
        Plumbing to make draw_graph use case working.
        """
        graph_conf = read_graph_config(self.args.config) if self.args.config else None

        code_parser = PythonParser()
        source_files = source_file_iterator(self.args.root_dir)
        graph = Graph(self.args.output, graph_conf)
        graph_drawer = GraphDrawer(graph)
        return DrawGraphUC(graph_drawer, code_parser, source_files, graph_conf)
Ejemplo n.º 4
0
 def create_check_use_case(self) -> CheckDependenciesUC:
     """
     Plumbing to make check use case working.
     """
     configuration = YamlConfigurationIO(self.args.config).read()
     code_parser = PythonParser()
     report_printer = ReportPrinter()
     source_files = source_file_iterator(self.args.root_dir)
     return CheckDependenciesUC(
         configuration, report_printer, code_parser, source_files
     )
Ejemplo n.º 5
0
    def create_graph_use_case(self) -> DrawGraphUC:
        """
        Plumbing to make draw_graph use case working.
        """
        graph_conf = read_graph_config(self.args.config) if self.args.config else None

        if self.args.lang:
            lang = self.args.lang
        elif graph_conf and "lang" in graph_conf:
            lang = graph_conf["lang"]
        else:
            lang = "python"

        code_parser = PythonParser() if lang in ["py", "python"] else GoParser()
        source_files = source_file_iterator(self.args.root_dir, lang[:2])
        graph = Graph(self.args.output, graph_conf)
        graph_drawer = GraphDrawer(graph)
        return DrawGraphUC(graph_drawer, code_parser, source_files, graph_conf)
Ejemplo n.º 6
0
"""
Test graph use case
"""
from typing import Iterator
from unittest.mock import Mock, patch

from dep_check.infra.io import Graph, GraphDrawer
from dep_check.infra.python_parser import PythonParser
from dep_check.models import Dependency, Module, SourceFile
from dep_check.use_cases.draw_graph import DrawGraphUC, _fold_dep

from .fakefile import GLOBAL_DEPENDENCIES, SIMPLE_FILE

PARSER = PythonParser()


def test_empty_source_files() -> None:
    """
    Test result with no source files given.
    """
    # Given
    source_files: Iterator[SourceFile] = iter([])
    drawer = Mock()
    use_case = DrawGraphUC(drawer, PARSER, source_files)

    # When
    use_case.run()

    # Then
    drawer.write.assert_called_with({})