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

test repository

This commit is contained in:
stefanogoldoni 2021-05-12 23:39:29 +02:00
parent b0217d6f36
commit 1bc59c76bc

View file

@ -19,15 +19,14 @@ class TestRepositoryGetAll:
# assert r.json["data"]["isAdmin"] is True # assert r.json["data"]["isAdmin"] is True
class TestRepositoryAdd: class TestRepositoryAdd:
def test_for_success(self, flask_client: Client, user_headers): def test_for_success(self, flask_client: Client, user_headers):
r = flask_client.post(f'/api/v1/repositories/', headers=user_headers, json={ r = flask_client.post(f'/api/v1/repositories/', headers=user_headers, json={
'conditions': [ 'conditions': [
{ {
'content': 'PdS2021', 'content': 'PdS2021',
'id': 0, 'id': 0,
'type': 0 'type': 0
} }
], ],
'evaluation_mode': 0, 'evaluation_mode': 0,
@ -37,24 +36,53 @@ class TestRepositoryAdd:
assert r.json["result"] == "success" assert r.json["result"] == "success"
assert r.json["data"]["is_active"] is True assert r.json["data"]["is_active"] is True
# non vengono passate le condizioni necessarie, in questo caso il nome della repository # non vengono passate le condizioni necessarie, in questo caso il nome della repository
def test_for_failure(self, flask_client: Client, user_headers): def test_for_failure(self, flask_client: Client, user_headers):
r = flask_client.post(f'/api/v1/repositories/', headers=user_headers, json={ r = flask_client.post(f'/api/v1/repositories/', headers=user_headers, json={
'conditions': [ 'conditions': [
{ {
'content': 'PdS2021', 'content': 'PdS2021',
'id': 0, 'id': 0,
'type': 0 'type': 0
} }
], ],
'evaluation_mode': 0, 'evaluation_mode': 0,
'is_active': True 'is_active': True
}) })
assert r.json["msg"] == "Missing arguments." assert r.json["msg"] == "Missing arguments."
assert r.json["result"] == "failure" assert r.json["result"] == "failure"
# viene passato un campo evaluation_mode con valore non previsto dall'enum
def test_wrong_evaluation_mode(self, flask_client: Client, user_headers):
r = flask_client.post(f'/api/v1/repositories/', headers=user_headers, json={
'conditions': [
{
'content': 'PdS2021',
'id': 0,
'type': 0
}
],
'evaluation_mode': 99,
'name': 'repo_test',
'is_active': True
})
assert r.json["result"] == "failure"
# viene passato un campo type con valore non previsto dall'enum
def test_wrong_condition(self, flask_client: Client, user_headers):
r = flask_client.post(f'/api/v1/repositories/', headers=user_headers, json={
'conditions': [
{
'content': 'PdS2021',
'id': 0,
'type': 99
}
],
'evaluation_mode': 2,
'name': 'repo_test',
'is_active': True
})
assert r.json["result"] == "failure"
''' '''
class TestUserDelete: class TestUserDelete: