Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/citrine/__version__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "3.11.5"
__version__ = "3.11.6"
6 changes: 5 additions & 1 deletion src/citrine/resources/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down
32 changes: 28 additions & 4 deletions tests/resources/test_project.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -490,7 +514,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': {
Expand All @@ -513,7 +537,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={})

Expand All @@ -539,7 +563,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': {
Expand All @@ -561,7 +585,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
Expand Down