def setUp(self) -> None: super().setUp() add_location_type( client=self.client, name="City", properties=[ PropertyDefinition( property_name="Mayor", property_kind=PropertyKind.string, default_raw_value=None, is_fixed=False, ), PropertyDefinition( property_name="Contact", property_kind=PropertyKind.email, default_raw_value=None, is_fixed=False, ), ], ) self.external_id = "test_external_id" self.suffixes = ["txt", "pdf", "png"] self.tmpdir = tempfile.mkdtemp() self.location_1 = add_location( client=self.client, location_hirerchy=[("City", "Lima1")], properties_dict={"Mayor": "Bernard King", "Contact": "*****@*****.**"}, lat=10, long=20, ) self.location_2 = add_location( client=self.client, location_hirerchy=[("City", "Lima2")], properties_dict={"Mayor": "Bernard King", "Contact": "*****@*****.**"}, lat=10, long=20, ) self.location_with_ext_id = add_location( client=self.client, location_hirerchy=[("City", "Lima3")], properties_dict={"Mayor": "Bernard King", "Contact": "*****@*****.**"}, lat=10, long=20, external_id=self.external_id, ) self.location_child_1 = add_location( client=self.client, location_hirerchy=[("City", "parent"), ("City", "child1")], properties_dict={"Mayor": "Bernard King", "Contact": "*****@*****.**"}, ) self.location_child_2 = add_location( client=self.client, location_hirerchy=[("City", "parent"), ("City", "child2")], properties_dict={"Mayor": "Bernard King", "Contact": "*****@*****.**"}, )
def test_equipment_type_add_external_id_to_property_type(self) -> None: equipment_type_name = self.equipment_type.name property_type_name = "IP" property_type_id = get_property_type_id( client=self.client, entity_type=Entity.EquipmentType, entity_name=equipment_type_name, property_type_name=property_type_name, ) e_type = edit_equipment_type_property_type( client=self.client, equipment_type_name=equipment_type_name, property_type_id=property_type_id, new_property_definition=PropertyDefinition( property_name=property_type_name, property_kind=PropertyKind.string, default_value=None, is_fixed=False, external_id="12345", ), ) property_types = get_property_types( client=self.client, entity_type=Entity.EquipmentType, entity_name=e_type.name, ) fetched_property_type = None for property_type in property_types: if property_type.name == property_type_name: fetched_property_type = property_type self.assertIsNotNone(fetched_property_type) self.assertEqual(fetched_property_type.externalId, "12345")
def setUp(self) -> None: super().setUp() add_equipment_port_type( self.client, name="port type 1", properties=[ PropertyDefinition( property_name="port property", property_kind=PropertyKind.string, default_value="port property value", is_fixed=False, ) ], link_properties=[ PropertyDefinition( property_name="link property", property_kind=PropertyKind.string, default_value="link property value", is_fixed=False, ) ], ) add_service_type( client=self.client, name="Internet Access", hasCustomer=True, properties=[ ("Service Package", "string", "Public 5G", True), ("Address Family", "string", None, True), ], ) add_location_type( client=self.client, name="Room", properties=[("Contact", "email", None, True)], ) add_equipment_type( client=self.client, name="Tp-Link T1600G", category="Router", properties=[("IP", "string", None, True)], ports_dict={ "Port 1": "port type 1", "Port 2": "port type 1" }, position_list=[], )
def setUp(self) -> None: super().setUp() self.service_type = add_service_type( client=self.client, name="Internet Access", has_customer=True, properties=[ PropertyDefinition( property_name="Service Package", property_kind=PropertyKind.string, default_raw_value="Public 5G", is_fixed=False, ), PropertyDefinition( property_name="Address Family", property_kind=PropertyKind.string, default_raw_value=None, is_fixed=False, ), ], endpoint_definitions=[], ) self.service = add_service( client=self.client, name="Room 201 Internet Access", external_id="S3232", service_type=self.service_type.name, customer=None, properties_dict={"Address Family": "v4"}, ) self.customer = add_customer(client=self.client, name="Donald", external_id="S322") self.service_with_customer = add_service( client=self.client, name="Room 202 Internet Access", external_id="S32325", service_type=self.service_type.name, customer=self.customer, properties_dict={"Address Family": "v4"}, )
def setUp(self) -> None: super().setUp() self.port_type1 = add_equipment_port_type( self.client, name="port type 1", properties=[ PropertyDefinition( property_name="port property", property_kind=PropertyKind.string, default_value="port property value", is_fixed=False, ) ], link_properties=[ PropertyDefinition( property_name="link property", property_kind=PropertyKind.string, default_value="link property value", is_fixed=False, ) ], )
def test_equipment_type_created(self) -> None: fetched_equipment_type = get_or_create_equipment_type( client=self.client, name="Tp-Link T1600G", category="Router", properties=[ PropertyDefinition( property_name="IP", property_kind=PropertyKind.string, default_value=None, is_fixed=False, ) ], ports_dict={}, position_list=[], ) self.assertEqual(self.equipment_type, fetched_equipment_type)
def setUp(self) -> None: super().setUp() self.equipment_type = add_equipment_type( client=self.client, name="Tp-Link T1600G", category="Router", properties=[ PropertyDefinition( property_name="IP", property_kind=PropertyKind.string, default_value=None, is_fixed=False, ) ], ports_dict={}, position_list=[], )
def test_service_type_edited(self) -> None: equipment_type = add_equipment_type( client=self.client, name="Tp-Link T1600G", category="Router", properties=[ PropertyDefinition( property_name="IP", property_kind=PropertyKind.string, default_raw_value=None, is_fixed=False, ) ], ports_dict={}, position_list=[], ) new_name = "New Service Package" new_properties = {"Service Package": "Public 5G"} endpoint_definitions = SERVICE_TYPES[ self.service_type.name].endpoint_definitions self.assertFalse(endpoint_definitions) edited_service_type = edit_service_type( client=self.client, service_type=self.service_type, new_name=new_name, new_properties=new_properties, new_endpoints=[ ServiceEndpointDefinition( id=None, name="EndpointDefinition", role="CPE", endpoint_definition_index=0, equipment_type_id=equipment_type.id, ) ], ) endpoint_definitions = SERVICE_TYPES[ edited_service_type.name].endpoint_definitions self.assertEqual(len(endpoint_definitions), 1) self.assertEqual(edited_service_type.name, new_name) self.assertEqual(len(edited_service_type.property_types), 1) self.assertEqual( edited_service_type.property_types[0].default_raw_value, "Public 5G")
def test_equipment_type_property_type_name(self) -> None: equipment_type_name = self.equipment_type.name property_type_name = "IP" new_name = "new_IP" property_type_id = get_property_type_id( client=self.client, entity_type=Entity.EquipmentType, entity_name=equipment_type_name, property_type_name=property_type_name, ) e_type = edit_equipment_type_property_type( client=self.client, equipment_type_name=equipment_type_name, property_type_id=property_type_id, new_property_definition=PropertyDefinition( property_name=new_name, property_kind=PropertyKind.string, default_raw_value=None, is_fixed=False, external_id=None, ), ) property_types = get_property_types( client=self.client, entity_type=Entity.EquipmentType, entity_name=e_type.name, ) fetched_property_type = None for property_type in property_types: property_type_input = format_to_property_type_input(property_type) if property_type_input.name == property_type_name: fetched_property_type = property_type_input self.assertEqual(fetched_property_type, None) for property_type in property_types: property_type_input = format_to_property_type_input(property_type) if property_type_input.name == new_name: fetched_property_type = property_type_input assert fetched_property_type is not None, f"property {new_name} does not exist" if fetched_property_type is not None: self.assertEqual(fetched_property_type.name, new_name)
def setUp(self) -> None: super().setUp() self.service_type = add_service_type( client=self.client, name="Internet Access", has_customer=True, properties=[ PropertyDefinition( property_name="Service Package", property_kind=PropertyKind.string, default_value=None, is_fixed=False, ) ], ) self.service = add_service( client=self.client, name="Room 201 Internet Access", external_id="S3232", service_type=self.service_type.name, customer=None, properties_dict={"Service Package": "Public 5G"}, )
def setUp(self) -> None: super().setUp() self.port_type1 = add_equipment_port_type( self.client, name="port type 1", properties=[ PropertyDefinition( property_name="port property", property_kind=PropertyKind.string, default_value="port property value", is_fixed=False, ) ], link_properties=[ PropertyDefinition( property_name="link property", property_kind=PropertyKind.string, default_value="link property value", is_fixed=False, ) ], ) add_location_type( client=self.client, name="City", properties=[ ("Mayor", "string", None, True), ("Contact", "email", None, True), ], ) add_equipment_type( client=self.client, name="Tp-Link T1600G", category="Router", properties=[("IP", "string", None, True)], ports_dict={"tp_link_port": "port type 1"}, position_list=[], ) self.location = add_location( client=self.client, location_hirerchy=[("City", "Lima")], properties_dict={ "Mayor": "Bernard King", "Contact": "*****@*****.**" }, lat=10, long=20, ) self.equipment = add_equipment( client=self.client, name="TPLinkRouter", equipment_type="Tp-Link T1600G", location=self.location, properties_dict={"IP": "127.0.0.1"}, ) self.equipment_with_external_id = add_equipment( client=self.client, name="TPLinkRouterExt", equipment_type="Tp-Link T1600G", location=self.location, properties_dict={"IP": "127.0.0.1"}, external_id="12345", )
def test_service_endpoint_added(self) -> None: add_equipment_port_type( self.client, name="port type 1", properties=[ PropertyDefinition( property_name="port property", property_kind=PropertyKind.string, default_raw_value="port property value", is_fixed=False, ) ], link_properties=[ PropertyDefinition( property_name="link property", property_kind=PropertyKind.string, default_raw_value="link property value", is_fixed=False, ) ], ) add_location_type( client=self.client, name="Room", properties=[ PropertyDefinition( property_name="Contact", property_kind=PropertyKind.email, default_raw_value=None, is_fixed=False, ) ], ) location = add_location( client=self.client, location_hirerchy=[("Room", "Room 201")], properties_dict={"Contact": "*****@*****.**"}, lat=10, long=20, ) equipment_type = add_equipment_type( client=self.client, name="Tp-Link T1600G", category="Router", properties=[ PropertyDefinition( property_name="IP", property_kind=PropertyKind.string, default_raw_value=None, is_fixed=False, ) ], ports_dict={ "Port 1": "port type 1", "Port 2": "port type 1" }, position_list=[], ) router1 = add_equipment( client=self.client, name="TPLinkRouter1", equipment_type=equipment_type.name, location=location, properties_dict={"IP": "192.688.0.1"}, ) edit_service_type( client=self.client, service_type=self.service_type, new_endpoints=[ ServiceEndpointDefinition( id=None, name="EndpointDefinition", role="CPE", endpoint_definition_index=0, equipment_type_id=equipment_type.id, ) ], ) endpoint_definitions = SERVICE_TYPES[ self.service_type.name].endpoint_definitions endpoints = get_service_endpoints(client=self.client, service_id=self.service.id) self.assertFalse(endpoints) endpoint_definition_id = endpoint_definitions[0].id assert (endpoint_definition_id is not None ), f"service type {self.service_type.name} has no endpoints" add_service_endpoint( client=self.client, service=self.service, equipment_id=router1.id, endpoint_definition_id=endpoint_definition_id, ) endpoints = get_service_endpoints(client=self.client, service_id=self.service.id) self.assertEqual(len(endpoints), 1)
def test_service_link_added(self) -> None: add_equipment_port_type( self.client, name="port type 1", properties=[ PropertyDefinition( property_name="port property", property_kind=PropertyKind.string, default_raw_value="port property value", is_fixed=False, ) ], link_properties=[ PropertyDefinition( property_name="link property", property_kind=PropertyKind.string, default_raw_value="link property value", is_fixed=False, ) ], ) add_location_type( client=self.client, name="Room", properties=[ PropertyDefinition( property_name="Contact", property_kind=PropertyKind.email, default_raw_value=None, is_fixed=False, ) ], ) location = add_location( client=self.client, location_hirerchy=[("Room", "Room 201")], properties_dict={"Contact": "*****@*****.**"}, lat=10, long=20, ) equipment_type = add_equipment_type( client=self.client, name="Tp-Link T1600G", category="Router", properties=[ PropertyDefinition( property_name="IP", property_kind=PropertyKind.string, default_raw_value=None, is_fixed=False, ) ], ports_dict={ "Port 1": "port type 1", "Port 2": "port type 1" }, position_list=[], ) router1 = add_equipment( client=self.client, name="TPLinkRouter1", equipment_type=equipment_type.name, location=location, properties_dict={"IP": "192.688.0.1"}, ) router2 = add_equipment( client=self.client, name="TPLinkRouter2", equipment_type=equipment_type.name, location=location, properties_dict={"IP": "192.688.0.2"}, ) router3 = add_equipment( client=self.client, name="TPLinkRouter3", equipment_type=equipment_type.name, location=location, properties_dict={"IP": "192.688.0.3"}, ) link1 = add_link( client=self.client, equipment_a=router1, port_name_a="Port 1", equipment_b=router2, port_name_b="Port 1", ) link2 = add_link( client=self.client, equipment_a=router2, port_name_a="Port 2", equipment_b=router3, port_name_b="Port 1", ) links = get_service_links(client=self.client, service_id=self.service.id) self.assertFalse(links) for link in [link1, link2]: add_service_link(client=self.client, service_id=self.service.id, link_id=link.id) links = get_service_links(client=self.client, service_id=self.service.id) self.assertEqual(len(links), 2)
def setUp(self) -> None: super().setUp() add_equipment_port_type( self.client, name="port type 1", properties=[ PropertyDefinition( property_name="port property", property_kind=PropertyKind.string, default_raw_value="port property value", is_fixed=False, ) ], link_properties=[ PropertyDefinition( property_name="link property", property_kind=PropertyKind.string, default_raw_value="link property value", is_fixed=False, ) ], ) add_location_type( client=self.client, name="City", properties=[ PropertyDefinition( property_name="Mayor", property_kind=PropertyKind.string, default_raw_value=None, is_fixed=False, ), PropertyDefinition( property_name="Contact", property_kind=PropertyKind.email, default_raw_value=None, is_fixed=False, ), ], ) self.location = add_location( client=self.client, location_hirerchy=[("City", "Lima")], properties_dict={ "Mayor": "Bernard King", "Contact": "*****@*****.**" }, lat=10, long=20, ) add_equipment_type( client=self.client, name="Tp-Link T1600G", category="Router", properties=[ PropertyDefinition( property_name="IP", property_kind=PropertyKind.string, default_raw_value=None, is_fixed=False, ) ], ports_dict={ "Port 1": "port type 1", "Port 2": "port type 1" }, position_list=[], ) self.equipment1 = add_equipment( client=self.client, name="TPLinkRouter1", equipment_type="Tp-Link T1600G", location=self.location, properties_dict={"IP": "192.688.0.1"}, ) self.equipment2 = add_equipment( client=self.client, name="TPLinkRouter2", equipment_type="Tp-Link T1600G", location=self.location, properties_dict={"IP": "192.688.0.2"}, ) self.equipment3 = add_equipment( client=self.client, name="TPLinkRouter3", equipment_type="Tp-Link T1600G", location=self.location, properties_dict={"IP": "192.688.0.2"}, ) self.link1 = add_link( client=self.client, equipment_a=self.equipment1, port_name_a="Port 1", equipment_b=self.equipment2, port_name_b="Port 1", )
def test_service_with_topology_created(self) -> None: add_equipment_port_type( self.client, name="port type 1", properties=[ PropertyDefinition( property_name="port property", property_kind=PropertyKind.string, default_value="port property value", is_fixed=False, ) ], link_properties=[ PropertyDefinition( property_name="link property", property_kind=PropertyKind.string, default_value="link property value", is_fixed=False, ) ], ) add_location_type( client=self.client, name="Room", properties=[("Contact", "email", None, True)], ) location = add_location( client=self.client, location_hirerchy=[("Room", "Room 201")], properties_dict={"Contact": "*****@*****.**"}, lat=10, long=20, ) add_equipment_type( client=self.client, name="Tp-Link T1600G", category="Router", properties=[("IP", "string", None, True)], ports_dict={ "Port 1": "port type 1", "Port 2": "port type 1" }, position_list=[], ) router1 = add_equipment( client=self.client, name="TPLinkRouter1", equipment_type="Tp-Link T1600G", location=location, properties_dict={"IP": "192.688.0.1"}, ) router2 = add_equipment( client=self.client, name="TPLinkRouter2", equipment_type="Tp-Link T1600G", location=location, properties_dict={"IP": "192.688.0.2"}, ) router3 = add_equipment( client=self.client, name="TPLinkRouter3", equipment_type="Tp-Link T1600G", location=location, properties_dict={"IP": "192.688.0.3"}, ) link1 = add_link( client=self.client, equipment_a=router1, port_name_a="Port 1", equipment_b=router2, port_name_b="Port 1", ) link2 = add_link( client=self.client, equipment_a=router2, port_name_a="Port 2", equipment_b=router3, port_name_b="Port 1", ) endpoint_port = get_port(client=self.client, equipment=router1, port_name="Port 2") for link in [link1, link2]: add_service_link(client=self.client, service_id=self.service.id, link_id=link.id) # TODO add service_endpoint_defintion api add_service_endpoint( client=self.client, service_id=self.service.id, equipment_id="1", endpoint_definition_id="1", ) ports = [e.port for e in self.service.endpoints] self.assertEqual([endpoint_port.id], [p.id if p is not None else None for p in ports]) self.assertEqual([link1.id, link2.id], [s.id for s in self.service.links])