-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding init github action and Refactor tests
- Loading branch information
Showing
11 changed files
with
63 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
name: Build and Deploy Code | ||
|
||
on: [push, pull_request] | ||
|
||
jobs: | ||
my_first_job: | ||
runs-on: ubuntu-20.04 | ||
steps: | ||
- name: pulling git repo | ||
uses: actions/checkout@v2 | ||
- name: say hi to user | ||
run: echo "hello user!" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,25 @@ | ||
from fastapi import status | ||
|
||
|
||
def test_user_successfully_delete_post(authorized_client, test_user, test_posts): | ||
post_id = test_posts[0].id | ||
res = authorized_client.delete(f'/posts/{post_id}') | ||
assert res.status_code == 204 | ||
assert res.status_code == status.HTTP_204_NO_CONTENT | ||
|
||
|
||
def test_delete_post_non_exist(authorized_client, test_user, test_posts): | ||
post_id = 9999 | ||
res = authorized_client.delete(f'/posts/{post_id}') | ||
assert res.status_code == 404 | ||
assert res.status_code == status.HTTP_404_NOT_FOUND | ||
|
||
|
||
def test_delete_other_user_post(authorized_client, test_user, test_posts): | ||
another_user_post_id = test_posts[3].id | ||
res = authorized_client.delete(f'/posts/{another_user_post_id}') | ||
assert res.status_code == 403 | ||
assert res.status_code == status.HTTP_403_FORBIDDEN | ||
|
||
|
||
def test_unauthorized_user_delete_post(client, test_user, test_posts): | ||
post_id = test_posts[0].id | ||
res = client.delete(f'/posts/{post_id}') | ||
assert res.status_code == 401 | ||
assert res.status_code == status.HTTP_401_UNAUTHORIZED |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
import pytest | ||
from jose import jwt | ||
from fastapi import status | ||
|
||
from app.config import settings | ||
from app import schemas | ||
|
@@ -18,16 +19,16 @@ def test_login_user(client, test_user): | |
assert user_id == test_user['id'] | ||
assert login_resp.access_token == user['access_token'] | ||
assert login_resp.token_type == 'bearer' | ||
assert res.status_code == 200 | ||
assert res.status_code == status.HTTP_200_OK | ||
|
||
|
||
@pytest.mark.parametrize("email, password, status_code", [ | ||
('[email protected]', 'password1234', 403), | ||
('[email protected]', 'wrongpassword1234', 403), | ||
('[email protected]', 'wrongpassword1234', 403), | ||
(None, 'password1234', 422), | ||
('[email protected]', None, 422), | ||
(None, None, 422), | ||
('[email protected]', 'password1234', status.HTTP_403_FORBIDDEN), | ||
('[email protected]', 'wrongpassword1234', status.HTTP_403_FORBIDDEN), | ||
('[email protected]', 'wrongpassword1234', status.HTTP_403_FORBIDDEN), | ||
(None, 'password1234', status.HTTP_422_UNPROCESSABLE_ENTITY), | ||
('[email protected]', None, status.HTTP_422_UNPROCESSABLE_ENTITY), | ||
(None, None, status.HTTP_422_UNPROCESSABLE_ENTITY), | ||
]) | ||
def test_incorrect_login(client, email, password, status_code): | ||
request_data = {'username': email, 'password': password} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters