Skip to content

Commit

Permalink
fix: search as client test (#83)
Browse files Browse the repository at this point in the history
  • Loading branch information
aatmanvaidya authored Feb 16, 2024
1 parent f6987a6 commit 9855e96
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 6 deletions.
Binary file not shown.
Binary file not shown.
Binary file added src/api/tests/sample_data/people.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/api/tests/sample_data/sample-cat-video.mp4
Binary file not shown.
9 changes: 5 additions & 4 deletions src/api/tests/test_index_api_as_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,28 +80,29 @@ def testIndexVideo(self):
# "media": open("sample_data/simple-text.txt", "rb"),
"data": json.dumps(data),
}
# axios.post("endpoint", data)
response = requests.post(url, json=data, headers=headers)
print(response.text)
self.assertEqual(response.status_code, 200)

@skip
def testIndexEnqueueImage(self):
url = API_URL + "/search"
# headers = {"Content-Type": "application/json"}
headers = {"Content-Type": "multipart/form-data"}
data = {
"post": {
"id": "1234",
"media_type": "image",
"media_url": "https://fs.tattle.co.in/service/kosh/file/c8709f21-bd7d-4e22-af14-50ad8a429f84",
"media_url": "https://raw.githubusercontent.com/tattle-made/feluda/master/src/api/core/operators/sample_data/people.jpg",
"datasource_id": "asdfasdf-asdfasdf-asdf",
"client_id": "123-12312",
},
"metadata": {"domain": "hate_speech", "type": ["gender", "caste"]},
"config": {"mode": "enqueue", "version": "0.1"},
}
files = {"data": json.dumps(data)}
response = requests.post(url, files=files)
print(response.json())
response = requests.post(url, json=data, headers=headers)
print(response.text)
self.assertEqual(response.status_code, 200)

@skip
Expand Down
4 changes: 2 additions & 2 deletions src/api/tests/test_search_api_as_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def testSearchRawQuery(self):
def testSearchImage(self):
url = API_URL + "/search"
data = {"query_type": "image"}
with open("sample_data/c8709f21-bd7d-4e22-af14-50ad8a429f84.jpeg", "rb") as file:
with open("sample_data/people.jpg", "rb") as file:
data = {"data": json.dumps(data)}
files = {"media": file}
response = requests.post(url, data=data, files=files)
Expand All @@ -39,7 +39,7 @@ def testSearchImage(self):
# @skip
def testIndexVideo(self):
url = API_URL + "/search"
with open("sample_data/07ba4a2f-c0a2-44ba-96d8-7b4cc94c8ee7.mp4", "rb") as file:
with open("sample_data/sample-cat-video.mp4", "rb") as file:
data = {"data": json.dumps({"query_type": "video"})}
files = {"media": file}
response = requests.post(url, data=data, files=files)
Expand Down

0 comments on commit 9855e96

Please sign in to comment.