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

More ownership classes #2999

Closed
wants to merge 5 commits into from
Closed

More ownership classes #2999

wants to merge 5 commits into from

Conversation

ericvergnaud
Copy link
Contributor

Changes

Existing Ownership classes deal with inventory objects.
We sometimes also need to get ownership from workspace objects.
This PR implements these for Job and ClusterDetails

Linked issues

Progresses #1415

Functionality

None

Tests

  • added unit tests
  • added integration tests

Copy link

✅ 21/21 passed, 4 skipped, 27m13s total

Running from acceptance #6835

Copy link
Contributor

@asnare asnare left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM; a few minor quibbles but more questions of preference than anything blocking.

assert ownership.owner_of(my_cluster_record) == ws.current_user.me().user_name
assert ownership.owner_of(their_cluster_record) == another_user.user_name
info_ownership = ClusterInfoOwnership(administrator_locator)
assert info_ownership.owner_of(my_cluster_record) == ws.current_user.me().user_name
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ws.current_user.me() is a REST call, so it's probably polite to factor that out as a local variable rather than call it twice.

admin_locator.get_workspace_administrator.return_value = "an_admin"

ownership = ClusterDetailsOwnership(admin_locator)
owner = ownership.owner_of(ClusterDetails(cluster_id="1"))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know the default for creator_name is None, but I think I prefer to explicitly provide it because it's an important detail for what we're testing.

admin_locator.get_workspace_administrator.return_value = "an_admin"

ownership = JobOwnership(admin_locator)
owner = ownership.owner_of(Job(job_id=1))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Likewise here with creator_user_name=None.

@@ -192,6 +192,16 @@ def _maybe_direct_owner(self, record: ClusterInfo) -> str | None:
return record.creator


class ClusterDetailsOwnership(Ownership[ClusterDetails]):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

where is it coming from? we don't have a concept of cluster details in our object model - we just have a cluster.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants