Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
anthonyjacquelin committed Nov 20, 2024
1 parent 1db1302 commit 2edf109
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 11 deletions.
6 changes: 3 additions & 3 deletions api/app/endpoints/stream.py
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ def start_stream(
if db_stream is None:
raise HTTPException(404, detail="Stream not found")

if current_user.id not in (db_stream.user_id, chat.user_id):
if current_user.id not in (db_stream.user_id, getattr(db_stream.chat, "user_id", None)):
raise HTTPException(403, detail="Forbidden")

# Get and configure the request parameters
Expand All @@ -260,8 +260,8 @@ def start_stream(
should_sids = db_stream.should_sids
must_not_sids = db_stream.must_not_sids
postprocessing = db_stream.postprocessing
operators = chat.operators
themes = chat.themes
operators = getattr(chat, "operators", None)
themes = getattr(chat, "themes", None)

sources = None
if db_stream.sources:
Expand Down
4 changes: 2 additions & 2 deletions api/app/tests/cases/archive.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
"chat_name": "string",
"chat_type": "meeting",
"id": 1,
"operator": null,
"operators": ["test_operator"],
"themes": ["test_theme"],
"stream_count": 2,
"streams": [
{
Expand Down Expand Up @@ -64,7 +65,6 @@
"with_history": true
}
],
"themes": null,
"user_id": 1
}

2 changes: 1 addition & 1 deletion api/app/tests/endpoints/test_chat.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def test_chat(self, client: TestClient):
assert response.status_code == 200

# Create Chat:
response = chat.create_chat(client, token, "qa")
response = chat.create_chat(client, token, "evaluations")
assert response.status_code == 200
chat_id = response.json()["id"]

Expand Down
2 changes: 1 addition & 1 deletion api/app/tests/endpoints/test_stream.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def test_chat_stream(self, client: TestClient, db):
assert response.status_code == 200

# Create Chat:
response = chat.create_chat(client, token, "meeting")
response = chat.create_chat(client, token, "meeting", operators=["test_operator"], themes=["test_theme"])
assert response.status_code == 200
chat_id = response.json()["id"]

Expand Down
6 changes: 2 additions & 4 deletions api/app/tests/utils/chat.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,11 @@ def read_chats(client: TestClient, token):
return client.get(f"{ROOT_PATH}/chats", headers={"Authorization": f"Bearer {token}"})


def create_chat(client: TestClient, token, chat_type):
def create_chat(client: TestClient, token, chat_type, operators=None, themes=None):
return client.post(
f"{ROOT_PATH}/chat",
headers={"Authorization": f"Bearer {token}"},
json={
"chat_type": chat_type,
},
json={"chat_type": chat_type, "operators": operators, "themes": themes},
)


Expand Down

0 comments on commit 2edf109

Please sign in to comment.