Skip to content
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

Add test for attempting to get tasks without a valid access token #14

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

benjaminshim
Copy link
Contributor

@benjaminshim benjaminshim commented May 12, 2024

Description

Added a new test to ensure that the /api/tasks endpoint correctly handles requests that are missing the required access token. The test checks that the response status code is 400 BAD REQUEST and that the error message explicitly states that an access token is required.

Also resolved linting errors within the following files:

  • comments.py
  • tasks.py
  • main.py
  • test_main.py

Relevant Issue

No relevant issues, just a general testing improvement.

Tests

The new test, along with previously existing ones, was run locally and passed successfully.

@benjaminshim benjaminshim requested a review from zhangdzh May 12, 2024 19:20
@benjaminshim benjaminshim self-assigned this May 12, 2024
Copy link
Collaborator

@zhangdzh zhangdzh left a comment

Choose a reason for hiding this comment

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

Separate Tasks error from Comments error so they are not dependent

def test_get_tasks_without_token():
response = TEST_CLIENT.get(TASKS)
assert response.status_code == HTTPStatus.BAD_REQUEST
assert TOKEN_ERROR_MESSAGE in response.get_json()['error']
Copy link
Collaborator

Choose a reason for hiding this comment

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

This assumes both comments and tasks components will consistently use the same error message

@ryankawahara ryankawahara self-requested a review May 12, 2024 23:32
Copy link
Collaborator

@ryankawahara ryankawahara left a comment

Choose a reason for hiding this comment

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

Looks good to me, refer to @zhangdzh's review to improve how the comments and tasks errors are handled

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.

3 participants