-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Constants and Paths #110
Constants and Paths #110
Conversation
…se pathlib instead.
@@ -1,3 +1,5 @@ | |||
"""Custom StaticNarrative Errors.""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Adding some extra documentation to this file.
err_msg = f"The Narrative {name} must be an integer > 0, not {number}" | ||
if number is None or not str(number).isdigit(): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Casting to int meant that if you put in values like 4.5
, they would get converted to 4
and the ref would appear valid, so I made this a bit more strict.
missing_parts = [part for part in part_name if part not in ref] | ||
if missing_parts: | ||
msg = "Missing keys required to create a NarrativeRef: " + ", ".join(missing_parts) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ensure that it isn't possible to do NarrativeRef({"wsid": 12345})
and get a valid NarrativeRef out
@@ -100,11 +100,11 @@ def mock_adapter(request: requests.Request) -> requests.Response: | |||
tag = params[0]["tag"] | |||
ids = params[0]["ids"] | |||
result = [_get_fake_nms_info(tag, ids)] | |||
response._content = bytes(json.dumps({"result": result, "version": "1.1"}), "UTF-8") | |||
response._content = bytes(json.dumps({"result": result, "version": "1.1"}), "UTF-8") # noqa: SLF001 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
prevent warnings when accessing response._content
def mock_auth_ok(user_id, token): | ||
pass | ||
|
||
|
||
def mock_auth_bad_token(token): | ||
pass | ||
|
||
|
||
def mock_ws_narrative_fetch(narrative_ref): | ||
pass | ||
|
||
|
||
def mock_ws_narrative_fetch_forbidden(narrative_ref): | ||
pass | ||
|
||
|
||
def mock_ws_info(ws_id): | ||
pass | ||
|
||
|
||
def mock_ws_info_unauth(ws_id): | ||
pass |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
none of these are used
# ensure there's a valid scratch dir and an assets dir | ||
mkdir -p "$current_dir"/../scratch/nginx | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no longer need this (forgot to delete it in a previous PR)
monkeypatch.setattr(Path, "is_absolute", starts_with_slash) | ||
monkeypatch.setattr(Path, "is_dir", starts_with_slash) | ||
monkeypatch.setattr(Path, "resolve", absolutify) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
replace the old mocks with these monkey patched versions (arguably a bit simpler?)
@@ -7,8 +7,6 @@ | |||
|
|||
from test.mocks import set_up_ok_mocks | |||
|
|||
USER_ID = "some_user" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
switching out USER_ID
for fake_user
from the conftest
USER_ID = "some_user" | ||
TOKEN = "some_token" # noqa: S105 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unused
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #110 +/- ##
===========================================
+ Coverage 70.67% 72.47% +1.79%
===========================================
Files 22 24 +2
Lines 1497 1544 +47
===========================================
+ Hits 1058 1119 +61
+ Misses 439 425 -14 ☔ View full report in Codecov by Sentry. |
yield mock_isdir | ||
def absolutify(self: Path) -> Path: | ||
"""Generate an absolute version of a path.""" | ||
return Path("/absolute") / self |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's pretty absolute!
Move remaining os.paths over to Path
Icon tests
Description of PR purpose/changes
Jira Ticket / Issue
N/A
Testing Instructions
Dev Checklist:
StaticNarrativeImpl.py
,StaticNarrativeServer.py
, andcompile_report.json
to this PR.