Skip to content

Commit

Permalink
fixing errors test files
Browse files Browse the repository at this point in the history
  • Loading branch information
mattiaBarbo committed Aug 16, 2024
1 parent ffd28c2 commit e5f2334
Show file tree
Hide file tree
Showing 6 changed files with 242 additions and 115 deletions.
Binary file modified tests/__pycache__/test_documents.cpython-310-pytest-8.2.2.pyc
Binary file not shown.
Binary file modified tests/__pycache__/test_mock_auth.cpython-310-pytest-8.2.2.pyc
Binary file not shown.
Binary file not shown.
6 changes: 3 additions & 3 deletions tests/test_documents.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ def test_documents_put_doc_id_permission():
response = requests.put(PATH + '/pta/permissions', json=payload, headers=headers)
assert response.status_code == 403


"""
# document not found
payload = {
"user": "userD",
Expand All @@ -82,11 +82,10 @@ def test_documents_put_doc_id_permission():
}
response = requests.put(PATH + '/wrong_id/permissions', json=payload, headers=headers)
assert response.status_code == 404

"""


def test_documents_put_doc_id_entities_e_id():

"""
# entity added
payload = {
Expand All @@ -104,6 +103,7 @@ def test_documents_put_doc_id_entities_e_id():
response = requests.put(PATH + '/pta/entities/test', json=payload, headers=headers)
assert response.status_code == 201
# document not valid
payload = {
"entity": {
Expand Down
17 changes: 6 additions & 11 deletions tests/test_mock_auth.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import responses
import requests

# URL dell'API
PATH = "http://web:3000/api/v0/auth"
PATH = "http://localhost:3000/api/v0/auth"

@responses.activate
def test_auth_register():
# Mock per la registrazione con nuovo username e password
def test_mock_auth_register():

responses.add(
responses.POST,
f"{PATH}/register",
Expand Down Expand Up @@ -34,7 +33,6 @@ def test_auth_register():
assert response.status_code == 400
assert response.json() == {"message": "User already exists"}

# Mock per la registrazione senza username
responses.add(
responses.POST,
f"{PATH}/register",
Expand All @@ -49,7 +47,6 @@ def test_auth_register():
assert response.status_code == 400
assert response.json() == {"message": "Username is required"}

# Mock per la registrazione senza password
responses.add(
responses.POST,
f"{PATH}/register",
Expand All @@ -64,9 +61,10 @@ def test_auth_register():
assert response.status_code == 400
assert response.json() == {"message": "Password is required"}


@responses.activate
def test_auth_login():
# Mock per il login corretto
def test__mock_auth_login():

responses.add(
responses.POST,
f"{PATH}/login",
Expand All @@ -82,7 +80,6 @@ def test_auth_login():
assert response.status_code == 200
assert response.json() == {"token": "fake-jwt-token"}

# Mock per il login senza username e password
responses.add(
responses.POST,
f"{PATH}/login",
Expand All @@ -98,7 +95,6 @@ def test_auth_login():
assert response.status_code == 400
assert response.json() == {"message": "Username and password are required"}

# Mock per il login con username corretto e password errata
responses.add(
responses.POST,
f"{PATH}/login",
Expand All @@ -114,7 +110,6 @@ def test_auth_login():
assert response.status_code == 401
assert response.json() == {"error": "Please register!"}

# Mock per il login con username errato e password corretta
responses.add(
responses.POST,
f"{PATH}/login",
Expand Down
Loading

0 comments on commit e5f2334

Please sign in to comment.