From d555dfdfde16dc7c350d448582e838c16e6ded35 Mon Sep 17 00:00:00 2001 From: Sami Nouidri Date: Mon, 25 Nov 2024 15:51:54 +0100 Subject: [PATCH] PB-224: Added unit test to test new provider filtering functionality --- .../tests_10/test_collections_endpoint.py | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/app/tests/tests_10/test_collections_endpoint.py b/app/tests/tests_10/test_collections_endpoint.py index 3c36e1d1..6ed9fc58 100644 --- a/app/tests/tests_10/test_collections_endpoint.py +++ b/app/tests/tests_10/test_collections_endpoint.py @@ -70,6 +70,26 @@ def test_single_collection_endpoint(self): self.check_stac_collection(self.collection_1.json, response_json) + def test_filtering_by_provider(self): + collection_with_provider = self.factory.create_sample( + sample='collection-1', + name='collection-provider', + providers=[{ + 'name': 'test-provider' + }], + db_create=True + ) + + response = self.client.get(f"/{STAC_BASE_V}/collections?provider=test-provider") + response_json = response.json() + self.assertStatusCode(200, response) + + self.assertEqual( + len(response_json['collections']), + 1, + msg=f"Only one collection should be returned. Response: {response_json}" + ) + @mock_s3_asset_file def test_single_collection_assets_endpoint(self): asset_count = 3