Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix get shared service by template name to filter by active service only #2947

Merged
Show file tree
Hide file tree
Changes from 3 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 api_app/_version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "0.6.1"
__version__ = "0.6.2"
2 changes: 1 addition & 1 deletion api_app/db/repositories/operations.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ def build_step_list(self, steps: List[OperationStep], resource_template_dict: di

# if it's a shared service, should be a singleton across the TRE, get it by template name
if step["resourceType"] == ResourceType.SharedService:
resource_for_step = resource_repo.get_resource_by_template_name(step["resourceTemplateName"])
resource_for_step = resource_repo.get_operating_resource_by_template_name(step["resourceTemplateName"])
tanya-borisova marked this conversation as resolved.
Show resolved Hide resolved

# if it's a workspace, find the parent workspace of where we are
if step["resourceType"] == ResourceType.Workspace:
Expand Down
4 changes: 2 additions & 2 deletions api_app/db/repositories/resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@ def get_resource_by_id(self, resource_id: UUID4) -> Resource:

return parse_obj_as(Resource, resource)

def get_resource_by_template_name(self, template_name: str) -> Resource:
query = f"SELECT TOP 1 * FROM c WHERE c.templateName = '{template_name}'"
def get_operating_resource_by_template_name(self, template_name: str) -> Resource:
query = f"SELECT TOP 1 * FROM c WHERE c.templateName = '{template_name}' AND {IS_OPERATING_SHARED_SERVICE}"
resources = self.query(query=query)
if not resources:
raise EntityDoesNotExist
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def test_create_operation_steps_from_multi_step_template(_, __, resource_repo, t
expected_op.message = "This resource is waiting to be deployed"

operations_repo.save_item = MagicMock()
resource_repo.get_resource_by_template_name = MagicMock(return_value=basic_shared_service)
resource_repo.get_operating_resource_by_template_name = MagicMock(return_value=basic_shared_service)
operation = operations_repo.create_operation_item(
resource_id="resource-id",
action="install",
Expand Down