-
Notifications
You must be signed in to change notification settings - Fork 206
SG-10151: set field visibility via API #209
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
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2678,6 +2678,72 @@ def test_multiple_latest_filters(self): | |
| self.sg.find, | ||
| "Version", filters, fields=fields, additional_filter_presets=additional_filters) | ||
|
|
||
| def test_modify_visibility(self): | ||
| """ | ||
| Ensure the visibility of a field can be edited via the API. | ||
| """ | ||
| # If the version of Shotgun is too old, do not run this test. | ||
| # TODO: Update this with the real version number once the feature is released. | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just highlighting this TODO. |
||
| if self.sg_version < (8, 5, 0): | ||
| warnings.warn("Test bypassed because SG server used does not support this feature.", FutureWarning) | ||
| return | ||
|
|
||
| field_display_name = "Project Visibility Test" | ||
| field_name = "sg_{0}".format(field_display_name.lower().replace(" ", "_")) | ||
|
|
||
| schema = self.sg.schema_field_read("Asset") | ||
| # Ensure the custom field exists. | ||
| if field_name not in schema: | ||
| self.sg.schema_field_create("Asset", "text", "Project Visibility Test") | ||
|
|
||
| # Grab any two projects that we can use for toggling the visible property with. | ||
| projects = self.sg.find("Project", [], order=[{"field_name": "id", "direction": "asc"}]) | ||
| project_1 = projects[0] | ||
| project_2 = projects[1] | ||
|
|
||
| # First, reset the field visibility in a known state, i.e. visible for both projects, | ||
| # in case the last test run failed midway through. | ||
| self.sg.schema_field_update("Asset", field_name, {"visible": True}, project_1) | ||
| self.assertEqual( | ||
| {"value": True, "editable": True}, | ||
| self.sg.schema_field_read("Asset", field_name, project_1)[field_name]["visible"] | ||
| ) | ||
| self.sg.schema_field_update("Asset", field_name, {"visible": True}, project_2) | ||
| self.assertEqual( | ||
| {"value": True, "editable": True}, | ||
| self.sg.schema_field_read("Asset", field_name, project_2)[field_name]["visible"] | ||
| ) | ||
|
|
||
| # Built-in fields should remain not editable. | ||
| self.assertFalse(self.sg.schema_field_read("Asset", "code")["code"]["visible"]["editable"]) | ||
|
|
||
| # Custom fields should be editable | ||
| self.assertEqual( | ||
| {"value": True, "editable": True}, | ||
| self.sg.schema_field_read("Asset", field_name)[field_name]["visible"] | ||
| ) | ||
|
|
||
| # Hide the field on project 1 | ||
| self.sg.schema_field_update("Asset", field_name, {"visible": False}, project_1) | ||
| # It should not be visible anymore. | ||
| self.assertEqual( | ||
| {"value": False, "editable": True}, | ||
| self.sg.schema_field_read("Asset", field_name, project_1)[field_name]["visible"] | ||
| ) | ||
|
|
||
| # The field should be visible on the second project. | ||
| self.assertEqual( | ||
| {"value": True, "editable": True}, | ||
| self.sg.schema_field_read("Asset", field_name, project_2)[field_name]["visible"] | ||
| ) | ||
|
|
||
| # Restore the visibility on the field. | ||
| self.sg.schema_field_update("Asset", field_name, {"visible": True}, project_1) | ||
| self.assertEqual( | ||
| {"value": True, "editable": True}, | ||
| self.sg.schema_field_read("Asset", field_name, project_1)[field_name]["visible"] | ||
| ) | ||
|
|
||
|
|
||
jfboismenu marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| def _has_unicode(data): | ||
| for k, v in data.items(): | ||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The server side simply expects the project to be passed in.