def test_product_sub_two(test_product_sub_block_two_db): product = ProductTable( name="ProductSubTwo", description="Test ProductSubTwo", product_type="Test", tag="Sub", status="active" ) product.product_blocks = [test_product_sub_block_two_db] db.session.add(product) db.session.commit() return product.product_id
def test_union_product(test_product_block_one_db): product = ProductTable(name="UnionProduct", description="Test Union Product", product_type="Test", tag="Union", status="active") product_block, product_sub_block = test_product_block_one_db product.product_blocks = [product_block, product_sub_block] db.session.add(product) db.session.commit() return product.product_id
def test_product_sub_list_union(test_product_block_with_list_union_db): product = ProductTable( name="ProductSubListUnion", description="Product with Union sub product_block", tag="UnionSub", product_type="Test", status="active", ) product_block, _, _ = test_product_block_with_list_union_db product.product_blocks = [product_block] db.session.add(product) db.session.commit() return product.product_id
def test_product_one(test_product_block_one_db): product = ProductTable( name="TestProductOne", description="Test ProductTable", product_type="Test", tag="TEST", status="active" ) fixed_input = FixedInputTable(name="test_fixed_input", value="False") product_block, _ = test_product_block_one_db product.fixed_inputs = [fixed_input] product.product_blocks = [product_block] db.session.add(product) db.session.commit() return product.product_id
def test_transform_json(self): nested_body = { "name": "MSP", "description": "MSP", "product_type": "Port", "tag": "Port", "status": "active", "fixed_inputs": [{ "name": "name", "value": "val" }, { "name": "name", "value": "val" }], "product_blocks": [{ "name": "name", "description": "desc", "resource_types": [{ "resource_type": "test" }] }], } nested_json_with_objects = transform_json(nested_body) product = ProductTable(**nested_json_with_objects) self.assertEqual( "test", product.product_blocks[0].resource_types[0].resource_type)
def seed(): ProductBlockTable.query.delete() resources = [ ResourceTypeTable(resource_type=IMS_CIRCUIT_ID, description="IMS Circuit Id") ] product_blocks = [ ProductBlockTable( product_block_id=PRODUCT_BLOCK_ID, name="Ethernet", description="desc", status="active", resource_types=resources, tag="tag", ) ] product = ProductTable( name="ProductTable", description="description", product_type="Port", tag="Port", status="active", product_blocks=product_blocks, fixed_inputs=[], ) db.session.add(product) db.session.commit()
def seed(): FixedInputTable.query.delete() fixed_inputs = [ FixedInputTable(name=PORT_SPEED, value=PORT_SPEED_VALUE), FixedInputTable(name=SERVICE_SPEED, value=SERVICE_SPEED_VALUE), ] product = ProductTable( product_id=PRODUCT_ID, name="ProductTable", description="description", product_type="Port", tag="SSP", status="active", fixed_inputs=fixed_inputs, ) subscription = SubscriptionTable( subscription_id=SUBSCRIPTION_ID, description="desc", status="active", insync=True, product=product, customer_id=uuid4(), ) db.session.add(product) db.session.add(subscription) db.session.commit()
def test_product_list_union(test_product_sub_block_one_db, test_product_sub_block_two_db): product = ProductTable( name="ProductListUnion", description="Test List Union Product", product_type="Test", tag="Union", status="active", ) fixed_input = FixedInputTable(name="test_fixed_input", value="False") product.fixed_inputs = [fixed_input] product.product_blocks = [test_product_sub_block_one_db, test_product_sub_block_two_db] db.session.add(product) db.session.commit() return product.product_id
def test_product_list_nested( test_product_block_list_nested_db_in_use_by_block): product = ProductTable(name="TestProductListNested", description="Test ProductTable", product_type="Test", tag="TEST", status="active") fixed_input = FixedInputTable(name="test_fixed_input", value="False") product_block = test_product_block_list_nested_db_in_use_by_block product.fixed_inputs = [fixed_input] product.product_blocks = [product_block] db.session.add(product) db.session.commit() return product.product_id
def generic_product_3(generic_product_block_2): p = ProductTable( name="Product 3", description="Generic Product Three", product_type="Generic", status="active", tag="GEN3", product_blocks=[generic_product_block_2], ) db.session.add(p) db.session.commit() return p
def generic_product_1(generic_product_block_1, generic_product_block_2): workflow = WorkflowTable.query.filter( WorkflowTable.name == "modify_note").one() p = ProductTable( name="Product 1", description="Generic Product One", product_type="Generic", status="active", tag="GEN1", product_blocks=[generic_product_block_1, generic_product_block_2], workflows=[workflow], ) db.session.add(p) db.session.commit() return p
def lp_product(protection_type, product_id, speed="1000"): name = f"msp_ssp_{protection_type.lower()}" msp_ssp_fixed_inputs = [ FixedInputTable(name="protection_type", value=protection_type.capitalize()), FixedInputTable(name=SERVICE_SPEED, value=speed), FixedInputTable(name=CITY_TYPE, value="inner_city"), ] return ProductTable( product_id=product_id, name=f"name_{product_id}", description=name, product_type="LightPath", tag="LightPath", status="active", fixed_inputs=msp_ssp_fixed_inputs, )
def seed(): product = ProductTable( name="ProductTable", description="description", product_type="Port", tag="Port", status="active" ) subscription = SubscriptionTable( subscription_id=SUBSCRIPTION_ID, description="desc", status="active", insync=True, product=product, customer_id=uuid4(), customer_descriptions=[ SubscriptionCustomerDescriptionTable( id=SUBSCRIPTION_CUSTOMER_DESCRIPTION_ID, customer_id=CUSTOMER_ID, description="customer other alias" ) ], ) db.session.add(product) db.session.add(subscription) db.session.commit()
def seed(): ProductTable.query.delete() resources = [ ResourceTypeTable(resource_type=IMS_CIRCUIT_ID, description="IMS circuit Id"), ] product_blocks = [ ProductBlockTable(name="Ethernet", description="d", status="active", resource_types=resources) ] fixed_inputs = [ FixedInputTable(name=SERVICE_SPEED, value="1000"), FixedInputTable(name=CITY_TYPE, value="inner_city"), FixedInputTable(name="protection_type", value="Protected"), ] product = ProductTable( product_id=PRODUCT_ID, name="LightPath", description="descr", product_type="LightPath", tag="LightPath", status="active", product_blocks=product_blocks, fixed_inputs=fixed_inputs, ) msp_product = ProductTable( product_id=MSP_PRODUCT_ID, name="MSP", description="descr", product_type="Port", tag="Port", status="active", product_blocks=product_blocks, fixed_inputs=[ FixedInputTable(name=PORT_SPEED, value="1000"), FixedInputTable(name=DOMAIN, value="SURFNET7") ], ) msp_product_100G = ProductTable( name="MSP 1100G", description="descr", product_type="Port", tag="Port", status="active", product_blocks=product_blocks, fixed_inputs=[ FixedInputTable(name=PORT_SPEED, value="100000"), FixedInputTable(name="domain", value="SURFNET7"), ], ) product_no_workflow = ProductTable(product_id=uuid4(), name="P", description="P", product_type="Port", tag="P", status="active") port_subscription_id = ResourceTypeTable( resource_type=PORT_SUBSCRIPTION_ID, description="Port Subscription Id") values = [ SubscriptionInstanceValueTable(resource_type=port_subscription_id, value=str(depends_on_SUBSCRIPTION_ID)) ] subscription = SubscriptionTable( subscription_id=SUBSCRIPTION_ID, description="desc", status="active", insync=True, product=product, customer_id=uuid4(), instances=[ SubscriptionInstanceTable(product_block=product_blocks[0], values=values) ], ) depends_on_subscription = SubscriptionTable( subscription_id=depends_on_SUBSCRIPTION_ID, description="desc", status="active", insync=True, product=msp_product, customer_id=uuid4(), ) def lp_product(protection_type, product_id, speed="1000"): name = f"msp_ssp_{protection_type.lower()}" msp_ssp_fixed_inputs = [ FixedInputTable(name="protection_type", value=protection_type.capitalize()), FixedInputTable(name=SERVICE_SPEED, value=speed), FixedInputTable(name=CITY_TYPE, value="inner_city"), ] return ProductTable( product_id=product_id, name=f"name_{product_id}", description=name, product_type="LightPath", tag="LightPath", status="active", fixed_inputs=msp_ssp_fixed_inputs, ) db.session.add(product) db.session.add(msp_product) db.session.add(msp_product_100G) db.session.add(lp_product("protected", uuid4(), speed="10000")) db.session.add(lp_product("protected", uuid4(), speed="750")) db.session.add(lp_product("redundant", REDUNDANT_MSP_SSP_ID)) db.session.add(lp_product("protected", PROTECTED_MSP_SSP_ID, speed="250")) db.session.add(lp_product("unprotected", UNPROTECTED_MSP_SSP_ID)) db.session.add(subscription) db.session.add(depends_on_subscription) db.session.add(product_no_workflow) db.session.commit()
def seed(): # These resource types are special resources = [ ResourceTypeTable(resource_type=IMS_CIRCUIT_ID, description="Desc"), ResourceTypeTable(resource_type=PORT_SUBSCRIPTION_ID, description="Desc"), ] product_blocks = [ ProductBlockTable(name="ProductBlockA", description="description a", status="active", resource_types=resources) ] fixed_inputs = [FixedInputTable(name="product_type", value="MSP100G")] # Wf needs to exist in code and needs to be a legacy wf with mapping lp_product = ProductTable( name="LightpathProduct", description="Service product that lives on ports", product_type="LightPath", tag= "LightPath", # This is special since in_use_by/depends_on subscription code handles specific tags status="active", product_blocks=product_blocks, fixed_inputs=fixed_inputs, ) port_a_product = ProductTable( product_id=PRODUCT_ID, name="PortAProduct", description="Port A description", product_type="Port", tag= "SP", # This is special since in_use_by/depends_on subscription code handles specific tags status="active", product_blocks=product_blocks, fixed_inputs=fixed_inputs, ) port_b_product = ProductTable( name="PortBProduct", description="Port B description", product_type="Port", tag="PORTB", status="active", product_blocks=product_blocks, fixed_inputs=fixed_inputs, ) # Special resource type handled by get subscription by ipam prefix endpoint ip_prefix_resources = [ ResourceTypeTable(resource_type=IPAM_PREFIX_ID, description="Prefix id") ] ip_prefix_product_blocks = [ ProductBlockTable(name="ProductBlockB", description="description b", status="active", resource_types=ip_prefix_resources) ] ip_prefix_product = ProductTable( name="IPPrefixProduct", description="ProductTable that is used by service product", product_type="IP_PREFIX", tag="IP_PREFIX", status="active", product_blocks=ip_prefix_product_blocks, ) ip_prefix_subscription = SubscriptionTable( subscription_id=IP_PREFIX_SUBSCRIPTION_ID, description="desc", status="active", insync=True, product=ip_prefix_product, customer_id=CUSTOMER_ID, instances=[ SubscriptionInstanceTable( product_block=ip_prefix_product_blocks[0], values=[ SubscriptionInstanceValueTable( resource_type=ip_prefix_resources[0], value="26") ], ) ], ) port_a_subscription = SubscriptionTable( subscription_id=PORT_A_SUBSCRIPTION_ID, description="desc", status="initial", insync=True, product=port_a_product, customer_id=CUSTOMER_ID, instances=[ SubscriptionInstanceTable( product_block=product_blocks[0], values=[ SubscriptionInstanceValueTable(resource_type=resources[0], value="54321") ], ) ], ) provisioning_port_a_subscription = SubscriptionTable( subscription_id=PROVISIONING_PORT_A_SUBSCRIPTION_ID, description="desc", status="provisioning", insync=False, product=port_a_product, customer_id=CUSTOMER_ID, instances=[ SubscriptionInstanceTable( product_block=product_blocks[0], values=[ SubscriptionInstanceValueTable(resource_type=resources[0], value="12345") ], ) ], ) ssp_subscription = SubscriptionTable( subscription_id=SSP_SUBSCRIPTION_ID, description="desc", status="active", insync=True, product=port_b_product, customer_id=CUSTOMER_ID, instances=[ SubscriptionInstanceTable( product_block=product_blocks[0], values=[ SubscriptionInstanceValueTable(resource_type=resources[0], value="54321") ], ) ], ) lp_subscription_instance_values_ssp = [ SubscriptionInstanceValueTable(resource_type=resources[0], value="54321"), SubscriptionInstanceValueTable(resource_type=resources[1], value=str(PORT_A_SUBSCRIPTION_ID)), ] lp_subscription_instance_ssp = SubscriptionInstanceTable( product_block=product_blocks[0], values=lp_subscription_instance_values_ssp) lp_subscription_instance_values_msp = [ SubscriptionInstanceValueTable(resource_type=resources[0], value="54321"), SubscriptionInstanceValueTable(resource_type=resources[1], value=str(SSP_SUBSCRIPTION_ID)), ] lp_subscription_instance_msp = SubscriptionInstanceTable( product_block=product_blocks[0], values=lp_subscription_instance_values_msp) lp_subscription = SubscriptionTable( subscription_id=SERVICE_SUBSCRIPTION_ID, description="desc", status="active", insync=True, product=lp_product, customer_id=CUSTOMER_ID, instances=[lp_subscription_instance_ssp, lp_subscription_instance_msp], ) invalid_subscription = SubscriptionTable( subscription_id=INVALID_SUBSCRIPTION_ID, description="desc", status="active", insync=True, product=port_a_product, customer_id=CUSTOMER_ID, instances=[], ) invalid_tagged_product = ProductTable( product_id=str(uuid4()), name="INVALID_PRODUCT", description="invalid descr", product_type="Port", tag="NEWMSP", status="active", product_blocks=product_blocks, fixed_inputs=fixed_inputs, ) invalid_tagged_subscription = SubscriptionTable( subscription_id=INVALID_PORT_SUBSCRIPTION_ID, description="desc", status="active", insync=False, product=invalid_tagged_product, customer_id=CUSTOMER_ID, instances=[ SubscriptionInstanceTable( product_block=product_blocks[0], values=[ SubscriptionInstanceValueTable(resource_type=resources[0], value="54321") ], ) ], ) db.session.add(port_a_product) db.session.add(ip_prefix_product) db.session.add(ip_prefix_subscription) db.session.add(invalid_tagged_product) db.session.add(port_b_product) db.session.add(lp_product) db.session.add(port_a_subscription) db.session.add(provisioning_port_a_subscription) db.session.add(ssp_subscription) db.session.add(lp_subscription) db.session.add(invalid_subscription) db.session.add(invalid_tagged_subscription) db.session.commit() RELATION_RESOURCE_TYPES.extend([ PORT_SUBSCRIPTION_ID, IP_PREFIX_SUBSCRIPTION_ID, INTERNETPINNEN_PREFIX_SUBSCRIPTION_ID, PARENT_IP_PREFIX_SUBSCRIPTION_ID, PEER_GROUP_SUBSCRIPTION_ID, ]) return ip_prefix_product