Code indexing in gitaly is broken and leads to code not being visible to the user. We work on the issue with highest priority.

Skip to content
Snippets Groups Projects
Commit 17a89335 authored by GotthardG's avatar GotthardG
Browse files

Clean up testfunctions.ipynb by removing redundant code

Removed outdated and unused code snippets from testfunctions.ipynb to streamline the notebook. This improves readability and reduces clutter, ensuring the file contains only relevant and functional code samples.
parent 51ac892c
No related branches found
No related tags found
No related merge requests found
Pipeline #48341 failed
......@@ -4,9 +4,21 @@ from backend.main import app
client = TestClient(app)
def authenticate(client):
response = client.post(
"/auth/login", json={"username": "testuser", "password": "testpassword"}
)
assert response.status_code == 200
return response.json()["access_token"]
def test_create_contact_success():
token = authenticate(client)
headers = {"Authorization": f"Bearer {token}"}
response = client.post(
"/contact",
"/protected/contacts",
headers=headers,
json={
"pgroups": "p20001",
"firstname": "John",
......@@ -15,7 +27,6 @@ def test_create_contact_success():
"phone_number": "+000000000",
},
)
# Assert success and verify response structure
assert response.status_code == 201
json_response = response.json()
assert json_response["firstname"] == "John"
......@@ -23,6 +34,22 @@ def test_create_contact_success():
assert json_response["email"] == "john.rambo@example.com"
def test_create_contact_unauthorized():
# Omit Authorization header to simulate unauthorized access
response = client.post(
"/protected/contacts",
json={
"pgroups": "p20001",
"firstname": "John",
"lastname": "Rambo",
"email": "john.rambo@example.com",
"phone_number": "+000000000",
},
)
assert response.status_code == 401
assert response.json()["detail"] == "Not authenticated"
def test_create_contact_already_exists():
# Ensure that the route fails gracefully if contact exists
client.post(
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment