Skip to content
Snippets Groups Projects
Commit cf7fb0ae authored by Karel van Klink's avatar Karel van Klink :smiley_cat: Committed by Neda Moeini
Browse files

restructure customer selector and ISO calculation

parent b4ee6ab8
Branches
Tags
1 merge request!83Clean up the repo a bit, and add some unit tests
from typing import Any
from pydantic_forms.validators import Choice
class CustomerNotFoundError(Exception):
"""Exception raised when a customer is not found."""
......@@ -22,3 +24,11 @@ def get_customer_by_name(name: str) -> dict[str, Any]:
return customer
raise CustomerNotFoundError(f"Customer {name} not found")
def customer_selector() -> Choice:
customers = {}
for customer in all_customers():
customers[customer["id"]] = customer["name"]
return Choice("Select a customer", zip(customers.keys(), customers.items())) # type: ignore[arg-type]
File moved
......@@ -14,6 +14,7 @@ from gso.products.product_types.iptrunk import IptrunkInactive, IptrunkProvision
from gso.products.product_types.router import Router
from gso.services import infoblox, provisioning_proxy, subscriptions
from gso.services.netbox_client import NetboxClient
from gso.services.crm import customer_selector
from gso.services.provisioning_proxy import pp_interaction
from gso.workflows.utils import (
available_interfaces_choices,
......@@ -22,6 +23,7 @@ from gso.workflows.utils import (
get_router_vendor,
validate_router_in_netbox,
)
from gso.utils.types.phy_port import PhyPortCapacity
def initial_input_form_generator(product_name: str) -> FormGenerator:
......
......@@ -10,6 +10,7 @@ from orchestrator.workflow import StepList, conditional, done, init, step, workf
from orchestrator.workflows.steps import resync, set_status, store_process_subscription
from orchestrator.workflows.utils import wrap_create_initial_input_form
from pydantic import validator
from services.crm import customer_selector
from gso.products.product_blocks.router import RouterRole, RouterVendor, generate_fqdn
from gso.products.product_types.router import RouterInactive, RouterProvisioning
......@@ -18,7 +19,7 @@ from gso.services import infoblox, provisioning_proxy, subscriptions
from gso.services.netbox_client import NetboxClient
from gso.services.provisioning_proxy import pp_interaction
from gso.utils.types.ip_port import PortNumber
from gso.workflows.utils import customer_selector, iso_from_ipv4
from utils.functions import iso_from_ipv4
def _site_selector() -> Choice:
......
......@@ -12,8 +12,8 @@ from pydantic import validator
from gso.products.product_blocks import site as site_pb
from gso.products.product_types import site
from gso.services.crm import customer_selector
from gso.utils.types.snmp import LatitudeCoordinate, LongitudeCoordinate
from gso.workflows.utils import customer_selector
def initial_input_form_generator(product_name: str) -> FormGenerator: # noqa: C901
......
......@@ -5,10 +5,9 @@ import pytest
from gso.products import Iptrunk, ProductType
from gso.products.product_blocks.iptrunk import IptrunkType
from gso.services.crm import get_customer_by_name
from gso.services.crm import customer_selector, get_customer_by_name
from gso.services.subscriptions import get_product_id_by_name
from gso.utils.types.phy_port import PhyPortCapacity
from gso.workflows.utils import customer_selector
from test.workflows import (
assert_aborted,
assert_complete,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment