mirror of
https://github.com/bec-project/bec_atlas.git
synced 2025-07-14 07:01:48 +02:00
tests: adjusted tests to new api
This commit is contained in:
@ -30,7 +30,7 @@ def test_login_wrong_password(backend_client):
|
|||||||
"/api/v1/user/login", json={"username": "admin@bec_atlas.ch", "password": "wrong_password"}
|
"/api/v1/user/login", json={"username": "admin@bec_atlas.ch", "password": "wrong_password"}
|
||||||
)
|
)
|
||||||
assert response.status_code == 401
|
assert response.status_code == 401
|
||||||
assert response.json() == {"detail": "Invalid password"}
|
assert response.json() == {"detail": "User not found or password is incorrect"}
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.timeout(60)
|
@pytest.mark.timeout(60)
|
||||||
@ -43,4 +43,4 @@ def test_login_unknown_user(backend_client):
|
|||||||
json={"username": "no_user@bec_atlas.ch", "password": "wrong_password"},
|
json={"username": "no_user@bec_atlas.ch", "password": "wrong_password"},
|
||||||
)
|
)
|
||||||
assert response.status_code == 404
|
assert response.status_code == 404
|
||||||
assert response.json() == {"detail": "User not found"}
|
assert response.json() == {"detail": "User not found or password is incorrect"}
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
import pytest
|
import pytest
|
||||||
from bec_atlas.ingestor.data_ingestor import DataIngestor
|
|
||||||
from bec_lib import messages
|
from bec_lib import messages
|
||||||
|
|
||||||
|
from bec_atlas.ingestor.data_ingestor import DataIngestor
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def scan_ingestor(backend):
|
def scan_ingestor(backend):
|
||||||
@ -76,7 +77,7 @@ def test_scan_ingestor_create_scan(scan_ingestor, backend):
|
|||||||
},
|
},
|
||||||
timestamp=1732610545.15924,
|
timestamp=1732610545.15924,
|
||||||
)
|
)
|
||||||
scan_ingestor.update_scan_status(msg, deployment_id="5cc67967-744d-4115-a46b-13246580cb3f")
|
scan_ingestor.update_scan_status(msg, deployment_id="678aa8d4875568640bd92174")
|
||||||
|
|
||||||
response = client.post(
|
response = client.post(
|
||||||
"/api/v1/user/login", json={"username": "admin@bec_atlas.ch", "password": "admin"}
|
"/api/v1/user/login", json={"username": "admin@bec_atlas.ch", "password": "admin"}
|
||||||
@ -85,7 +86,7 @@ def test_scan_ingestor_create_scan(scan_ingestor, backend):
|
|||||||
|
|
||||||
session_id = msg.info.get("session_id")
|
session_id = msg.info.get("session_id")
|
||||||
scan_id = msg.scan_id
|
scan_id = msg.scan_id
|
||||||
response = client.get(f"/api/v1/scans/session/{session_id}")
|
response = client.get("/api/v1/scans/session", params={"session_id": session_id})
|
||||||
assert response.status_code == 200
|
assert response.status_code == 200
|
||||||
out = response.json()[0]
|
out = response.json()[0]
|
||||||
# assert out["session_id"] == session_id
|
# assert out["session_id"] == session_id
|
||||||
@ -93,14 +94,14 @@ def test_scan_ingestor_create_scan(scan_ingestor, backend):
|
|||||||
assert out["status"] == "open"
|
assert out["status"] == "open"
|
||||||
|
|
||||||
msg.status = "closed"
|
msg.status = "closed"
|
||||||
scan_ingestor.update_scan_status(msg, deployment_id="5cc67967-744d-4115-a46b-13246580cb3f")
|
scan_ingestor.update_scan_status(msg, deployment_id="678aa8d4875568640bd92174")
|
||||||
response = client.get(f"/api/v1/scans/id/{scan_id}")
|
response = client.get("/api/v1/scans/id", params={"scan_id": scan_id})
|
||||||
assert response.status_code == 200
|
assert response.status_code == 200
|
||||||
out = response.json()
|
out = response.json()
|
||||||
assert out["status"] == "closed"
|
assert out["status"] == "closed"
|
||||||
assert out["scan_id"] == scan_id
|
assert out["scan_id"] == scan_id
|
||||||
|
|
||||||
response = client.get(f"/api/v1/scans/session/{session_id}")
|
response = client.get("/api/v1/scans/session", params={"session_id": session_id})
|
||||||
assert response.status_code == 200
|
assert response.status_code == 200
|
||||||
out = response.json()
|
out = response.json()
|
||||||
assert len(out) == 1
|
assert len(out) == 1
|
||||||
|
Reference in New Issue
Block a user