mirror of
https://github.com/pds-nest/nest.git
synced 2024-11-21 20:44:18 +00:00
completati test GET e POST alerts
This commit is contained in:
parent
e7c5d0e9d8
commit
6c3c0fade8
1 changed files with 121 additions and 10 deletions
|
@ -22,32 +22,143 @@ class TestAlertsGetAllOfARepository:
|
|||
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,
|
||||
|
||||
class TestAlertPost:
|
||||
def test_missing_name(self, flask_client: Client, user_headers):
|
||||
r = flask_client.post(f'/api/v1/repositories/1/alerts/', headers=user_headers,
|
||||
json={})
|
||||
assert r.status_code == 400
|
||||
assert r.json["result"] == "failure"
|
||||
|
||||
def test_missing_limit(self, flask_client: Client, user_headers):
|
||||
r = flask_client.post(f'/api/v1/repositories/1/alerts/', headers=user_headers,
|
||||
json={"name": "testalert"})
|
||||
assert r.status_code == 400
|
||||
assert r.json["result"] == "failure"
|
||||
|
||||
def test_missing_window_size(self, flask_client: Client, user_headers):
|
||||
r = flask_client.post(f'/api/v1/repositories/1/alerts/', headers=user_headers,
|
||||
json={"name": "testalert", "limit": "1"})
|
||||
assert r.status_code == 400
|
||||
assert r.json["result"] == "failure"
|
||||
|
||||
def test_missing_evaluation_mode(self, flask_client: Client, user_headers):
|
||||
r = flask_client.post(f'/api/v1/repositories/1/alerts/', headers=user_headers,
|
||||
json={
|
||||
"conditions": [
|
||||
{
|
||||
"content": "pds2021",
|
||||
"id": 0,
|
||||
"type": 0
|
||||
}
|
||||
],
|
||||
"XXXevaluation_modeXXX": 0,
|
||||
"limit": 0,
|
||||
"name": "pds",
|
||||
"repository_id": 1,
|
||||
"window_size": 0
|
||||
})
|
||||
assert r.status_code == 400
|
||||
assert r.json["result"] == "failure"
|
||||
|
||||
def test_wrong_evaluation_mode(self, flask_client: Client, user_headers):
|
||||
r = flask_client.post(f'/api/v1/repositories/1/alerts/', headers=user_headers,
|
||||
json={
|
||||
"conditions": [
|
||||
{
|
||||
"content": "pds2021",
|
||||
"id": 0,
|
||||
"type": 0
|
||||
}
|
||||
],
|
||||
"evaluation_mode": 99,
|
||||
"limit": 0,
|
||||
"name": "pds",
|
||||
"repository_id": 1,
|
||||
"window_size": 0
|
||||
})
|
||||
assert r.status_code == 400
|
||||
assert r.json["result"] == "failure"
|
||||
|
||||
def test_missing_type(self, flask_client: Client, user_headers):
|
||||
r = flask_client.post(f'/api/v1/repositories/1/alerts/', headers=user_headers,
|
||||
json={
|
||||
"conditions": [
|
||||
{
|
||||
"content": "pds2021",
|
||||
"id": 0,
|
||||
"XXXtypeXXX": 99
|
||||
}
|
||||
],
|
||||
"evaluation_mode": 0,
|
||||
"limit": 0,
|
||||
"name": "pds",
|
||||
"repository_id": 1,
|
||||
"window_size": 0
|
||||
})
|
||||
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,
|
||||
json={"content": "string", "type": 99})
|
||||
r = flask_client.post(f'/api/v1/repositories/1/alerts/', headers=user_headers,
|
||||
json={
|
||||
"conditions": [
|
||||
{
|
||||
"content": "pds2021",
|
||||
"id": 0,
|
||||
"type": 99
|
||||
}
|
||||
],
|
||||
"evaluation_mode": 0,
|
||||
"limit": 0,
|
||||
"name": "pds",
|
||||
"repository_id": 1,
|
||||
"window_size": 0
|
||||
})
|
||||
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,
|
||||
json={"type": 0})
|
||||
r = flask_client.post(f'/api/v1/repositories/1/alerts/', headers=user_headers,
|
||||
json={
|
||||
"conditions": [
|
||||
{
|
||||
"XXXcontentXXX": "pds2021",
|
||||
"id": 0,
|
||||
"type": 0
|
||||
}
|
||||
],
|
||||
"evaluation_mode": 0,
|
||||
"limit": 0,
|
||||
"name": "pds",
|
||||
"repository_id": 1,
|
||||
"window_size": 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,
|
||||
json={"content": "onlyForTest", "type": 0})
|
||||
r = flask_client.post(f'/api/v1/repositories/1/alerts/', headers=user_headers,
|
||||
json={
|
||||
"conditions": [
|
||||
{
|
||||
"content": "pds2021",
|
||||
"id": 0,
|
||||
"type": 0
|
||||
}
|
||||
],
|
||||
"evaluation_mode": 0,
|
||||
"limit": 0,
|
||||
"name": "pds",
|
||||
"repository_id": 1,
|
||||
"window_size": 0
|
||||
})
|
||||
assert r.status_code == 201
|
||||
assert r.json["result"] == "success"
|
||||
|
||||
|
||||
|
||||
'''
|
||||
# test del file condition
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue