Skip to content

Commit

Permalink
Use latest version of prosper_shared
Browse files Browse the repository at this point in the history
  • Loading branch information
grahamtt committed Jun 29, 2024
1 parent 31942e1 commit f07cd9d
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 73 deletions.
16 changes: 0 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -186,22 +186,6 @@ prosper-api.credentials.username:
description: Your Prosper username
optional: false
type: str
prosper-shared.serde.parse-dates:
default: true
description: Date values represented as strings should be parsed into `date` and `datetime` objects.
Supports ISO-8601-compliant date strings.
optional: false
type: bool
prosper-shared.serde.parse-enums:
default: true
description: Enum values represented as strings should be parsed into their respective types.
optional: false
type: bool
prosper-shared.serde.use-decimals:
default: true
description: Floating point values should be parsed as decimals instead of floats.
optional: false
type: bool
```
## Feedback
Expand Down
10 changes: 5 additions & 5 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 0 additions & 5 deletions prosper_api/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

import requests
from backoff import expo, on_exception
from prosper_shared import serde
from prosper_shared.omni_config import Config
from ratelimit import RateLimitException, limits

Expand Down Expand Up @@ -102,10 +101,6 @@ def __init__(
if auth_token_manager is None:
auth_token_manager = AuthTokenManager(config)

self.parse_decimals = config.get_as_bool(serde._USE_DECIMALS_CONFIG_PATH)
if not self.parse_decimals:
self._warn_about_floats()

self._config = config
self._auth_token_manager = auth_token_manager

Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ repository = "https://github.com/grahamtt/prosper-api"
python = ">=3.9,<4.0"
backoff = "^2.2.1"
dpath = "^2.1.6"
prosper-shared = "^0.2.9"
prosper-shared = "^0.7.0"
pydantic = "^2.7.4"
ratelimit = "^2.2.1"
requests = "^2.31.0"
Expand Down
46 changes: 0 additions & 46 deletions tests/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -713,38 +713,32 @@ def test_list_loans(self, client_for_api_tests):
"parse_decimals_config",
"input_val",
"return_val",
"expect_warning",
],
[
(
True,
None,
'{"p1": "v1", "p2": 2.0}',
False,
),
(
True,
{"param1": "value1", "param2": 2.0},
'{"p1": "v1", "p2": 2.0}',
True,
),
(
False,
{"param1": "value1", "param2": 2.0},
'{"p1": "v1", "p2": 2.0}',
True,
),
(
True,
{"param1": "value1", "param2": Decimal(2.0)},
'{"p1": "v1", "p2": 2.0}',
False,
),
(
False,
{"param1": "value1", "param2": Decimal(2.0)},
'{"p1": "v1", "p2": 2.0}',
True,
),
],
)
Expand All @@ -757,7 +751,6 @@ def test_do_get(
parse_decimals_config: bool,
input_val: dict,
return_val: str,
expect_warning: bool,
):
auth_token_manager_mock.return_value.get_token.return_value = "auth_token"
request_mock.return_value.text = return_val
Expand All @@ -778,60 +771,38 @@ def test_do_get(
"Accept": "application/json",
},
)
if expect_warning:
assert [
r
for r in caplog.records
if r.message.startswith(
"WARNING: Floating point numbers are not recommended for representing currency"
)
]
else:
assert not [
r
for r in caplog.records
if r.message.startswith(
"WARNING: Floating point numbers are not recommended for representing currency"
)
]

@pytest.mark.parametrize(
[
"parse_decimals_config",
"input_val",
"return_val",
"expect_warning",
],
[
(
True,
None,
'{"p1": "v1", "p2": 2.0}',
False,
),
(
True,
{"param1": "value1", "param2": 2.0},
'{"p1": "v1", "p2": 2.0}',
True,
),
(
False,
{"param1": "value1", "param2": 2.0},
'{"p1": "v1", "p2": 2.0}',
True,
),
(
True,
{"param1": "value1", "param2": Decimal(2.0)},
'{"p1": "v1", "p2": 2.0}',
False,
),
(
False,
{"param1": "value1", "param2": Decimal(2.0)},
'{"p1": "v1", "p2": 2.0}',
True,
),
],
)
Expand All @@ -844,7 +815,6 @@ def test_do_post(
parse_decimals_config: bool,
input_val: dict,
return_val: str,
expect_warning: bool,
):
auth_token_manager_mock.return_value.get_token.return_value = "auth_token"
request_mock.return_value.text = return_val
Expand All @@ -865,22 +835,6 @@ def test_do_post(
"Accept": "application/json",
},
)
if expect_warning:
assert [
r
for r in caplog.records
if r.message.startswith(
"WARNING: Floating point numbers are not recommended for representing currency"
)
]
else:
assert not [
r
for r in caplog.records
if r.message.startswith(
"WARNING: Floating point numbers are not recommended for representing currency"
)
]

def test_bool_val_when_invalid(self):
with pytest.raises(ValueError):
Expand Down

0 comments on commit f07cd9d

Please sign in to comment.