1
Fork 0
mirror of https://github.com/pds-nest/nest.git synced 2024-11-22 04:54:18 +00:00

risolti bug e aggiunti un paio di test

This commit is contained in:
Annielated 2021-05-28 18:22:50 +02:00
parent 009cfa49f6
commit 34ecba7319
5 changed files with 11 additions and 7 deletions

View file

@ -6,3 +6,8 @@ from flask.testing import Client
def test_doa(flask_client: Client, admin_headers): def test_doa(flask_client: Client, admin_headers):
response = flask_client.get("/doa", headers=admin_headers) response = flask_client.get("/doa", headers=admin_headers)
assert b"If you see this, the server is fine." in response.data assert b"If you see this, the server is fine." in response.data
def test_sq_told_me_to_do_this(flask_client: Client, user_headers):
response = flask_client.post("/doa", headers=user_headers)
assert b"Hello there." in response.data

View file

@ -24,7 +24,7 @@ class TestUserGetAll:
assert r.json["result"] == "success" assert r.json["result"] == "success"
def test_for_failure(self, flask_client: Client, user_headers): def test_for_failure(self, flask_client: Client, user_headers):
r = flask_client.get(f'/api/v1/users/', headers=user_headers) r = flask_client.patch(f'/api/v1/users/', headers=user_headers)
assert r.json["result"] == "failure" assert r.json["result"] == "failure"

View file

@ -213,8 +213,8 @@ class TestRepositoryPut:
assert r.status_code == 404 assert r.status_code == 404
assert r.json["result"] == "failure" assert r.json["result"] == "failure"
def test_for_success(self, flask_client: Client, admin_headers): def test_for_success(self, flask_client: Client, user_headers):
r = flask_client.put(f'/api/v1/repositories/1', headers=admin_headers, json={ r = flask_client.put(f'/api/v1/repositories/1', headers=user_headers, json={
"conditions": [ "conditions": [
{ {
"content": "string", "content": "string",

View file

@ -12,8 +12,8 @@ class TestConditionGetAllOfARepository:
assert r.status_code == 404 assert r.status_code == 404
assert r.json["result"] == "failure" assert r.json["result"] == "failure"
def test__unauthorized_repository(self, flask_client: Client, admin_headers): def test__unauthorized_user(self, flask_client: Client, user_headers):
r = flask_client.get(f'/api/v1/repositories/1/conditions/', headers=admin_headers) r = flask_client.get(f'/api/v1/repositories/2/conditions/', headers=user_headers)
assert r.status_code == 403 assert r.status_code == 403
assert r.json["result"] == "failure" assert r.json["result"] == "failure"

View file

@ -74,9 +74,8 @@ class TestAuthorizationsPut:
class TestAuthorizationsDelete: class TestAuthorizationsDelete:
def test_for_success(self, flask_client: Client, user_headers): def test_for_success(self, flask_client: Client, user_headers):
r = flask_client.delete(f'/api/v1/repositories/1/authorizations/user_test@nest.com', headers=user_headers) r = flask_client.delete(f'/api/v1/repositories/1/authorizations/admin@admin.com', headers=user_headers)
assert r.status_code == 204 assert r.status_code == 204
assert r.json["result"] == "success"
def test_user_not_logged(self, flask_client: Client): def test_user_not_logged(self, flask_client: Client):
r = flask_client.delete(f'/api/v1/repositories/1/authorizations/user_test@nest.com') r = flask_client.delete(f'/api/v1/repositories/1/authorizations/user_test@nest.com')