def test_list_market_names_and_fixing_dates(self): dependency_graph = Mock(spec=DependencyGraph, id=1) call_requirement_repo = MagicMock( spec=CallRequirementRepository, __getitem__=lambda self, x: { 1: Mock(spec=CallRequirement, dsl_source="Fixing('2011-01-01', Market('1'))", effective_present_time=datetime.datetime(2011, 1, 1), _dsl_expr=None), 2: Mock(spec=CallRequirement, dsl_source="Fixing('2012-02-02', Market('2'))", effective_present_time=datetime.datetime(2011, 2, 2), _dsl_expr=None), 3: Mock(spec=CallRequirement, dsl_source="Fixing('2013-03-03', Market('3'))", effective_present_time=datetime.datetime(2011, 3, 3), _dsl_expr=None), }[x]) call_link_repo = MagicMock(spec=CallLinkRepository, __getitem__=lambda self, x: { 1: Mock(spec=CallLink, call_id=2), 2: Mock(spec=CallLink, call_id=3), 3: Mock(spec=CallLink, call_id=1), }[x]) call_dependencies_repo = MagicMock( spec=CallDependenciesRepo, __getitem__=lambda self, x: { 1: Mock(spec=CallDependencies, dependencies=[]), 2: Mock(spec=CallDependencies, dependencies=[]), 3: Mock(spec=CallDependencies, dependencies=[]), }[x]) market_dependencies_repo = MagicMock(spec=PerturbationDependenciesRepo) observation_date = datetime.datetime(2011, 1, 1) requirements = set() identify_simulation_requirements(dependency_graph.id, call_requirement_repo, call_link_repo, call_dependencies_repo, market_dependencies_repo, observation_date, requirements) self.assertEqual( requirements, { ('1', datetime.datetime(2011, 1, 1), datetime.datetime(2011, 1, 1)), ('2', datetime.datetime(2012, 2, 2), datetime.datetime(2012, 2, 2)), ('3', datetime.datetime(2013, 3, 3), datetime.datetime(2013, 3, 3)), })
def identify_simulation_requirements(self, contract_specification, observation_date, requirements): assert isinstance(contract_specification, ContractSpecification), contract_specification assert isinstance(requirements, set) return identify_simulation_requirements( contract_specification.id, self.call_requirement_repo, self.call_link_repo, self.call_dependencies_repo, self.perturbation_dependencies_repo, observation_date, requirements)
def identify_simulation_requirements(self, contract_specification, observation_date, requirements, periodisation): assert isinstance(contract_specification, ContractSpecification), type(contract_specification) assert isinstance(requirements, set) return identify_simulation_requirements(contract_specification.id, self.call_requirement_repo, self.call_link_repo, self.call_dependencies_repo, observation_date, requirements, periodisation)
def test_list_market_names_and_fixing_dates(self): contract_specification = Mock(spec=ContractSpecification, id=1) call_requirement1 = Mock(spec=CallRequirement, dsl_source="Fixing('2011-01-01', Market('1'))", present_time=datetime.datetime(2011, 1, 1), _dsl_expr=None, id=1) call_requirement2 = Mock(spec=CallRequirement, dsl_source="Fixing('2012-02-02', Market('2'))", present_time=datetime.datetime(2011, 2, 2), _dsl_expr=None, id=2) call_requirement3 = Mock(spec=CallRequirement, dsl_source="Fixing('2013-03-03', Market('3'))", present_time=datetime.datetime(2011, 3, 3), _dsl_expr=None, id=3) call_requirement_repo = MagicMock(spec=CallRequirementRepository, __getitem__=lambda self, x: { 1: call_requirement1, 2: call_requirement2, 3: call_requirement3, }[x]) self.assertEqual(call_requirement1.id, 1) self.assertEqual(call_requirement2.id, 2) self.assertEqual(call_requirement3.id, 3) call_link_repo = MagicMock(spec=CallLinkRepository, __getitem__=lambda self, x: { 1: Mock(spec=CallLink, call_id=2), 2: Mock(spec=CallLink, call_id=3), 3: Mock(spec=CallLink, call_id=1), }[x]) call_dependencies_repo = MagicMock(spec=CallDependenciesRepo, __getitem__=lambda self, x: { 1: Mock(spec=CallDependencies, dependencies=[]), 2: Mock(spec=CallDependencies, dependencies=[]), 3: Mock(spec=CallDependencies, dependencies=[]), }[x]) observation_date = datetime.datetime(2011, 1, 1) requirements = set() identify_simulation_requirements(contract_specification.id, call_requirement_repo, call_link_repo, call_dependencies_repo, observation_date, requirements) self.assertEqual(requirements, { ('1', datetime.datetime(2011, 1, 1), datetime.datetime(2011, 1, 1)), ('2', datetime.datetime(2012, 2, 2), datetime.datetime(2012, 2, 2)), ('3', datetime.datetime(2013, 3, 3), datetime.datetime(2013, 3, 3)), })
def test_list_market_names_and_fixing_dates(self): contract_specification = Mock(spec=ContractSpecification, id=1) call_requirement1 = Mock( spec=CallRequirement, dsl_source="Fixing('2011-01-01', Market('1'))", present_time=datetime.datetime(2011, 1, 1), _dsl_expr=None, id=1) call_requirement2 = Mock( spec=CallRequirement, dsl_source="Fixing('2012-02-02', Market('2'))", present_time=datetime.datetime(2011, 2, 2), _dsl_expr=None, id=2) call_requirement3 = Mock( spec=CallRequirement, dsl_source="Fixing('2013-03-03', Market('3'))", present_time=datetime.datetime(2011, 3, 3), _dsl_expr=None, id=3) call_requirement_repo = MagicMock(spec=CallRequirementRepository, __getitem__=lambda self, x: { 1: call_requirement1, 2: call_requirement2, 3: call_requirement3, }[x]) self.assertEqual(call_requirement1.id, 1) self.assertEqual(call_requirement2.id, 2) self.assertEqual(call_requirement3.id, 3) call_link_repo = MagicMock(spec=CallLinkRepository, __getitem__=lambda self, x: { 1: Mock(spec=CallLink, call_id=2), 2: Mock(spec=CallLink, call_id=3), 3: Mock(spec=CallLink, call_id=1), }[x]) call_dependencies_repo = MagicMock( spec=CallDependenciesRepo, __getitem__=lambda self, x: { 1: Mock(spec=CallDependencies, dependencies=[]), 2: Mock(spec=CallDependencies, dependencies=[]), 3: Mock(spec=CallDependencies, dependencies=[]), }[x]) observation_date = datetime.datetime(2011, 1, 1) requirements = set() identify_simulation_requirements(contract_specification.id, call_requirement_repo, call_link_repo, call_dependencies_repo, observation_date, requirements) self.assertEqual( requirements, { ('1', datetime.datetime(2011, 1, 1), datetime.datetime(2011, 1, 1)), ('2', datetime.datetime(2012, 2, 2), datetime.datetime(2012, 2, 2)), ('3', datetime.datetime(2013, 3, 3), datetime.datetime(2013, 3, 3)), })