Python hamcrest.has_length() Examples
The following are 30
code examples of hamcrest.has_length().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
hamcrest
, or try the search function
.
Example #1
Source File: test__class_api.py From django-river with BSD 3-Clause "New" or "Revised" License | 6 votes |
def test_shouldReturnNoApprovalWhenUserIsUnAuthorized(self): unauthorized_user = UserObjectFactory() state1 = StateObjectFactory(label="state1") state2 = StateObjectFactory(label="state2") workflow = WorkflowFactory(initial_state=state1, content_type=self.content_type, field_name="my_field") authorized_permission = PermissionObjectFactory() transition_meta = TransitionMetaFactory.create( workflow=workflow, source_state=state1, destination_state=state2, ) TransitionApprovalMetaFactory.create( workflow=workflow, transition_meta=transition_meta, priority=0, permissions=[authorized_permission] ) BasicTestModelObjectFactory() available_approvals = BasicTestModel.river.my_field.get_available_approvals(as_user=unauthorized_user) assert_that(available_approvals, has_length(0))
Example #2
Source File: juniper_mx_protocol_test.py From fake-switches with Apache License 2.0 | 6 votes |
def test_add_a_routing_interface_to_vlan(self): self.edit({ "bridge-domains": { "domain": { "name": "VLAN123", "vlan-id": "123", "routing-interface": "irb.123"}}}) self.nc.commit() vlan123 = self._get_vlan("VLAN123") assert_that(vlan123.xpath("routing-interface")[0].text, is_("irb.123")) self.edit({ "bridge-domains": { "domain": [ {"name": "VLAN123"}, {"routing-interface": {XML_ATTRIBUTES: {"operation": "delete"}}}]}}) self.nc.commit() vlan123 = self._get_vlan("VLAN123") assert_that(vlan123.xpath("routing-interface"), has_length(0)) self.cleanup(vlan("VLAN123"))
Example #3
Source File: arista_test.py From netman with Apache License 2.0 | 6 votes |
def test_get_vlan_without_interface(self): self.switch.node.should_receive("enable") \ .with_args(["show vlan 456", "show interfaces Vlan456"], strict=True) \ .and_raise(CommandError(1002, "CLI command 3 of 3 'show interfaces Vlan456' failed: invalid command", command_error="Interface does not exist", output=[ {}, {'vlans': {'456': vlan_data(name='Patate')}}, {'errors': ['Interface does not exist']} ])) self.switch.node.should_receive("get_config").with_args(params="interfaces Vlan456").once() \ .and_return(['interface Vlan456']) vlan = self.switch.get_vlan(456) assert_that(vlan.number, equal_to(456)) assert_that(vlan.name, equal_to('Patate')) assert_that(vlan.ips, has_length(0))
Example #4
Source File: juniper_mx_protocol_test.py From fake-switches with Apache License 2.0 | 6 votes |
def test_set_interface_disabling(self): result = self.nc.get_config(source="running", filter=dict_2_etree({"filter": { "configuration": {"interfaces": {"interface": {"name": "xe-0/0/2"}}}}})) assert_that(result.xpath("data/configuration/interfaces/interface"), has_length(0)) self.edit({"interfaces": {"interface": [{"name": "xe-0/0/2"}, {"disable": ""}]}}) self.nc.commit() result = self.nc.get_config(source="running", filter=dict_2_etree({"filter": { "configuration": {"interfaces": {"interface": {"name": "xe-0/0/2"}}}}})) int002 = result.xpath("data/configuration/interfaces/interface")[0] assert_that(int002.xpath("disable"), has_length(1)) self.edit({"interfaces": { "interface": [{"name": "xe-0/0/2"}, {"disable": {XML_ATTRIBUTES: {"operation": "delete"}}}]}}) self.nc.commit() result = self.nc.get_config(source="running", filter=dict_2_etree({"filter": { "configuration": {"interfaces": {"interface": {"name": "xe-0/0/2"}}}}})) assert_that(result.xpath("data/configuration/interfaces/interface"), has_length(0))
Example #5
Source File: juniper_mx_protocol_test.py From fake-switches with Apache License 2.0 | 6 votes |
def test_multiple_ip_support(self): self.edit({ "interfaces": { "interface": { "name": "irb", "unit": { "name": "300", "family": { "inet": [ {"address": {"name": "3.3.3.2/27"}}, {"address": {"name": "4.4.4.2/27"}}, ]}}}}}) self.nc.commit() int_vlan = self._interface_vlan("300") assert_that(int_vlan.xpath("family/inet/address"), has_length(2)) assert_that(int_vlan.xpath("family/inet/address/name")[0].text, is_("3.3.3.2/27")) assert_that(int_vlan.xpath("family/inet/address/name")[1].text, is_("4.4.4.2/27")) self.cleanup(reset_interface("irb"))
Example #6
Source File: test_mirror_view.py From storops with Apache License 2.0 | 6 votes |
def test_get_single(self): mg = VNXMirrorGroup.get(t_cli(), name='petermg') assert_that(mg, instance_of(VNXMirrorGroup)) assert_that(mg.name, equal_to('petermg')) assert_that(mg.gid, equal_to('50:06:01:60:B6:60:25:22:00:00:00:00')) assert_that(mg.description, equal_to('')) assert_that(mg.state, equal_to('Synchronized')) assert_that(mg.role, equal_to('Primary')) assert_that(mg.condition, equal_to('Active')) assert_that(mg.policy, equal_to(VNXMirrorGroupRecoveryPolicy.MANUAL)) assert_that(mg.mirrors, has_length(2)) assert_that(mg.group_mirrors, has_length(2)) for m in mg.mirrors: assert_that(m, instance_of(VNXMirrorView)) for mg in mg.group_mirrors: assert_that( mg.mirror_name, not_none()) assert_that(mg.src_lun_id, instance_of(int))
Example #7
Source File: test__class_api.py From django-river with BSD 3-Clause "New" or "Revised" License | 6 votes |
def test_shouldAssesFinalStateProperlyWhenThereIsOnlyOne(self): state1 = StateObjectFactory(label="state1") state2 = StateObjectFactory(label="state2") workflow = WorkflowFactory(initial_state=state1, content_type=self.content_type, field_name="my_field") transition_meta = TransitionMetaFactory.create( workflow=workflow, source_state=state1, destination_state=state2, ) TransitionApprovalMetaFactory.create( workflow=workflow, transition_meta=transition_meta, priority=0 ) assert_that(BasicTestModel.river.my_field.final_states, has_length(1)) assert_that(list(BasicTestModel.river.my_field.final_states), has_item(state2))
Example #8
Source File: test__migrations.py From django-river with BSD 3-Clause "New" or "Revised" License | 6 votes |
def test_shouldCreateAllMigrations(self): for f in os.listdir("river/migrations"): if f != "__init__.py" and f != "__pycache__" and not f.endswith(".pyc"): open(os.path.join("river/tests/volatile/river/", f), 'wb').write(open(os.path.join("river/migrations", f), 'rb').read()) self.migrations_before = list(filter(lambda f: f.endswith('.py') and f != '__init__.py', os.listdir('river/tests/volatile/river/'))) out = StringIO() sys.stout = out call_command('makemigrations', 'river', stdout=out) self.migrations_after = list(filter(lambda f: f.endswith('.py') and f != '__init__.py', os.listdir('river/tests/volatile/river/'))) assert_that(out.getvalue(), equal_to("No changes detected in app 'river'\n")) assert_that(self.migrations_after, has_length(len(self.migrations_before)))
Example #9
Source File: test__transition_approval.py From django-river with BSD 3-Clause "New" or "Revised" License | 6 votes |
def test_shouldNotAllowWorkflowToBeDeletedWhenThereIsATransitionApproval(self): content_type = ContentType.objects.get_for_model(BasicTestModel) state1 = StateObjectFactory(label="state1") state2 = StateObjectFactory(label="state2") workflow = WorkflowFactory(initial_state=state1, content_type=content_type, field_name="my_field") transition_meta = TransitionMetaFactory.create( workflow=workflow, source_state=state1, destination_state=state2, ) TransitionApprovalMetaFactory.create(workflow=workflow, transition_meta=transition_meta, priority=0) BasicTestModelObjectFactory() TransitionApproval.objects.filter(workflow=workflow).update(status=APPROVED) approvals = TransitionApproval.objects.filter(workflow=workflow) assert_that(approvals, has_length(1)) assert_that( calling(workflow.delete), raises(ProtectedError, "Cannot delete some instances of model 'Workflow' because they are referenced through a protected foreign key") )
Example #10
Source File: test__transition_approval_meta.py From django-river with BSD 3-Clause "New" or "Revised" License | 6 votes |
def test_shouldNotDeletePendingTransitionWhenDeleted(self): content_type = ContentType.objects.get_for_model(BasicTestModel) state1 = StateObjectFactory(label="state1") state2 = StateObjectFactory(label="state2") workflow = WorkflowFactory(initial_state=state1, content_type=content_type, field_name="my_field") transition_meta = TransitionMetaFactory.create( workflow=workflow, source_state=state1, destination_state=state2, ) meta1 = TransitionApprovalMetaFactory.create(workflow=workflow, transition_meta=transition_meta, priority=0) BasicTestModelObjectFactory() TransitionApproval.objects.filter(workflow=workflow).update(status=PENDING) assert_that(TransitionApproval.objects.filter(workflow=workflow), has_length(1)) meta1.delete() assert_that(TransitionApproval.objects.filter(workflow=workflow), has_length(0))
Example #11
Source File: juniper_base_protocol_test.py From fake-switches with Apache License 2.0 | 5 votes |
def test_lock_edit_candidate_add_vlan_and_commit(self): with self.nc.locked(target='candidate'): result = self.nc.edit_config(target='candidate', config=dict_2_etree({ "config": { "configuration": { "vlans": { "vlan": { "name": "VLAN2999", } } } }})) assert_that(result.xpath("//rpc-reply/ok"), has_length(1)) result = self.nc.commit() assert_that(result.xpath("//rpc-reply/ok"), has_length(1)) result = self.nc.get_config(source="running") assert_that(result.xpath("data/configuration/vlans/vlan"), has_length(1)) self.edit({ "vlans": { "vlan": { XML_ATTRIBUTES: {"operation": "delete"}, "name": "VLAN2999" } } }) self.nc.commit() result = self.nc.get_config(source="running") assert_that(result.xpath("data/configuration/vlans/vlan"), has_length(0))
Example #12
Source File: juniper_base_protocol_with_commit_delay_test.py From fake-switches with Apache License 2.0 | 5 votes |
def test_lock_edit_candidate_add_vlan_and_commit_with_commit_delay(self): with self.nc.locked(target='candidate'): result = self.nc.edit_config(target='candidate', config=dict_2_etree({ "config": { "configuration": { "vlans": { "vlan": { "name": "VLAN2999", } } } }})) assert_that(result.xpath("//rpc-reply/ok"), has_length(1)) result = self.nc.commit() assert_that(result.xpath("//rpc-reply/ok"), has_length(1)) result = self.nc.get_config(source="running") assert_that(result.xpath("data/configuration/vlans/vlan"), has_length(1)) self.edit({ "vlans": { "vlan": { XML_ATTRIBUTES: {"operation": "delete"}, "name": "VLAN2999" } } }) start_time = time() self.nc.commit() end_time = time() result = self.nc.get_config(source="running") assert_that(result.xpath("data/configuration/vlans/vlan"), has_length(0)) assert_that((end_time - start_time), greater_than(COMMIT_DELAY))
Example #13
Source File: juniper_mx_protocol_test.py From fake-switches with Apache License 2.0 | 5 votes |
def test_set_interface_description(self): self.edit({ "interfaces": { "interface": [ {"name": "xe-0/0/2"}, {"description": "Hey there beautiful"}]}}) self.nc.commit() result = self.nc.get_config(source="running", filter=dict_2_etree({"filter": { "configuration": {"interfaces": {"interface": {"name": "xe-0/0/2"}}}} })) assert_that(result.xpath("data/configuration/interfaces/interface"), has_length(1)) int002 = result.xpath("data/configuration/interfaces/interface")[0] assert_that(int002.xpath("name")[0].text, equal_to("xe-0/0/2")) assert_that(int002.xpath("description")[0].text, equal_to("Hey there beautiful")) self.edit({ "interfaces": { "interface": [ {"name": "xe-0/0/2"}, {"description": {XML_ATTRIBUTES: {"operation": "delete"}}}]}}) self.nc.commit() result = self.nc.get_config(source="running", filter=dict_2_etree({"filter": { "configuration": {"interfaces": {"interface": {"name": "xe-0/0/2"}}}} })) assert_that(result.xpath("data/configuration/interfaces/interface"), has_length(0))
Example #14
Source File: __init__.py From fake-switches with Apache License 2.0 | 5 votes |
def edit(self, config): result = self.nc.edit_config(target="candidate", config=dict_2_etree({ "config": { "configuration": config } })) assert_that(result.xpath("//rpc-reply/ok"), has_length(1))
Example #15
Source File: __init__.py From fake-switches with Apache License 2.0 | 5 votes |
def tearDown(self): assert_that(self.nc.get_config(source="running").xpath("data/configuration/*"), has_length(0)) try: self.nc.discard_changes() finally: self.nc.close_session()
Example #16
Source File: juniper_base_protocol_test.py From fake-switches with Apache License 2.0 | 5 votes |
def test_create_vlan(self): self.nc.edit_config(target='candidate', config=dict_2_etree({"config": {"configuration": { "vlans": { "vlan": [ {"name": "VLAN2999"}, {"description": "WHAAT"}, {"vlan-id": "2995"} ] } }}})) self.nc.commit() result = self.nc.get_config(source="running", filter=dict_2_etree({"filter": { "configuration": {"vlans": {}}} })) assert_that(result.xpath("data/*"), has_length(1)) assert_that(result.xpath("data/configuration/*"), has_length(1)) assert_that(result.xpath("data/configuration/vlans/*"), has_length(1)) assert_that(result.xpath("data/configuration/vlans/vlan/*"), has_length(3)) vlan2995 = result.xpath("data/configuration/vlans/vlan")[0] assert_that(vlan2995.xpath("name")[0].text, equal_to("VLAN2999")) assert_that(vlan2995.xpath("description")[0].text, equal_to("WHAAT")) assert_that(vlan2995.xpath("vlan-id")[0].text, equal_to("2995")) self.cleanup(vlan("VLAN2999"))
Example #17
Source File: juniper_base_protocol_with_commit_delay_test.py From fake-switches with Apache License 2.0 | 5 votes |
def edit(self, config): result = self.nc.edit_config(target="candidate", config=dict_2_etree({ "config": { "configuration": config } })) assert_that(result.xpath("//rpc-reply/ok"), has_length(1))
Example #18
Source File: test_cisco_core.py From fake-switches with Apache License 2.0 | 5 votes |
def test_cisco_2960_48TT_L_has_right_ports(self): ports = cisco_core.Cisco2960_48TT_L_SwitchCore.get_default_ports() fast_ethernet_ports = [p for p in ports if p.name.startswith('FastEthernet')] gigabit_ethernet_ports = [p for p in ports if p.name.startswith('GigabitEthernet')] assert_that(fast_ethernet_ports, has_length(48)) assert_that(gigabit_ethernet_ports, has_length(2)) assert_that(fast_ethernet_ports[0], has_property('name', 'FastEthernet0/1')) assert_that(gigabit_ethernet_ports[0], has_property('name', 'GigabitEthernet0/1'))
Example #19
Source File: juniper_base_protocol_test.py From fake-switches with Apache License 2.0 | 5 votes |
def test_only_configured_interfaces_are_returned(self): self.edit({ "interfaces": { "interface": [ {"name": "ge-0/0/3"}, {"description": "I see what you did there!"}]}}) self.nc.commit() result = self.nc.get_config(source="running") assert_that(result.xpath("data/configuration/interfaces/*"), has_length(1)) self.cleanup(reset_interface("ge-0/0/3"))
Example #20
Source File: juniper_mx_protocol_test.py From fake-switches with Apache License 2.0 | 5 votes |
def test_auto_negotiation_and_no_auto_negotiation_are_mutually_exclusive(self): self.edit({ "interfaces": [ {"interface": [ {"name": "xe-0/0/1"}, {"gigether-options": { "auto-negotiation": {}}}]}]}) self.nc.commit() ge001 = self.get_interface("xe-0/0/1") assert_that(ge001.xpath("gigether-options/auto-negotiation"), has_length(1)) assert_that(ge001.xpath("gigether-options/no-auto-negotiation"), has_length(0)) self.edit({ "interfaces": [ {"interface": [ {"name": "xe-0/0/1"}, {"gigether-options": { "no-auto-negotiation": {}}}]}]}) self.nc.commit() ge001 = self.get_interface("xe-0/0/1") assert_that(ge001.xpath("gigether-options/auto-negotiation"), has_length(0)) assert_that(ge001.xpath("gigether-options/no-auto-negotiation"), has_length(1)) self.edit({ "interfaces": [ {"interface": [ {"name": "xe-0/0/1"}, {"gigether-options": { "no-auto-negotiation": {XML_ATTRIBUTES: {"operation": "delete"}}}}]}]}) self.nc.commit() assert_that(self.get_interface("xe-0/0/1"), is_(None))
Example #21
Source File: juniper_mx_protocol_test.py From fake-switches with Apache License 2.0 | 5 votes |
def test_set_interface_trunk_native_vlan_id(self): self.edit({ "interfaces": { "interface": [ {"name": "xe-0/0/2"}, {"native-vlan-id": "2996"}]}}) self.nc.commit() result = self.nc.get_config(source="running", filter=dict_2_etree({"filter": { "configuration": {"interfaces": {"interface": {"name": "xe-0/0/2"}}}} })) assert_that(result.xpath("data/configuration/interfaces/interface"), has_length(1)) int002 = result.xpath("data/configuration/interfaces/interface")[0] assert_that(int002.xpath("name")[0].text, equal_to("xe-0/0/2")) assert_that(int002.xpath("native-vlan-id")[0].text, equal_to("2996")) self.edit({ "interfaces": { "interface": [ {"name": "xe-0/0/2"}, {"native-vlan-id": {XML_ATTRIBUTES: {"operation": "delete"}}}]}}) self.nc.commit() result = self.nc.get_config(source="running", filter=dict_2_etree({"filter": { "configuration": {"interfaces": {"interface": {"name": "xe-0/0/2"}}}} })) assert_that(result.xpath("data/configuration/interfaces/interface"), has_length(0)) self.cleanup(reset_interface("xe-0/0/2"))
Example #22
Source File: netconf_protocol_test.py From fake-switches with Apache License 2.0 | 5 votes |
def test_filtering(self): content = dict_2_etree({ "data": { "configuration": [ {"shizzle": { "whizzle": {} }}, {"shizzle": { "whizzle": { "howdy": {} }, "not-whizzle": { "not-howdy": {} } }}, {"zizzle": { "nothing": {} }}, {"outzzle": { "nothing": {} }} ] } }) content_filter = dict_2_etree({ "filter": { "configuration": { "shizzle": {"whizzle": {}}, "zizzle": {}, } } }) filter_content(content, content_filter) assert_that(content.xpath("//data/configuration/shizzle"), has_length(2)) assert_that(content.xpath("//data/configuration/shizzle/*"), has_length(2)) assert_that(content.xpath("//data/configuration/shizzle/whizzle/howdy"), has_length(1)) assert_that(content.xpath("//data/configuration/zizzle"), has_length(1)) assert_that(content.xpath("//data/configuration/outzzle"), has_length(0))
Example #23
Source File: juniper_mx_protocol_test.py From fake-switches with Apache License 2.0 | 5 votes |
def test_vlan_configuration_merging(self): self.edit({ "bridge-domains": { "domain": [ {"name": "VLAN2999"}, {"vlan-id": "2995"} ]}}) self.edit({ "bridge-domains": { "domain": [ {"name": "VLAN2999"}, {"description": "shizzle"} ]}}) self.nc.commit() self.edit({ "bridge-domains": { "domain": [ {"name": "VLAN2999"}, {"vlan-id": "2996"}, {"description": {XML_ATTRIBUTES: {"operation": "delete"}}} ]}}) self.nc.commit() result = self.nc.get_config(source="running", filter=dict_2_etree({"filter": { "configuration": {"bridge-domains": {}}} })) assert_that(result.xpath("data/configuration/bridge-domains/domain"), has_length(1)) vlan2995 = result.xpath("data/configuration/bridge-domains/domain")[0] assert_that(vlan2995.xpath("name")[0].text, equal_to("VLAN2999")) assert_that(vlan2995.xpath("description"), has_length(0)) assert_that(vlan2995.xpath("vlan-id")[0].text, equal_to("2996")) self.cleanup(vlan("VLAN2999"))
Example #24
Source File: juniper_mx_protocol_test.py From fake-switches with Apache License 2.0 | 5 votes |
def test_create_vlan(self): self.nc.edit_config(target='candidate', config=dict_2_etree({"config": {"configuration": { "bridge-domains": { "domain": [ {"name": "VLAN2999"}, {"description": "WHAAT"}, {"vlan-id": "2995"} ] } }}})) self.nc.commit() result = self.nc.get_config(source="running", filter=dict_2_etree({"filter": { "configuration": {"bridge-domains": {}}} })) assert_that(result.xpath("data/*"), has_length(1)) assert_that(result.xpath("data/configuration/*"), has_length(1)) assert_that(result.xpath("data/configuration/bridge-domains/*"), has_length(1)) assert_that(result.xpath("data/configuration/bridge-domains/domain/*"), has_length(3)) vlan2995 = result.xpath("data/configuration/bridge-domains/domain")[0] assert_that(vlan2995.xpath("name")[0].text, equal_to("VLAN2999")) assert_that(vlan2995.xpath("description")[0].text, equal_to("WHAAT")) assert_that(vlan2995.xpath("vlan-id")[0].text, equal_to("2995")) self.cleanup(vlan("VLAN2999"))
Example #25
Source File: juniper_mx_protocol_test.py From fake-switches with Apache License 2.0 | 5 votes |
def test_lock_edit_candidate_add_vlan_and_commit(self): with self.nc.locked(target='candidate'): result = self.nc.edit_config(target='candidate', config=dict_2_etree({ "config": { "configuration": { "bridge-domains": { "domain": { "name": "VLAN2999", "vlan-id": "2999", } } } }})) assert_that(result.xpath("//rpc-reply/ok"), has_length(1)) result = self.nc.commit() assert_that(result.xpath("//rpc-reply/ok"), has_length(1)) result = self.nc.get_config(source="running") assert_that(result.xpath("data/configuration/bridge-domains/domain"), has_length(1)) self.edit({ "bridge-domains": { "domain": { XML_ATTRIBUTES: {"operation": "delete"}, "name": "VLAN2999" } } }) self.nc.commit() result = self.nc.get_config(source="running") assert_that(result.xpath("data/configuration/bridge-domains/domain"), has_length(0))
Example #26
Source File: juniper_mx_protocol_test.py From fake-switches with Apache License 2.0 | 5 votes |
def test_only_configured_interfaces_are_returned(self): self.edit({ "interfaces": { "interface": [ {"name": "xe-0/0/3"}, {"description": "I see what you did there!"}]}}) self.nc.commit() result = self.nc.get_config(source="running") assert_that(result.xpath("data/configuration/interfaces/*"), has_length(1)) self.cleanup(reset_interface("xe-0/0/3"))
Example #27
Source File: juniper_mx_protocol_test.py From fake-switches with Apache License 2.0 | 5 votes |
def test_get_running_config_shows_nothing_by_default(self): result = self.nc.get_config(source="running") conf = result._NCElement__result.xml assert_that(conf, contains_regex( '<configuration xmlns="http://xml.juniper.net/xnm/1.1/xnm" junos:commit-localtime="[^"]*" junos:commit-seconds="[^"]*" junos:commit-user="[^"]*"')) assert_that(result.xpath("data/configuration/*"), has_length(0))
Example #28
Source File: test_portfolio_statistics.py From cifrum with GNU General Public License v3.0 | 5 votes |
def test__handle_assets_with_monthly_data_gaps(currency: Currency): p = lib.portfolio(assets={'micex/KUBE': 1}, currency=currency.name) assert_that(p, not_none()) assert_that(p.assets, has_length(1)) assert_that(p.get_return(), is_not(empty()))
Example #29
Source File: basic_steps.py From django-river with BSD 3-Clause "New" or "Revised" License | 5 votes |
def check_output_count(context, number): assert_that(context.result, has_length(number))
Example #30
Source File: test_portfolio_statistics.py From cifrum with GNU General Public License v3.0 | 5 votes |
def test__initial_data(): assert_that(_portfolio.assets, has_length(3)) p = lib.portfolio(assets=_asset_names, start_period=str(_portfolio_period_start), end_period=str(_portfolio_period_end), currency='RUB') assert_that(p.assets, has_length(3)) assert_that(p.assets['mut_ru/0890-94127385'].close().values, contains( *[1055.64, 1094.14, 1080.76, 1074.51, 1091.37, 1151.83, 1103.9, 1147.5, 1193.69, 1175.64, 1199.64, 1233.88, 1252.67, 1302.46, 1268.7, 1269.31, 1334.93, 1351.45, 1357.41, 1366.64, 1444.08, 1535.61, 1525.6, 1403.08, 1375.97, 1390.39, 1314.96] )) assert_that(p.assets['micex/FXRU'].close().values, contains( *[5070., 4670., 4830., 5110., 5650., 6130., 6160., 6140., 6330., 7020., 7230., 7250., 6720., 6540., 6710., 6630., 6760., 6770., 6550., 6610., 6570., 6260., 6310., 6110., 5970., 6110., 6190.] )) assert_that(p.assets['micex/FXMM'].close().values, contains( *[1097.2, 1110., 1121.7, 1135.5, 1146.5, 1155.7, 1164.4, 1174.3, 1183.8, 1194.7, 1203.8, 1215.1, 1228.6, 1233.2, 1237.3, 1246.6, 1253.7, 1265.5, 1273.4, 1282.7, 1292.1, 1302.2, 1308.6, 1317.2, 1327.5, 1336.8, 1346.1] )) assert_that(np.round(_portfolio.get_return().values, 8).tolist(), contains( *[0.12229691, -0.01582228, -0.02737772, -0.01702011, -0.06406856, -0.01160388, 0.04782469, 0.00100095, -0.06237734, -0.0103524, 0.01680251, 0.09387303, 0.06095007, -0.02852904, 0.02625182, -0.01216933, 0.04138359, 0.02000188, 0.01177389, -0.00741344, 0.08587424, 0.00909396, -0.00811951, 0.01276804, 0.00324936, -0.0100885])) assert_that(np.round(_portfolio.get_return(real=True).values, 8).tolist(), contains( *[0.12001991, -0.0208132, -0.03077293, -0.01708596, -0.0627414, -0.01006255, 0.04829642, 0.00311853, -0.05916249, -0.01198559, 0.01596637, 0.08918301, 0.05594384, -0.03244377, 0.02289264, -0.01056843, 0.04042848, 0.01755568, 0.01051378, -0.00586757, 0.08551928, 0.00324703, -0.01123018, 0.01194533, 0.00028252, -0.01093415] ))