mirror of
https://github.com/pds-nest/nest.git
synced 2024-11-25 14:34:19 +00:00
test repository
This commit is contained in:
parent
e9922fb483
commit
844445a0fa
2 changed files with 7 additions and 6 deletions
|
@ -70,15 +70,16 @@ def page_repositories():
|
|||
spectator = spectator.filter(not Repository.is_active)
|
||||
owner = owner.all()
|
||||
spectator = spectator.all()
|
||||
return json_success([r.to_json() for r in owner]+[r.repository.to_json() for r in spectator])
|
||||
return json_success([r.to_json() for r in owner] + [r.repository.to_json() for r in spectator])
|
||||
elif request.method == "POST":
|
||||
# Users will be tolerated if they change parameters they're not supposed to touch. We'll ignore them for now.
|
||||
if not request.json.get("name") or not request.json.get("conditions") or not str(request.json.get("evaluation_mode")):
|
||||
if not request.json.get("name") or not request.json.get("conditions") or not str(
|
||||
request.json.get("evaluation_mode")):
|
||||
return json_error("Missing arguments."), 400
|
||||
name = request.json.get("name")
|
||||
try:
|
||||
evaluation_mode = ConditionMode(request.json['evaluation_mode'])
|
||||
except KeyError:
|
||||
except: # KeyError
|
||||
return json_error("Unknown `type` specified."), 400
|
||||
repository = Repository(name=name, owner_id=user.email, is_active=False, evaluation_mode=evaluation_mode)
|
||||
ext.session.add(repository)
|
||||
|
|
|
@ -18,12 +18,12 @@ class TestRepositoryAdd:
|
|||
'name': 'repo_test',
|
||||
'is_active': True
|
||||
})
|
||||
assert r.status_code == 200
|
||||
assert r.status_code == 201
|
||||
assert r.json["result"] == "success"
|
||||
assert r.json["data"]["is_active"] is True
|
||||
|
||||
# ne creo un altro come admin
|
||||
def test_for_success(self, flask_client: Client, admin_headers):
|
||||
def test_for_success_admin(self, flask_client: Client, admin_headers):
|
||||
r = flask_client.post(f'/api/v1/repositories/', headers=admin_headers, json={
|
||||
'conditions': [
|
||||
{
|
||||
|
@ -36,7 +36,7 @@ class TestRepositoryAdd:
|
|||
'name': 'repo_admin',
|
||||
'is_active': True
|
||||
})
|
||||
assert r.status_code == 200
|
||||
assert r.status_code == 201
|
||||
assert r.json["result"] == "success"
|
||||
assert r.json["data"]["is_active"] is True
|
||||
|
||||
|
|
Loading…
Reference in a new issue