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)
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)
def register_contract_specification(self, source_code, observation_date=None): """ Registers a new contract specification, from given Quant DSL source code. """ return register_contract_specification( source_code=source_code, observation_date=observation_date)
def register_contract_specification(self, specification): """ The contract specification is a Quant DSL module. """ return register_contract_specification(specification=specification)
def register_contract_specification(self, specification): """ The contract specification is a Quant DSL module. """ return register_contract_specification(specification=specification)
def register_contract_specification(self, source_code, observation_date=None): """ Registers a new contract specification, from given Quant DSL source code. """ return register_contract_specification(source_code=source_code, observation_date=observation_date)