def generate_dependency_graph(self, event):
     assert isinstance(event, ContractSpecification.Created)
     contract_specification = self.contract_specification_repo[
         event.entity_id]
     generate_dependency_graph(contract_specification,
                               self.call_dependencies_repo,
                               self.call_dependents_repo)
Пример #2
0
    def test_generate_dependency_graph_with_function_call(self):
        contract_specification = register_contract_specification(
            specification="""
def double(x):
    return x * 2

double(1 + 1)
""")

        generate_dependency_graph(
            contract_specification=contract_specification,
            call_dependencies_repo=self.call_dependencies_repo,
            call_dependents_repo=self.call_dependents_repo,
            call_leafs_repo=self.call_leafs_repo,
            call_requirement_repo=self.call_requirement_repo,
        )

        root_dependencies = self.call_dependencies_repo[
            contract_specification.id]
        assert isinstance(root_dependencies, CallDependencies)
        self.assertEqual(len(root_dependencies.dependencies), 1)

        root_dependency = root_dependencies.dependencies[0]
        call_dependencies = self.call_dependencies_repo[root_dependency]
        self.assertEqual(len(call_dependencies.dependencies), 0)

        dependency = self.call_dependents_repo[root_dependency]
        assert isinstance(dependency, CallDependents)
        self.assertEqual(len(dependency.dependents), 1)

        self.assertEqual(dependency.dependents[0], contract_specification.id)
Пример #3
0
    def test_generate_dependency_graph_with_function_call(self):
        contract_specification = register_contract_specification(source_code="""
def double(x):
    return x * 2

double(1 + 1)
""")

        generate_dependency_graph(
            contract_specification=contract_specification,
            call_dependencies_repo=self.call_dependencies_repo,
            call_dependents_repo=self.call_dependents_repo,
            call_requirement_repo=self.call_requirement_repo,
        )

        root_dependencies = self.call_dependencies_repo[contract_specification.id]
        assert isinstance(root_dependencies, CallDependencies)
        self.assertEqual(len(root_dependencies.dependencies), 1)

        root_dependency = root_dependencies.dependencies[0]
        call_dependencies = self.call_dependencies_repo[root_dependency]
        self.assertEqual(len(call_dependencies.dependencies), 0)

        dependency = self.call_dependents_repo[root_dependency]
        assert isinstance(dependency, CallDependents)
        self.assertEqual(len(dependency.dependents), 1)

        self.assertEqual(dependency.dependents[0], contract_specification.id)
Пример #4
0
 def generate_dependency_graph(self, event):
     assert isinstance(event, ContractSpecification.Created)
     contract_specification = self.contract_specification_repo[event.entity_id]
     try:
         generate_dependency_graph(contract_specification, self.call_dependencies_repo, self.call_dependents_repo,
                                   self.call_requirement_repo, dsl_classes=self.dsl_classes)
     except RuntimeError as e:
         if 'maximum recursion depth exceeded' in str(e):
             raise RecursionDepthError('maximum recursion depth exceeded')
         else:
             raise
Пример #5
0
 def generate_dependency_graph(self, contract_specification):
     return generate_dependency_graph(contract_specification, self.call_dependencies_repo,
                                      self.call_dependents_repo)
 def generate_dependency_graph(self, event):
     assert isinstance(event, ContractSpecification.Created)
     contract_specification = self.contract_specification_repo[event.entity_id]
     generate_dependency_graph(contract_specification, self.call_dependencies_repo, self.call_dependents_repo)