mirror of
https://github.com/khoaliber/khoj.git
synced 2026-03-06 13:22:12 +00:00
Split /api/v1/index/update into /api/content PUT, PATCH API endpoints
- This utilizes PUT, PATCH HTTP method semantics to remove need for the "regenerate" query param and "/update" url suffix - This should make the url more succinct and API request intent more understandable by using existing HTTP method semantics
This commit is contained in:
@@ -75,7 +75,7 @@ def test_index_update_with_no_auth_key(client):
|
||||
files = get_sample_files_data()
|
||||
|
||||
# Act
|
||||
response = client.post("/api/v1/index/update", files=files)
|
||||
response = client.patch("/api/content", files=files)
|
||||
|
||||
# Assert
|
||||
assert response.status_code == 403
|
||||
@@ -89,7 +89,7 @@ def test_index_update_with_invalid_auth_key(client):
|
||||
headers = {"Authorization": "Bearer kk-invalid-token"}
|
||||
|
||||
# Act
|
||||
response = client.post("/api/v1/index/update", files=files, headers=headers)
|
||||
response = client.patch("/api/content", files=files, headers=headers)
|
||||
|
||||
# Assert
|
||||
assert response.status_code == 403
|
||||
@@ -130,7 +130,7 @@ def test_index_update_big_files(client):
|
||||
headers = {"Authorization": "Bearer kk-secret"}
|
||||
|
||||
# Act
|
||||
response = client.post("/api/v1/index/update", files=files, headers=headers)
|
||||
response = client.patch("/api/content", files=files, headers=headers)
|
||||
|
||||
# Assert
|
||||
assert response.status_code == 429
|
||||
@@ -146,7 +146,7 @@ def test_index_update_medium_file_unsubscribed(client, api_user4: KhojApiUser):
|
||||
headers = {"Authorization": f"Bearer {api_token}"}
|
||||
|
||||
# Act
|
||||
response = client.post("/api/v1/index/update", files=files, headers=headers)
|
||||
response = client.patch("/api/content", files=files, headers=headers)
|
||||
|
||||
# Assert
|
||||
assert response.status_code == 429
|
||||
@@ -162,7 +162,7 @@ def test_index_update_normal_file_unsubscribed(client, api_user4: KhojApiUser):
|
||||
headers = {"Authorization": f"Bearer {api_token}"}
|
||||
|
||||
# Act
|
||||
response = client.post("/api/v1/index/update", files=files, headers=headers)
|
||||
response = client.patch("/api/content", files=files, headers=headers)
|
||||
|
||||
# Assert
|
||||
assert response.status_code == 200
|
||||
@@ -177,7 +177,7 @@ def test_index_update_big_files_no_billing(client):
|
||||
headers = {"Authorization": "Bearer kk-secret"}
|
||||
|
||||
# Act
|
||||
response = client.post("/api/v1/index/update", files=files, headers=headers)
|
||||
response = client.patch("/api/content", files=files, headers=headers)
|
||||
|
||||
# Assert
|
||||
assert response.status_code == 200
|
||||
@@ -191,7 +191,7 @@ def test_index_update(client):
|
||||
headers = {"Authorization": "Bearer kk-secret"}
|
||||
|
||||
# Act
|
||||
response = client.post("/api/v1/index/update", files=files, headers=headers)
|
||||
response = client.patch("/api/content", files=files, headers=headers)
|
||||
|
||||
# Assert
|
||||
assert response.status_code == 200
|
||||
@@ -208,8 +208,8 @@ def test_index_update_fails_if_more_than_1000_files(client, api_user4: KhojApiUs
|
||||
headers = {"Authorization": f"Bearer {api_token}"}
|
||||
|
||||
# Act
|
||||
ok_response = client.post("/api/v1/index/update", files=files[:1000], headers=headers)
|
||||
bad_response = client.post("/api/v1/index/update", files=files, headers=headers)
|
||||
ok_response = client.patch("/api/content", files=files[:1000], headers=headers)
|
||||
bad_response = client.patch("/api/content", files=files, headers=headers)
|
||||
|
||||
# Assert
|
||||
assert ok_response.status_code == 200
|
||||
@@ -226,7 +226,7 @@ def test_regenerate_with_valid_content_type(client):
|
||||
headers = {"Authorization": "Bearer kk-secret"}
|
||||
|
||||
# Act
|
||||
response = client.post(f"/api/v1/index/update?t={content_type}", files=files, headers=headers)
|
||||
response = client.patch(f"/api/content?t={content_type}", files=files, headers=headers)
|
||||
|
||||
# Assert
|
||||
assert response.status_code == 200, f"Returned status: {response.status_code} for content type: {content_type}"
|
||||
@@ -243,7 +243,7 @@ def test_regenerate_with_github_fails_without_pat(client):
|
||||
files = get_sample_files_data()
|
||||
|
||||
# Act
|
||||
response = client.post(f"/api/v1/index/update?t=github", files=files, headers=headers)
|
||||
response = client.patch(f"/api/content?t=github", files=files, headers=headers)
|
||||
|
||||
# Assert
|
||||
assert response.status_code == 200, f"Returned status: {response.status_code} for content type: github"
|
||||
|
||||
Reference in New Issue
Block a user