Skip to content

Commit a751064

Browse files
committed
normal users
1 parent dfe70ab commit a751064

File tree

8 files changed

+33
-38
lines changed

8 files changed

+33
-38
lines changed

backend/app/seed_data/seed_data.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,14 @@
2121
],
2222
"users": [
2323
{
24+
"email": "{{SUPERUSER_EMAIL}}",
2425
"password": "changethis",
2526
"full_name": "SUPERUSER",
2627
"is_active": true,
2728
"is_superuser": true
2829
},
2930
{
31+
"email": "{{ADMIN_EMAIL}}",
3032
"password": "admin123",
3133
"full_name": "ADMIN",
3234
"is_active": true,

backend/app/seed_data/seed_data.py

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -309,26 +309,15 @@ def seed_database(session: Session) -> None:
309309
f"Created organization: {organization.name} (ID: {organization.id})"
310310
)
311311

312-
# Create users
313-
users = []
314312
for user_data in seed_data["users"]:
315-
# Directly map the emails from environment variables based on the user name
316-
if user_data["full_name"] == "SUPERUSER":
313+
if user_data["email"] == "{{SUPERUSER_EMAIL}}":
317314
user_data["email"] = settings.FIRST_SUPERUSER
318-
elif user_data["full_name"] == "ADMIN":
315+
elif user_data["email"] == "{{ADMIN_EMAIL}}":
319316
user_data["email"] = settings.EMAIL_TEST_USER
320-
else:
321-
# If the user is not SUPERUSER or ADMIN, allow manual email assignment
322-
if "email" not in user_data:
323-
logging.warning(
324-
f"Email not provided for user {user_data['full_name']}. Skipping user creation."
325-
)
326-
continue # Skip if no email is provided for new users
327-
logging.info(
328-
f"Email manually provided for user: {user_data['full_name']}"
329-
)
330-
331-
# Create the user in the database
317+
318+
# Create users
319+
users = []
320+
for user_data in seed_data["users"]:
332321
user = create_user(session, user_data)
333322
users.append(user)
334323
logging.info(f"Created user: {user.email} (ID: {user.id})")

backend/app/tests/api/routes/collections/test_collection_info.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,9 @@ def create_collection(
3737

3838

3939
def test_collection_info_processing(
40-
db: Session, client: TestClient, superuser_api_key_headers
40+
db: Session, client: TestClient, normal_user_api_key_headers
4141
):
42-
headers = superuser_api_key_headers
42+
headers = normal_user_api_key_headers
4343
user = get_user_from_api_key(db, headers)
4444
collection = create_collection(db, user, status=CollectionStatus.processing)
4545

@@ -58,9 +58,9 @@ def test_collection_info_processing(
5858

5959

6060
def test_collection_info_successful(
61-
db: Session, client: TestClient, superuser_api_key_headers
61+
db: Session, client: TestClient, normal_user_api_key_headers
6262
):
63-
headers = superuser_api_key_headers
63+
headers = normal_user_api_key_headers
6464
user = get_user_from_api_key(db, headers)
6565
collection = create_collection(
6666
db, user, status=CollectionStatus.successful, with_llm=True
@@ -81,9 +81,9 @@ def test_collection_info_successful(
8181

8282

8383
def test_collection_info_failed(
84-
db: Session, client: TestClient, superuser_api_key_headers
84+
db: Session, client: TestClient, normal_user_api_key_headers
8585
):
86-
headers = superuser_api_key_headers
86+
headers = normal_user_api_key_headers
8787
user = get_user_from_api_key(db, headers)
8888
collection = create_collection(db, user, status=CollectionStatus.failed)
8989

backend/app/tests/api/routes/collections/test_create_collections.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ class TestCollectionRouteCreate:
4747

4848
@openai_responses.mock()
4949
def test_create_collection_success(
50-
self, client: TestClient, db: Session, superuser_api_key_headers
50+
self, client: TestClient, db: Session, normal_user_api_key_headers
5151
):
5252
store = DocumentStore(db)
5353
documents = store.fill(self._n_documents)
@@ -60,7 +60,7 @@ def test_create_collection_success(
6060
"instructions": "Test collection assistant.",
6161
"temperature": 0.1,
6262
}
63-
headers = superuser_api_key_headers
63+
headers = normal_user_api_key_headers
6464

6565
response = client.post(
6666
f"{settings.API_V1_STR}/collections/create", json=body, headers=headers

backend/app/tests/api/routes/documents/test_route_document_upload.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ def put(self, route: Route, scratch: Path):
2525
with scratch.open("rb") as fp:
2626
return self.client.post(
2727
str(route),
28-
headers=self.superuser_token_headers,
28+
headers=self.normal_user_api_key_headers,
2929
files={
3030
"src": (str(scratch), fp, mtype),
3131
},
@@ -45,8 +45,8 @@ def route():
4545

4646

4747
@pytest.fixture
48-
def uploader(client: TestClient, superuser_token_headers: dict[str, str]):
49-
return WebUploader(client, superuser_token_headers)
48+
def uploader(client: TestClient, normal_user_api_key_headers: dict[str, str]):
49+
return WebUploader(client, normal_user_api_key_headers)
5050

5151

5252
@pytest.fixture(scope="class")

backend/app/tests/api/routes/test_responses.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
@patch("app.api.routes.responses.OpenAI")
1717
@patch("app.api.routes.responses.get_provider_credential")
1818
def test_responses_endpoint_success(
19-
mock_get_credential, mock_openai, db, superuser_api_key_headers: dict[str, str]
19+
mock_get_credential, mock_openai, db, normal_user_api_key_headers: dict[str, str]
2020
):
2121
"""Test the /responses endpoint for successful response creation."""
2222
# Setup mock credentials
@@ -49,7 +49,7 @@ def test_responses_endpoint_success(
4949
}
5050

5151
response = client.post(
52-
"/responses", json=request_data, headers=superuser_api_key_headers
52+
"/responses", json=request_data, headers=normal_user_api_key_headers
5353
)
5454
assert response.status_code == 200
5555
response_json = response.json()
@@ -62,7 +62,11 @@ def test_responses_endpoint_success(
6262
@patch("app.api.routes.responses.get_provider_credential")
6363
@patch("app.api.routes.responses.get_assistant_by_id")
6464
def test_responses_endpoint_without_vector_store(
65-
mock_get_assistant, mock_get_credential, mock_openai, db, superuser_api_key_headers
65+
mock_get_assistant,
66+
mock_get_credential,
67+
mock_openai,
68+
db,
69+
normal_user_api_key_headers,
6670
):
6771
"""Test the /responses endpoint when assistant has no vector store configured."""
6872
# Setup mock credentials
@@ -103,7 +107,7 @@ def test_responses_endpoint_without_vector_store(
103107
}
104108

105109
response = client.post(
106-
"/responses", json=request_data, headers=superuser_api_key_headers
110+
"/responses", json=request_data, headers=normal_user_api_key_headers
107111
)
108112
assert response.status_code == 200
109113
response_json = response.json()

backend/app/tests/utils/document.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -113,18 +113,18 @@ def append(self, doc: Document, suffix: str = None):
113113
@dataclass
114114
class WebCrawler:
115115
client: TestClient
116-
superuser_token_headers: dict[str, str]
116+
normal_user_api_key_headers: dict[str, str]
117117

118118
def get(self, route: Route):
119119
return self.client.get(
120120
str(route),
121-
headers=self.superuser_token_headers,
121+
headers=self.normal_user_api_key_headers,
122122
)
123123

124124
def delete(self, route: Route):
125125
return self.client.delete(
126126
str(route),
127-
headers=self.superuser_token_headers,
127+
headers=self.normal_user_api_key_headers,
128128
)
129129

130130

@@ -158,5 +158,5 @@ def to_dict(self):
158158

159159

160160
@pytest.fixture
161-
def crawler(client: TestClient, superuser_token_headers: dict[str, str]):
162-
return WebCrawler(client, superuser_token_headers)
161+
def crawler(client: TestClient, normal_user_api_key_headers: dict[str, str]):
162+
return WebCrawler(client, normal_user_api_key_headers)

backend/app/tests/utils/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ def get_api_key_by_email(db: Session, email: EmailStr) -> str:
5454

5555

5656
def get_user_id_by_email(db: Session) -> int:
57-
user = get_user_by_email(session=db, email=settings.FIRST_SUPERUSER)
57+
user = get_user_by_email(session=db, email=settings.EMAIL_TEST_USER)
5858
return user.id
5959

6060

0 commit comments

Comments
 (0)