Skip to content

Add test and coverage#5

Open
renceInbox wants to merge 8 commits intomainfrom
enhancement/add-test-and-coverage
Open

Add test and coverage#5
renceInbox wants to merge 8 commits intomainfrom
enhancement/add-test-and-coverage

Conversation

@renceInbox
Copy link
Contributor

No description provided.

@renceInbox renceInbox self-assigned this Nov 21, 2023
@renceInbox renceInbox force-pushed the enhancement/add-test-and-coverage branch 2 times, most recently from a36010c to dd789cf Compare November 21, 2023 06:24
@renceInbox renceInbox force-pushed the enhancement/add-test-and-coverage branch from dd789cf to 4bd0ee7 Compare November 21, 2023 06:27
pre-commit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@renceInbox can we use the latest actions/checkout, which is v3 here? It is used further down already.

if response.status_code != 200:
raise OpenSPPClientException(f"Unsuccessful login. Response data: {data}")
data = response.json()
result = response.json().get("result", "")

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't this check redundant as the code is already checking response.status_code and raising an exception if it is != 200?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@renceInbox I see that the test test_unsuccessful_authentication is checking the contents of the JSON response and even if the result is 200, the contents of the JSON seems to indicate that there is still an error. Can you please remind me what the source of this error could be?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @kneckinator , this could happen in login. If we provide an invalid username and password the response will be 200 but the result will say 401.

data = response.json()
if not response.status_code == 200:
if response.status_code != 200:
raise OpenSPPClientException(f"Unsuccessful login. Response data: {data}")

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe that the data in the exception should be response.json(). As written now, it will print the request data.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @kneckinator , I fixed the variable names to avoid this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants