mirror of
https://github.com/pds-nest/nest.git
synced 2025-03-24 09:17:15 +00:00
test repository
This commit is contained in:
parent
7933164f60
commit
5710bd69fd
1 changed files with 39 additions and 12 deletions
|
@ -4,6 +4,7 @@ from flask.testing import Client
|
||||||
|
|
||||||
|
|
||||||
class TestRepositoryAdd:
|
class TestRepositoryAdd:
|
||||||
|
# creo un repository
|
||||||
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': [
|
||||||
|
@ -21,6 +22,24 @@ 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
|
||||||
|
|
||||||
|
# ne creo un altro come admin
|
||||||
|
def test_for_success(self, flask_client: Client, admin_headers):
|
||||||
|
r = flask_client.post(f'/api/v1/repositories/', headers=admin_headers, json={
|
||||||
|
'conditions': [
|
||||||
|
{
|
||||||
|
'content': 'PdS2021',
|
||||||
|
'id': 0,
|
||||||
|
'type': 0
|
||||||
|
}
|
||||||
|
],
|
||||||
|
'evaluation_mode': 0,
|
||||||
|
'name': 'repo_admin',
|
||||||
|
'is_active': True
|
||||||
|
})
|
||||||
|
assert r.status_code == 200
|
||||||
|
assert r.json["result"] == "success"
|
||||||
|
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_no_name(self, flask_client: Client, user_headers):
|
def test_no_name(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={
|
||||||
|
@ -107,32 +126,39 @@ class TestRepositoryPatch:
|
||||||
|
|
||||||
def test_unknown_type(self, flask_client: Client, admin_headers):
|
def test_unknown_type(self, flask_client: Client, admin_headers):
|
||||||
r = flask_client.patch(f'/api/v1/repositories/1', headers=admin_headers,
|
r = flask_client.patch(f'/api/v1/repositories/1', headers=admin_headers,
|
||||||
json={
|
json={
|
||||||
"name": "string",
|
"name": "string",
|
||||||
"close": "string",
|
"close": "string",
|
||||||
"open": "string",
|
"open": "string",
|
||||||
"evaluation_mode": 99
|
"evaluation_mode": 99
|
||||||
})
|
})
|
||||||
assert r.status_code == 400
|
assert r.status_code == 400
|
||||||
assert r.json["result"] == "failure"
|
assert r.json["result"] == "failure"
|
||||||
|
|
||||||
def test_for_success(self, flask_client: Client, user_headers):
|
def test_for_success(self, flask_client: Client, user_headers):
|
||||||
r = flask_client.patch(f'/api/v1/repositories/1', headers=user_headers,
|
r = flask_client.patch(f'/api/v1/repositories/1', headers=user_headers,
|
||||||
json={
|
json={
|
||||||
"name": "nuovo_nome",
|
"name": "nuovo_nome",
|
||||||
"close": "false",
|
"close": "false",
|
||||||
"open": "false",
|
"open": "false",
|
||||||
"evaluation_mode": 1
|
"evaluation_mode": 1
|
||||||
})
|
})
|
||||||
assert r.status_code == 200
|
assert r.status_code == 200
|
||||||
assert r.json["result"] == "success"
|
assert r.json["result"] == "success"
|
||||||
|
|
||||||
|
|
||||||
class TestRepositoryDelete:
|
class TestRepositoryDelete:
|
||||||
def test_wrong_owner(self, flask_client: Client, user_headers):
|
def test_wrong_owner(self, flask_client: Client, user_headers):
|
||||||
r = flask_client.delete(f'/api/v1/repositories/2', headers=user_headers)
|
r = flask_client.delete(f'/api/v1/repositories/2', headers=user_headers)
|
||||||
assert r.status_code == 403
|
assert r.status_code == 403
|
||||||
assert r.json["result"] == "failure"
|
assert r.json["result"] == "failure"
|
||||||
|
|
||||||
|
# TODO: testare la condizione di uscita con errore perche ci sono delle dipendenze
|
||||||
|
|
||||||
|
def test_for_success(self, flask_client: Client, admin_headers):
|
||||||
|
r = flask_client.delete(f'/api/v1/repositories/2', headers=admin_headers)
|
||||||
|
assert r.status_code == 200
|
||||||
|
assert r.json["result"] == "success"
|
||||||
|
|
||||||
|
|
||||||
class TestRepositoryPut:
|
class TestRepositoryPut:
|
||||||
|
@ -147,6 +173,7 @@ class TestRepositoryPut:
|
||||||
assert r.status_code == 400
|
assert r.status_code == 400
|
||||||
assert r.json["result"] == "failure"
|
assert r.json["result"] == "failure"
|
||||||
|
|
||||||
|
|
||||||
'''
|
'''
|
||||||
class TestUserDelete:
|
class TestUserDelete:
|
||||||
def test_for_success(self, flask_client: Client, admin_headers):
|
def test_for_success(self, flask_client: Client, admin_headers):
|
||||||
|
|
Loading…
Add table
Reference in a new issue