diff --git a/gso/products/product_blocks/router.py b/gso/products/product_blocks/router.py index 03be23a9b4f9ee38f1f1d5238d0db6a441871458..77b8eaf3da1ea89b09880c00ab5d7659cfb5d67b 100644 --- a/gso/products/product_blocks/router.py +++ b/gso/products/product_blocks/router.py @@ -13,20 +13,15 @@ class RouterVendor(strEnum): """Enumerator for the different product vendors that are supported.""" JUNIPER = "juniper" - """Juniper routers.""" NOKIA = "nokia" - """Nokia routers.""" class RouterRole(strEnum): """Enumerator for the different types of routers.""" P = "p" - """P router.""" PE = "pe" - """PE router.""" AMT = "amt" - """AMT router.""" class PortNumber(ConstrainedInt): @@ -36,9 +31,7 @@ class PortNumber(ConstrainedInt): """ gt = 0 - """The lower bound of the valid port number range.""" le = 49151 - """As mentioned earlier, the ephemeral port range should not be chosen, and is therefore not available.""" class RouterBlockInactive( diff --git a/gso/services/provisioning_proxy.py b/gso/services/provisioning_proxy.py index af0902a156220f13a35b5aed3b87984ee773fc16..1ca12a0b95d8a03da406491f2c4fbcf1af4bc5ca 100644 --- a/gso/services/provisioning_proxy.py +++ b/gso/services/provisioning_proxy.py @@ -33,11 +33,8 @@ class CUDOperation(strEnum): """ POST = "POST" - """Creation is done with a `POST` request.""" PUT = "PUT" - """Updating is done with a `PUT` request.""" DELETE = "DELETE" - """Removal is done with a `DELETE` request.""" def _send_request(endpoint: str, parameters: dict, process_id: UUIDstr, operation: CUDOperation) -> None: diff --git a/gso/workflows/site/create_site.py b/gso/workflows/site/create_site.py index b16cf5b42eaf384f0cd9e960eb566437f11a5d36..555c3574f3cb7364802773463b78fa427bdaf165 100644 --- a/gso/workflows/site/create_site.py +++ b/gso/workflows/site/create_site.py @@ -16,7 +16,7 @@ from gso.products.product_types import site from gso.workflows.utils import customer_selector -def initial_input_form_generator(product_name: str) -> FormGenerator: +def initial_input_form_generator(product_name: str) -> FormGenerator: # noqa: C901 class CreateSiteForm(FormPage): class Config: title = product_name @@ -37,24 +37,26 @@ def initial_input_form_generator(product_name: str) -> FormGenerator: def country_code_must_exist(cls, country_code: str) -> str | NoReturn: try: _ = pycountry.countries.lookup(country_code) - # Lookup succeeded, the country code is valid. return country_code except LookupError: - # Lookup failed, the country code is not valid. raise ValueError("Invalid or non-existent country code, it must be in ISO 3166-1 alpha-2 format.") @validator("site_latitude", allow_reuse=True) def latitude_must_be_valid(cls, latitude: str) -> str | NoReturn: - if -90 <= float(latitude) <= 90: - # Check whether the value is a valid degree of latitude. + def _is_valid_latitude(degree: float) -> bool: + return -90 <= degree <= 90 + + if _is_valid_latitude(float(latitude)): return latitude raise ValueError("Entered latitude is not a valid value, must be between -90.0° and 90.0°.") @validator("site_longitude", allow_reuse=True) def longitude_must_be_valid(cls, longitude: str) -> str | NoReturn: - if -180 <= float(longitude) <= 180: - # Check whether the value is a valid degree of longitude. + def _is_valid_longitude(degree: float) -> bool: + return -180 <= degree <= 180 + + if _is_valid_longitude(float(longitude)): return longitude raise ValueError("Entered longitude is not a valid value, must be between -180.0° and 180.0°.") @@ -63,7 +65,6 @@ def initial_input_form_generator(product_name: str) -> FormGenerator: def ts_address_must_be_valid(cls, ts_address: str) -> str | NoReturn: try: ipaddress.ip_address(ts_address) - # The address is valid return ts_address except ValueError: raise ValueError("Enter a valid IPv4 or v6 address.") diff --git a/requirements.txt b/requirements.txt index ce4bdef0f15c76aeb10584377161dd9555c9cf74..b18fd748b0c07b05e824c613b98bd6ab7b29380f 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,6 +1,7 @@ orchestrator-core==1.2.2 pydantic~=1.10.9 requests +pycountry pytest faker