From 42cc2e8f3b8adad1bd78cf6f12207408395dacb3 Mon Sep 17 00:00:00 2001 From: David Graham Date: Tue, 16 Jul 2024 17:06:53 -0400 Subject: [PATCH] fix test that allow new_client to be created without a RCRAInfo environment --- emanifest-py/src/emanifest/client.py | 24 ++++++++++++----------- emanifest-py/src/emanifest/test_client.py | 6 ++---- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/emanifest-py/src/emanifest/client.py b/emanifest-py/src/emanifest/client.py index 913f7f65..f55aff9f 100644 --- a/emanifest-py/src/emanifest/client.py +++ b/emanifest-py/src/emanifest/client.py @@ -10,6 +10,7 @@ from typing import ( Generic, List, + Literal, Optional, TypeVar, ) @@ -18,25 +19,23 @@ from requests_toolbelt.multipart import decoder, encoder # type: ignore from typing_extensions import Unpack -from emanifest import ( - PortOfEntry, - RcraCodeDescription, - RcraSite, - SiteExistsResponse, - SiteSearchArgs, - UserSearchArgs, - UserSearchResponse, -) -from emanifest.types import ( +from .types import ( AgencyCode, CorrectionRevertResponse, CorrectionVersionSearchArgs, ManifestOperationResponse, ManifestSignatureResponse, MtnSearchArgs, + PortOfEntry, + RcraCodeDescription, + RcraSite, SearchBillArgs, SignManifestArgs, + SiteExistsResponse, + SiteSearchArgs, UILinkArgs, + UserSearchArgs, + UserSearchResponse, ) RCRAINFO_PROD = "https://rcrainfo.epa.gov/rcrainfoprod/rest/api/" @@ -908,8 +907,11 @@ def _parse_url(base_url: str | None) -> str: return base_url +BaseUrls = Literal["prod", "preprod"] + + def new_client( - base_url: str | None = None, + base_url: BaseUrls | str | None = None, api_id: str | None = None, api_key: str | None = None, auto_renew: bool = False, diff --git a/emanifest-py/src/emanifest/test_client.py b/emanifest-py/src/emanifest/test_client.py index 50c1bfcd..121b5667 100644 --- a/emanifest-py/src/emanifest/test_client.py +++ b/emanifest-py/src/emanifest/test_client.py @@ -84,7 +84,7 @@ class MyClass(RcrainfoClient): def retrieve_id(self, api_id=None) -> str: """ This example method on our test subclass shows we can override the set_api_id method - if the user wants to get their api ID from somewhere else (e.g., a service, or database) + if the user wants to get their api ID from somewhere else (e.g., a service, database) """ returned_string = ( self.mock_api_id_from_external @@ -216,13 +216,11 @@ class TestNewClientConstructor: def test_returns_instance_of_client(self): rcrainfo = new_client("prod") preprod = new_client("preprod") - blank = new_client() assert isinstance(rcrainfo, RcrainfoClient) assert isinstance(preprod, RcrainfoClient) - assert isinstance(blank, RcrainfoClient) def test_new_client_defaults_to_preprod(self): - rcrainfo = new_client() + rcrainfo = new_client("preprod") assert rcrainfo.base_url == RCRAINFO_PREPROD def test_no_base_url_raises_exception(self):