Skip to content

Commit

Permalink
fixing paths
Browse files Browse the repository at this point in the history
  • Loading branch information
elman23 committed Sep 26, 2023
1 parent e489939 commit e2024a2
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
10 changes: 5 additions & 5 deletions tests/test_post.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

def test_get_all_post(authorized_client, test_posts):
print("Testing get all posts...")
response = authorized_client.get("/posts")
response = authorized_client.get("/posts/")
posts = [schemas.ResponsePostVote(**post) for post in response.json()]
assert posts
assert len(posts) == len(test_posts)
Expand All @@ -14,7 +14,7 @@ def test_get_all_post(authorized_client, test_posts):

def test_unauthorized_user_get_all_posts(client, test_posts):
print("Testing unauthorized client getting all posts...")
response = client.get("/posts")
response = client.get("/posts/")
assert response.status_code == status.HTTP_401_UNAUTHORIZED


Expand Down Expand Up @@ -50,7 +50,7 @@ def test_authorized_get_one_post(authorized_client, test_posts):
("Hi there!", "Hi there!", False),
])
def test_create_post(authorized_client, test_user, title, content, published):
response = authorized_client.post("/posts", json={"title": title, "content": content, "published": published})
response = authorized_client.post("/posts/", json={"title": title, "content": content, "published": published})
assert response.status_code == status.HTTP_201_CREATED
post = schemas.ResponsePost(**response.json())
assert post.title == title
Expand All @@ -62,7 +62,7 @@ def test_create_post(authorized_client, test_user, title, content, published):
def test_create_post_default_published(authorized_client, test_user):
title = "Test title"
content = "Test content"
response = authorized_client.post("/posts", json={"title": title, "content": content})
response = authorized_client.post("/posts/", json={"title": title, "content": content})
assert response.status_code == status.HTTP_201_CREATED
post = schemas.ResponsePost(**response.json())
assert post.title == title
Expand All @@ -75,7 +75,7 @@ def test_unauthorized_user_create_post(client, test_user):
print("Testing unauthorized client creating a post...")
title = "Test title"
content = "Test content"
response = client.post("/posts", json={"title": title, "content": content})
response = client.post("/posts/", json={"title": title, "content": content})
assert response.status_code == status.HTTP_401_UNAUTHORIZED


Expand Down
2 changes: 1 addition & 1 deletion tests/test_user.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def test_root(client):

def test_create_user(client):
print("Testing user creation...")
response = client.post("/users", json={"email": "[email protected]", "password": "password"})
response = client.post("/users/", json={"email": "[email protected]", "password": "password"})
new_user = schemas.ResponseUser(**response.json())
assert new_user.email == "[email protected]"
assert response.status_code == status.HTTP_201_CREATED
Expand Down
12 changes: 6 additions & 6 deletions tests/test_vote.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,31 +11,31 @@ def test_vote(session, test_user, test_posts):


def test_vote_on_post(authorized_client, test_posts):
response = authorized_client.post("/vote", json={"post_id": test_posts[0].id, "direction": 1})
response = authorized_client.post("/vote/", json={"post_id": test_posts[0].id, "direction": 1})
assert response.status_code == status.HTTP_201_CREATED


def test_vote_twice_post(authorized_client, test_posts, test_vote):
response = authorized_client.post("/vote", json={"post_id": test_posts[3].id, "direction": 1})
response = authorized_client.post("/vote/", json={"post_id": test_posts[3].id, "direction": 1})
assert response.status_code == status.HTTP_409_CONFLICT


def test_vote_delete_post(authorized_client, test_posts, test_vote):
response = authorized_client.post("/vote", json={"post_id": test_posts[3].id, "direction": 0})
response = authorized_client.post("/vote/", json={"post_id": test_posts[3].id, "direction": 0})
assert response.status_code == status.HTTP_201_CREATED


def test_vote_down_post(authorized_client, test_posts):
response = authorized_client.post("/vote", json={"post_id": test_posts[0].id, "direction": 0})
response = authorized_client.post("/vote/", json={"post_id": test_posts[0].id, "direction": 0})
assert response.status_code == status.HTTP_404_NOT_FOUND


def test_vote_not_existent_post(authorized_client, test_posts):
not_existent_id = 1000
response = authorized_client.post("/vote", json={"post_id": not_existent_id, "direction": 1})
response = authorized_client.post("/vote/", json={"post_id": not_existent_id, "direction": 1})
assert response.status_code == status.HTTP_404_NOT_FOUND


def test_vote_unauthorized_user(client, test_posts):
response = client.post("/vote", json={"post_id": test_posts[0].id, "direction": 1})
response = client.post("/vote/", json={"post_id": test_posts[0].id, "direction": 1})
assert response.status_code == status.HTTP_401_UNAUTHORIZED

0 comments on commit e2024a2

Please sign in to comment.