Skip to content
Snippets Groups Projects
Commit 6af0e5cb authored by Hakan Calim's avatar Hakan Calim Committed by Neda Moeini
Browse files

NAT-328: add test for checking invalid site name

parent f3305097
No related branches found
No related tags found
1 merge request!97Feature/nat 328 site names should be validated
import pytest
from pydantic_forms.exceptions import FormValidationError
from gso.products import ProductType
from gso.products.product_blocks.site import SiteTier
......@@ -38,3 +39,35 @@ def test_create_site(responses, faker):
subscription.description
== f"Site in {initial_site_data[1]['site_city']}, {initial_site_data[1]['site_country']}"
)
@pytest.mark.workflow
def test_site_name_is_incorrect(responses, faker):
"""The site name is a string with 3 upper case letter and one digit.
Like: AMS, LON, LON1...LON 9.
This test checks a invalid string for site name.
The validation should throw an exception in case of a invalid string.
"""
invalid_site_name = "AMST10"
expected_exception_msg = f"Enter a valid site name similar looks like AMS, AMS1or LON9. Get: {invalid_site_name}"
product_id = get_product_id_by_name(ProductType.SITE)
initial_site_data = [
{"product": product_id},
{
"site_name": invalid_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(),
"customer": get_customer_by_name("GÉANT")["id"],
},
]
with pytest.raises(FormValidationError) as test_exception:
result, process, step_log = run_workflow("create_site", initial_site_data)
assert str(test_exception.value) == expected_exception_msg
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