Skip to content

Commit

Permalink
Add test for query params
Browse files Browse the repository at this point in the history
  • Loading branch information
aristizabal95 committed Dec 13, 2024
1 parent d4fdd73 commit f5bd343
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions server/benchmark/tests/test_.py
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,30 @@ def test_generic_get_benchmark_list(self):
self.assertEqual(len(response.data["results"]), 1)
self.assertEqual(response.data["results"][0]["id"], benchmark_id)

@parameterized.expand([
({"name": "bmk2"}, 1),
({"name": "string", "owner": 3}, 1),
({"name": "nonexistent"}, 0),
({"is_valid": True}, 2),
({"data_preparation_mlcube": 2}, 1),
])
def test_get_with_query_params(self, query_dict, expected_num_results):
# Arrange
# Create another benchmark
benchmark = self.mock_benchmark(
self.ref_model["id"], self.prep["id"], self.eval["id"], name="bmk2"
)
benchmark = self.create_benchmark(benchmark).data
query_str = "&".join([f"{k}={v}" for k, v in query_dict.items()])

# Act
query_url = self.url + f"?{query_str}"
response = self.client.get(query_url)

# Assert
self.assertEqual(response.status_code, status.HTTP_200_OK)
self.assertEqual(len(response.data["results"]), expected_num_results)


class PermissionTest(BenchmarkTest):
"""Test module for permissions of /benchmarks/ endpoint
Expand Down

0 comments on commit f5bd343

Please sign in to comment.