mirror of
https://github.com/pds-nest/nest.git
synced 2024-11-21 20:44:18 +00:00
Tests work properly
lets gooooo
This commit is contained in:
parent
de86e33a84
commit
1a23d9c81f
4 changed files with 12 additions and 11 deletions
|
@ -245,6 +245,7 @@ class TestRepositoryPut:
|
|||
"isAdmin": True,
|
||||
"username": "string"
|
||||
},
|
||||
"spectators": [],
|
||||
"start": "2021-05-14T12:12:29.827Z"
|
||||
})
|
||||
assert r.status_code == 200
|
||||
|
|
|
@ -8,42 +8,42 @@ from flask.testing import Client
|
|||
|
||||
class TestConditionGetAllOfARepository:
|
||||
def test_repository_not_found(self, flask_client: Client, user_headers):
|
||||
r = flask_client.get(f'/api/v1/repositories/99/conditions', headers=user_headers)
|
||||
r = flask_client.get(f'/api/v1/repositories/99/conditions/', headers=user_headers)
|
||||
assert r.status_code == 404
|
||||
assert r.json["result"] == "failure"
|
||||
|
||||
def test__unauthorized_repository(self, flask_client: Client, admin_headers):
|
||||
r = flask_client.get(f'/api/v1/repositories/1/conditions', headers=admin_headers)
|
||||
r = flask_client.get(f'/api/v1/repositories/1/conditions/', headers=admin_headers)
|
||||
assert r.status_code == 403
|
||||
assert r.json["result"] == "failure"
|
||||
|
||||
def test_get_all_conditions_of_a_repository(self, flask_client: Client, user_headers):
|
||||
r = flask_client.get(f'/api/v1/repositories/1/conditions', headers=user_headers)
|
||||
r = flask_client.get(f'/api/v1/repositories/1/conditions/', headers=user_headers)
|
||||
assert r.status_code == 200
|
||||
assert r.json["result"] == "success"
|
||||
|
||||
|
||||
class TestConditionPost:
|
||||
def test_missing_type(self, flask_client: Client, user_headers):
|
||||
r = flask_client.post(f'/api/v1/repositories/1/conditions', headers=user_headers,
|
||||
r = flask_client.post(f'/api/v1/repositories/1/conditions/', headers=user_headers,
|
||||
json={})
|
||||
assert r.status_code == 400
|
||||
assert r.json["result"] == "failure"
|
||||
|
||||
def test_wrong_type(self, flask_client: Client, user_headers):
|
||||
r = flask_client.post(f'/api/v1/repositories/1/conditions', headers=user_headers,
|
||||
r = flask_client.post(f'/api/v1/repositories/1/conditions/', headers=user_headers,
|
||||
json={"content": "string", "type": 99})
|
||||
assert r.status_code == 400
|
||||
assert r.json["result"] == "failure"
|
||||
|
||||
def test_missing_content(self, flask_client: Client, user_headers):
|
||||
r = flask_client.post(f'/api/v1/repositories/1/conditions', headers=user_headers,
|
||||
r = flask_client.post(f'/api/v1/repositories/1/conditions/', headers=user_headers,
|
||||
json={"type": 0})
|
||||
assert r.status_code == 400
|
||||
assert r.json["result"] == "failure"
|
||||
|
||||
def test_for_success(self, flask_client: Client, user_headers):
|
||||
r = flask_client.post(f'/api/v1/repositories/1/conditions', headers=user_headers,
|
||||
r = flask_client.post(f'/api/v1/repositories/1/conditions/', headers=user_headers,
|
||||
json={"content": "onlyForTest", "type": 0})
|
||||
assert r.status_code == 201
|
||||
assert r.json["result"] == "success"
|
||||
|
|
|
@ -8,17 +8,17 @@ from flask.testing import Client
|
|||
|
||||
class TestAlertsGetAllOfARepository:
|
||||
def test_repository_not_found(self, flask_client: Client, user_headers):
|
||||
r = flask_client.get(f'/api/v1/repositories/99/alerts', headers=user_headers)
|
||||
r = flask_client.get(f'/api/v1/repositories/99/alerts/', headers=user_headers)
|
||||
assert r.status_code == 404
|
||||
assert r.json["result"] == "failure"
|
||||
|
||||
def test_unauthorized_repository(self, flask_client: Client, admin_headers):
|
||||
r = flask_client.get(f'/api/v1/repositories/1/alerts', headers=admin_headers)
|
||||
r = flask_client.get(f'/api/v1/repositories/1/alerts/', headers=admin_headers)
|
||||
assert r.status_code == 403
|
||||
assert r.json["result"] == "failure"
|
||||
|
||||
def test_get_all_alerts_of_a_repository(self, flask_client: Client, user_headers):
|
||||
r = flask_client.get(f'/api/v1/repositories/1/alerts', headers=user_headers)
|
||||
r = flask_client.get(f'/api/v1/repositories/1/alerts/', headers=user_headers)
|
||||
assert r.status_code == 200
|
||||
assert r.json["result"] == "success"
|
||||
|
||||
|
|
|
@ -47,7 +47,7 @@ class TestAuthorizationsPut:
|
|||
r = flask_client.put(f'/api/v1/repositories/1/authorizations/', headers=user_headers, json={
|
||||
'email': 'admin@admin.com'
|
||||
})
|
||||
assert r.status_code == 201
|
||||
assert r.status_code == 200
|
||||
assert r.json["result"] == "success"
|
||||
|
||||
def test_authorization_already_existed(self, flask_client: Client, user_headers):
|
||||
|
|
Loading…
Reference in a new issue