Skip to content

Commit

Permalink
fix test that allow new_client to be created without a RCRAInfo envir…
Browse files Browse the repository at this point in the history
…onment
  • Loading branch information
dpgraham4401 committed Jul 16, 2024
1 parent 1ab534d commit 42cc2e8
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 15 deletions.
24 changes: 13 additions & 11 deletions emanifest-py/src/emanifest/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from typing import (
Generic,
List,
Literal,
Optional,
TypeVar,
)
Expand All @@ -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/"
Expand Down Expand Up @@ -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,
Expand Down
6 changes: 2 additions & 4 deletions emanifest-py/src/emanifest/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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):
Expand Down

0 comments on commit 42cc2e8

Please sign in to comment.