diff --git a/test/workflows/site/test_create_site.py b/test/workflows/site/test_create_site.py index de4462bfee1b26b2168686514c8d77feb4dd2c39..c52c78cfb3e2ea5b5dfca1ac2c5040a18e98d631 100644 --- a/test/workflows/site/test_create_site.py +++ b/test/workflows/site/test_create_site.py @@ -1,4 +1,5 @@ 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