Skip to content
Snippets Groups Projects
Commit 74019763 authored by Karel van Klink's avatar Karel van Klink :smiley_cat:
Browse files

Move unit test workflow inputs to pytest fixtures

parent 4cfe6542
No related branches found
No related tags found
1 merge request!213Add unit tests for imported products
Pipeline #86762 passed
......@@ -11,9 +11,9 @@ from test.workflows import (
)
@pytest.mark.workflow()
def test_create_imported_iptrunk_success(faker, nokia_router_subscription_factory):
input_data = {
@pytest.fixture()
def workflow_input_data(faker, nokia_router_subscription_factory):
return {
"partner": "GEANT",
"geant_s_sid": faker.geant_sid(),
"iptrunk_description": faker.sentence(),
......@@ -36,7 +36,11 @@ def test_create_imported_iptrunk_success(faker, nokia_router_subscription_factor
"iptrunk_ipv4_network": faker.ipv4_network(max_subnet=31),
"iptrunk_ipv6_network": faker.ipv6_network(max_subnet=126),
}
result, _, _ = run_workflow("create_imported_iptrunk", [input_data])
@pytest.mark.workflow()
def test_create_imported_iptrunk_success(workflow_input_data):
result, _, _ = run_workflow("create_imported_iptrunk", [workflow_input_data])
state = extract_state(result)
imported_router = ImportedIptrunk.from_subscription(state["subscription_id"])
......
......@@ -11,9 +11,9 @@ from test.workflows import (
)
@pytest.mark.workflow()
def test_create_imported_office_router_success(faker, site_subscription_factory):
input_data = {
@pytest.fixture()
def workflow_input_data(faker, site_subscription_factory):
return {
"partner": "GEANT",
"office_router_site": Site.from_subscription(site_subscription_factory()).site.site_name,
"office_router_fqdn": faker.domain_name(levels=4),
......@@ -22,7 +22,10 @@ def test_create_imported_office_router_success(faker, site_subscription_factory)
"office_router_lo_ipv6_address": faker.ipv6(),
}
result, _, _ = run_workflow("create_imported_office_router", [input_data])
@pytest.mark.workflow()
def test_create_imported_office_router_success(workflow_input_data):
result, _, _ = run_workflow("create_imported_office_router", [workflow_input_data])
state = extract_state(result)
imported_office_router = ImportedOfficeRouter.from_subscription(state["subscription_id"])
......
......@@ -6,24 +6,26 @@ from gso.products.product_types.site import ImportedSite
from test.workflows import assert_complete, extract_state, run_workflow
@pytest.fixture()
def workflow_input_data(faker):
return {
"site_name": faker.site_name(),
"site_city": faker.city(),
"site_country": faker.country(),
"site_country_code": faker.country_code(),
"site_latitude": "-74.0060",
"site_longitude": "40.7128",
"site_bgp_community_id": faker.pyint(),
"site_internal_id": faker.pyint(),
"site_tier": SiteTier.TIER1,
"site_ts_address": faker.ipv4(),
"partner": "GEANT",
}
@pytest.mark.workflow()
def test_create_imported_site_success(faker):
initial_created_site_data = [
{
"site_name": faker.site_name(),
"site_city": faker.city(),
"site_country": faker.country(),
"site_country_code": faker.country_code(),
"site_latitude": "-74.0060",
"site_longitude": "40.7128",
"site_bgp_community_id": faker.pyint(),
"site_internal_id": faker.pyint(),
"site_tier": SiteTier.TIER1,
"site_ts_address": faker.ipv4(),
"partner": "GEANT",
}
]
result, _, _ = run_workflow("create_imported_site", initial_created_site_data)
def test_create_imported_site_success(workflow_input_data):
result, _, _ = run_workflow("create_imported_site", [workflow_input_data])
assert_complete(result)
state = extract_state(result)
......
......@@ -11,9 +11,9 @@ from test.workflows import (
)
@pytest.mark.workflow()
def test_create_imported_office_router_success(faker, site_subscription_factory):
input_data = {
@pytest.fixture()
def workflow_input_data(faker, site_subscription_factory):
return {
"partner": "GEANT",
"hostname": faker.domain_word(),
"super_pop_switch_site": Site.from_subscription(site_subscription_factory()).site.site_name,
......@@ -21,7 +21,10 @@ def test_create_imported_office_router_success(faker, site_subscription_factory)
"super_pop_switch_mgmt_ipv4_address": faker.ipv4(),
}
result, _, _ = run_workflow("create_imported_super_pop_switch", [input_data])
@pytest.mark.workflow()
def test_create_imported_office_router_success(workflow_input_data):
result, _, _ = run_workflow("create_imported_super_pop_switch", [workflow_input_data])
state = extract_state(result)
imported_super_pop_switch = ImportedSuperPopSwitch.from_subscription(state["subscription_id"])
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment