def test_config_defaults(self) -> None: """Test default retries.""" config = ShipEngineConfig(dict(api_key="baz_sim")) assert config.retries == 1 assert config.page_size == 50 assert config.timeout == 5 assert config.base_uri is BaseURL.SHIPENGINE_RPC_URL.value
def complete_valid_config() -> ShipEngineConfig: """ Return a `ShipEngineConfig` object that has valid custom values passed in. """ return ShipEngineConfig( dict( api_key=Constants.STUB_API_KEY.value, page_size=50, retries=2, timeout=10, ))
def set_config_retries(retries: int) -> ShipEngineConfig: """ Return a ShipEngineConfig object with the set retries and API Key, where the rest of the configuration values are the default values. :param int retries: The retries to be passed into the `ShipEngineConfig` object. :returns: :class:`ShipEngineConfig`: Global configuration object for the ShipEngine SDK. :raises: :class:`InvalidFieldValueError`: If invalid value is passed into `ShipEngineConfig` object at instantiation. """ return ShipEngineConfig(dict(api_key="baz_sim", retries=retries))
def set_config_timeout(timeout: int) -> ShipEngineConfig: """ Return an error from an invalid timeout value being passed in or returns the successfully created `ShipEngineConfig` object if valid configuration values are passed in. :param int timeout: The timeout to be passed into the `ShipEngineConfig` object. :returns: :class:`ShipEngineConfig`: Global configuration object for the ShipEngine SDK. :raises: :class:`InvalidFieldValueError`: If invalid value is passed into `ShipEngineConfig` object at instantiation. """ return ShipEngineConfig(dict(api_key="baz_sim", timeout=timeout))
def stub_shipengine_config() -> ShipEngineConfig: """Return a valid test ShipEngineConfig object.""" return ShipEngineConfig(config=stub_config())
def config_with_whitespace_in_api_key() -> ShipEngineConfig: """Return an error from whitespace in API Key.""" return ShipEngineConfig(dict(api_key=" "))
def config_with_empty_api_key() -> ShipEngineConfig: """Return an error from empty API Key.""" return ShipEngineConfig(dict(api_key=""))
def test_to_json_method(self) -> None: """Test the to_json convenience method.""" config = ShipEngineConfig(stub_config()) j = config.to_json() assert type(j) is str
def test_to_dict_method(self) -> None: """Test the to_dict convenience method.""" config = ShipEngineConfig(stub_config()) d = config.to_dict() assert type(d) is dict
def config_with_no_api_key() -> ShipEngineConfig: """Return an error from no API Key.""" return ShipEngineConfig(dict(retries=2))