mirror of
https://github.com/khoaliber/khoj.git
synced 2026-03-02 13:18:18 +00:00
Add additional unit tests to verify behavior of unsubscribed/subscribed users
This commit is contained in:
@@ -140,6 +140,38 @@ def test_index_update_big_files(client):
|
||||
assert response.status_code == 429
|
||||
|
||||
|
||||
# ----------------------------------------------------------------------------------------------------
|
||||
@pytest.mark.django_db(transaction=True)
|
||||
def test_index_update_medium_file_unsubscribed(client, api_user4: KhojApiUser):
|
||||
# Arrange
|
||||
api_token = api_user4.token
|
||||
state.billing_enabled = True
|
||||
files = get_medium_size_sample_files_data()
|
||||
headers = {"Authorization": f"Bearer {api_token}"}
|
||||
|
||||
# Act
|
||||
response = client.post("/api/v1/index/update", files=files, headers=headers)
|
||||
|
||||
# Assert
|
||||
assert response.status_code == 429
|
||||
|
||||
|
||||
# ----------------------------------------------------------------------------------------------------
|
||||
@pytest.mark.django_db(transaction=True)
|
||||
def test_index_update_normal_file_unsubscribed(client, api_user4: KhojApiUser):
|
||||
# Arrange
|
||||
api_token = api_user4.token
|
||||
state.billing_enabled = True
|
||||
files = get_sample_files_data()
|
||||
headers = {"Authorization": f"Bearer {api_token}"}
|
||||
|
||||
# Act
|
||||
response = client.post("/api/v1/index/update", files=files, headers=headers)
|
||||
|
||||
# Assert
|
||||
assert response.status_code == 200
|
||||
|
||||
|
||||
@pytest.mark.django_db(transaction=True)
|
||||
def test_index_update_big_files_no_billing(client):
|
||||
# Arrange
|
||||
@@ -460,3 +492,13 @@ def get_big_size_sample_files_data():
|
||||
("path/to/filename.org", big_text, "text/org"),
|
||||
)
|
||||
]
|
||||
|
||||
|
||||
def get_medium_size_sample_files_data():
|
||||
big_text = "a" * (10 * 1024 * 1024) # a string of approximately 10 MB
|
||||
return [
|
||||
(
|
||||
"files",
|
||||
("path/to/filename.org", big_text, "text/org"),
|
||||
)
|
||||
]
|
||||
|
||||
Reference in New Issue
Block a user