From 655f43acb2daf72029922e6237324cf7c1cf6e6f Mon Sep 17 00:00:00 2001 From: Pablo Cavallo Date: Tue, 12 Nov 2024 14:47:53 +0100 Subject: [PATCH 1/3] PNE-816: Make the project search endpoint to use the teams version one. --- src/citrine/resources/project.py | 6 +++++- tests/resources/test_project.py | 8 ++++---- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/citrine/resources/project.py b/src/citrine/resources/project.py index 01401dc36..b9d75da37 100644 --- a/src/citrine/resources/project.py +++ b/src/citrine/resources/project.py @@ -647,7 +647,11 @@ def search_all(self, search_params: Optional[Dict]) -> Iterable[Dict]: """ collections = [] - path = self._get_path(action="search") + if self.team_id is None: + path = "/projects/search" + else: + path = format_escaped_url("/teams/{team_id}/projects/search", team_id=self.team_id) + query_params = {'userId': ""} json = {} if search_params is None else {'search_params': search_params} diff --git a/tests/resources/test_project.py b/tests/resources/test_project.py index caae9496b..d5fd32e69 100644 --- a/tests/resources/test_project.py +++ b/tests/resources/test_project.py @@ -490,7 +490,7 @@ def test_search_all(collection: ProjectCollection): results = list(collection.search_all(search_params=search_params)) expected_call = FakeCall(method='POST', - path='/projects/search', + path=f'/teams/{collection.team_id}/projects/search', params={'userId': ''}, json={'search_params': { 'name': { @@ -513,7 +513,7 @@ def test_search_all_no_search_params(collection: ProjectCollection): result = list(collection.search_all(search_params=None)) expected_call = FakeCall(method='POST', - path='/projects/search', + path=f'/teams/{collection.team_id}/projects/search', params={'userId': ''}, json={}) @@ -539,7 +539,7 @@ def test_search_projects(collection: ProjectCollection): result = list(collection.search(search_params=search_params)) expected_call = FakeCall(method='POST', - path='/projects/search', + path=f'/teams/{collection.team_id}/projects/search', params={'userId': ''}, json={'search_params': { 'name': { @@ -561,7 +561,7 @@ def test_search_projects_no_search_params(collection: ProjectCollection): # Then result = list(collection.search()) - expected_call = FakeCall(method='POST', path='/projects/search', params={'userId': ''}, json={}) + expected_call = FakeCall(method='POST', path=f'/teams/{collection.team_id}/projects/search', params={'userId': ''}, json={}) assert 1 == collection.session.num_calls assert expected_call == collection.session.last_call From 9f29d5ececf2aeeebf6f80a16de51177245b49a4 Mon Sep 17 00:00:00 2001 From: Pablo Cavallo Date: Tue, 12 Nov 2024 14:47:53 +0100 Subject: [PATCH 2/3] PNE-816: Bumping version --- src/citrine/__version__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/citrine/__version__.py b/src/citrine/__version__.py index 425110fb6..92bbba870 100644 --- a/src/citrine/__version__.py +++ b/src/citrine/__version__.py @@ -1 +1 @@ -__version__ = "3.11.5" +__version__ = "3.11.6" From dd999da6db205e5c002d99a79c1c6afe521d6f92 Mon Sep 17 00:00:00 2001 From: Pablo Cavallo Date: Mon, 18 Nov 2024 12:45:17 +0100 Subject: [PATCH 3/3] PNE-816: Missing coverage --- tests/resources/test_project.py | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/tests/resources/test_project.py b/tests/resources/test_project.py index d5fd32e69..1b3bacb04 100644 --- a/tests/resources/test_project.py +++ b/tests/resources/test_project.py @@ -473,6 +473,30 @@ def test_list_projects_with_page_params(collection, session): assert expected_call == session.last_call +def test_search_all_no_team(session): + project_collection = ProjectCollection(session=session) + projects_data = ProjectDataFactory.create_batch(2) + project_name_to_match = projects_data[0]["name"] + + search_params = {"name": {"value": project_name_to_match, "search_method": "EXACT"}} + expected_response = [p for p in projects_data if p["name"] == project_name_to_match] + + project_collection.session.set_response({"projects": expected_response}) + + # Then + results = list(project_collection.search_all(search_params=search_params)) + + expected_call = FakeCall( + method="POST", + path="/projects/search", + params={"userId": ""}, + json={"search_params": search_params}, + ) + + assert 1 == project_collection.session.num_calls + assert expected_call == project_collection.session.last_call + assert 1 == len(results) + def test_search_all(collection: ProjectCollection): # Given projects_data = ProjectDataFactory.create_batch(2)