def find_mock_impl(*args, **kwargs): mgr = ToolkitManager() mgr.pipeline_configuration = 1 with self.assertRaisesRegexp( sgtk.bootstrap.TankBootstrapError, "Can't enumerate pipeline configurations matching a specific id." ): mgr.get_pipeline_configurations(None)
def find_mock_impl(*args, **kwargs): mgr = ToolkitManager() mgr.pipeline_configuration = 1 with self.assertRaisesRegexp( sgtk.bootstrap.TankBootstrapError, "Can't enumerate pipeline configurations matching a specific id." ): mgr.get_pipeline_configurations(None)
def test_basic_execution(self): """ Test basic execution and return value structure """ cc = self.mockgun.create( "PipelineConfiguration", dict( code="Primary", project=self._project, users=[], windows_path=None, mac_path=None, linux_path=None, plugin_ids="basic.*", descriptor= "sgtk:descriptor:app_store?name=tk-config-basic&version=v1.2.3", uploaded_config=None, ), ) mgr = ToolkitManager(self._mocked_sg_user) mgr.plugin_id = "basic.test" configs = mgr.get_pipeline_configurations(self._project) expected_fields = [ "descriptor_source_uri", "name", "project", "descriptor", "type", "id", ] self.assertEqual(len(configs), 1) config = configs[0] self.assertEqual(sorted(expected_fields), sorted(config.keys())) self.assertEqual(config["id"], cc["id"]) self.assertEqual(config["type"], "PipelineConfiguration") self.assertEqual(config["name"], "Primary") self.assertEqual(config["project"], self._project) self.assertEqual( config["descriptor"].get_uri(), "sgtk:descriptor:app_store?name=tk-config-basic&version=v1.2.3", ) self.assertEqual( config["descriptor_source_uri"], "sgtk:descriptor:app_store?name=tk-config-basic&version=v1.2.3", ) # with a different plugin id we won't get anything mgr.plugin_id = "something.else" configs = mgr.get_pipeline_configurations(self._project) self.assertEqual(len(configs), 0)
def test_override_logic(self): """ Tests that paths override descriptors """ self.mockgun.create( "PipelineConfiguration", dict( code="Primary", project=self._project, users=[], windows_path="/path", mac_path="/path", linux_path="/path", plugin_ids="basic.*", descriptor= "sgtk:descriptor:app_store?name=tk-config-basic&version=v1.2.3", uploaded_config=None, )) mgr = ToolkitManager(self._mocked_sg_user) mgr.plugin_id = "basic.test" configs = mgr.get_pipeline_configurations(self._project) config = configs[0] self.assertEqual( config["descriptor"].get_uri(), "sgtk:descriptor:path?linux_path=/path&mac_path=/path&windows_path=\\path" ) self.assertEqual(config["descriptor_source_uri"], None)
def test_latest_tracking_descriptor(self, _): """ Test descriptors tracking latest """ self.mockgun.create( "PipelineConfiguration", dict( code="Primary", project=self._project, users=[], windows_path=None, mac_path=None, linux_path=None, plugin_ids="basic.*", descriptor="sgtk:descriptor:app_store?name=tk-config-basic", uploaded_config=None, )) mgr = ToolkitManager(self._mocked_sg_user) mgr.plugin_id = "basic.test" configs = mgr.get_pipeline_configurations(self._project) config = configs[0] self.assertTrue(isinstance(config["descriptor"], Mock)) self.assertEqual(config["descriptor_source_uri"], "sgtk:descriptor:app_store?name=tk-config-basic")
def test_override_logic(self): """ Tests that paths override descriptors """ self.mockgun.create( "PipelineConfiguration", dict( code="Primary", project=self._project, users=[], windows_path="/path", mac_path="/path", linux_path="/path", plugin_ids="basic.*", descriptor="sgtk:descriptor:app_store?name=tk-config-basic&version=v1.2.3", uploaded_config=None, ) ) mgr = ToolkitManager(self._mocked_sg_user) mgr.plugin_id = "basic.test" configs = mgr.get_pipeline_configurations(self._project) config = configs[0] self.assertEqual( config["descriptor"].get_uri(), "sgtk:descriptor:path?linux_path=/path&mac_path=/path&windows_path=%5Cpath" ) self.assertEqual(config["descriptor_source_uri"], None)
def test_latest_tracking_descriptor(self, _): """ Test descriptors tracking latest """ self.mockgun.create( "PipelineConfiguration", dict( code="Primary", project=self._project, users=[], windows_path=None, mac_path=None, linux_path=None, plugin_ids="basic.*", descriptor="sgtk:descriptor:app_store?name=tk-config-basic", uploaded_config=None, ) ) mgr = ToolkitManager(self._mocked_sg_user) mgr.plugin_id = "basic.test" configs = mgr.get_pipeline_configurations(self._project) config = configs[0] self.assertTrue(isinstance(config["descriptor"], Mock)) self.assertEqual(config["descriptor_source_uri"], "sgtk:descriptor:app_store?name=tk-config-basic")
def test_basic_execution(self): """ Test basic execution and return value structure """ cc = self.mockgun.create( "PipelineConfiguration", dict( code="Primary", project=self._project, users=[], windows_path=None, mac_path=None, linux_path=None, plugin_ids="basic.*", descriptor="sgtk:descriptor:app_store?name=tk-config-basic&version=v1.2.3", uploaded_config=None, ) ) mgr = ToolkitManager(self._mocked_sg_user) mgr.plugin_id = "basic.test" configs = mgr.get_pipeline_configurations(self._project) expected_fields = [ "descriptor_source_uri", "name", "project", "descriptor", "type", "id" ] self.assertEqual(len(configs), 1) config = configs[0] self.assertEqual(sorted(expected_fields), sorted(config.keys())) self.assertEqual(config["id"], cc["id"]) self.assertEqual(config["type"], "PipelineConfiguration") self.assertEqual(config["name"], "Primary") self.assertEqual(config["project"], self._project) self.assertEqual(config["descriptor"].get_uri(), "sgtk:descriptor:app_store?name=tk-config-basic&version=v1.2.3") self.assertEqual(config["descriptor_source_uri"], "sgtk:descriptor:app_store?name=tk-config-basic&version=v1.2.3") # with a different plugin id we won't get anything mgr.plugin_id = "something.else" configs = mgr.get_pipeline_configurations(self._project) self.assertEqual(len(configs), 0)
def test_user_filters(self): """ Test user based sandboxes """ self.mockgun.create( "PipelineConfiguration", dict( code="Doe Dev", project=self._project, users=[self._john_doe], windows_path=None, mac_path=None, linux_path=None, plugin_ids="basic.*", descriptor= "sgtk:descriptor:app_store?name=tk-config-basic&version=v1.2.3", uploaded_config=None, ), ) self.mockgun.create( "PipelineConfiguration", dict( code="Smith Dev", project=self._project, users=[self._john_smith], windows_path=None, mac_path=None, linux_path=None, plugin_ids="basic.*", descriptor= "sgtk:descriptor:app_store?name=tk-config-basic&version=v1.2.3", uploaded_config=None, ), ) mgr = ToolkitManager(self._mocked_sg_user) mgr.plugin_id = "basic.test" configs = mgr.get_pipeline_configurations(self._project) self.assertEqual(len(configs), 1) config = configs[0] self.assertEqual(config["name"], "Doe Dev")
def test_user_filters(self): """ Test user based sandboxes """ self.mockgun.create( "PipelineConfiguration", dict( code="Doe Dev", project=self._project, users=[self._john_doe], windows_path=None, mac_path=None, linux_path=None, plugin_ids="basic.*", descriptor="sgtk:descriptor:app_store?name=tk-config-basic&version=v1.2.3", uploaded_config=None, ) ) self.mockgun.create( "PipelineConfiguration", dict( code="Smith Dev", project=self._project, users=[self._john_smith], windows_path=None, mac_path=None, linux_path=None, plugin_ids="basic.*", descriptor="sgtk:descriptor:app_store?name=tk-config-basic&version=v1.2.3", uploaded_config=None, ) ) mgr = ToolkitManager(self._mocked_sg_user) mgr.plugin_id = "basic.test" configs = mgr.get_pipeline_configurations(self._project) self.assertEqual(len(configs), 1) config = configs[0] self.assertEqual(config["name"], "Doe Dev")