|
| 1 | +# Copyright (c) 2026 Autodesk. |
| 2 | +# |
| 3 | +# CONFIDENTIAL AND PROPRIETARY |
| 4 | +# |
| 5 | +# This work is provided "AS IS" and subject to the ShotGrid Pipeline Toolkit |
| 6 | +# Source Code License included in this distribution package. See LICENSE. |
| 7 | +# By accessing, using, copying or modifying this work you indicate your |
| 8 | +# agreement to the ShotGrid Pipeline Toolkit Source Code License. All rights |
| 9 | +# not expressly granted therein are reserved by Autodesk. |
| 10 | +import os |
| 11 | + |
| 12 | +from publish_api_test_base import PublishApiTestBase |
| 13 | +from tank_test.tank_test_base import setUpModule # noqa |
| 14 | + |
| 15 | + |
| 16 | +class TestDisplayHook(PublishApiTestBase): |
| 17 | + def test_attributes_exist(self): |
| 18 | + from sgtk import Hook |
| 19 | + |
| 20 | + assert hasattr(self.app, "display_hook") |
| 21 | + assert isinstance(self.app.display_hook, Hook) |
| 22 | + for prop in ("action_name", "button_name", "menu_name", "menu_properties"): |
| 23 | + assert hasattr(self.app.display_hook, prop) |
| 24 | + |
| 25 | + def test_matches_v2_10_7(self): |
| 26 | + """Test new display hook properties match same values from on v2.10.7 tag. |
| 27 | +
|
| 28 | + This ensures drop-in compatibility with existing code and configurations. |
| 29 | + """ |
| 30 | + app = self.app |
| 31 | + |
| 32 | + # tk-multi-publish2/app.py:MultiPublish2.init_app() |
| 33 | + from tank.util import sgre as re |
| 34 | + |
| 35 | + display_name = app.get_setting("display_name") |
| 36 | + command_name = display_name.lower() |
| 37 | + command_name = re.sub(r"[^0-9a-zA-Z]+", "_", command_name) |
| 38 | + menu_caption = "%s..." % display_name |
| 39 | + menu_options = { |
| 40 | + "short_name": command_name, |
| 41 | + "description": "Publishing of data to Flow Production Tracking", |
| 42 | + "icons": { |
| 43 | + "dark": {"png": os.path.join(app.disk_location, "icon_256_dark.png")} |
| 44 | + }, |
| 45 | + } |
| 46 | + # self.engine.register_command(menu_caption, cb, menu_options) |
| 47 | + assert app.display_hook.menu_name == menu_caption |
| 48 | + assert app.display_hook.menu_properties == menu_options |
| 49 | + |
| 50 | + # tk-multi-publish2/python/tk_multi_publish2/dialog.py:AppDialog.__init__() |
| 51 | + display_action_name = app.get_setting("display_action_name") |
| 52 | + # self._display_action_name = self._bundle.get_setting("display_action_name") |
| 53 | + # self.ui.publish.setText(self._display_action_name) |
| 54 | + assert app.display_hook.action_name == display_action_name |
| 55 | + assert app.display_hook.button_name == display_action_name |
0 commit comments