def test_get_asset_by_shotgun_id(self): self.shot.update({"shotgun_id": 1}) self.entity.update({"shotgun_id": 1}) asset = assets_service.get_asset_by_shotgun_id(1) self.assertEqual(asset["id"], str(self.entity.id)) assets_service.remove_asset(asset["id"]) self.assertRaises(AssetNotFoundException, assets_service.get_asset_by_shotgun_id, 1)
def post_processing(self): # We handle the fact that an asset can have multiple parents by using # the entities out field as a children field. for key in self.parent_map.keys(): try: asset = assets_service.get_asset_by_shotgun_id(key) data = {"entities_out": self.parent_map[key]} assets_service.update_asset(asset["id"], data) except AssetNotFoundException: pass return self.parent_map
def delete_func(self, asset): try: asset = assets_service.get_asset_by_shotgun_id(asset.shotgun_id) tasks = tasks_service.get_tasks_for_asset(asset["id"]) if self.is_working_files_linked(tasks): assets_service.cancel_asset(asset["id"]) else: for task in tasks: deletion_service.remove_task(task["id"]) assets_service.remove_asset(asset["id"]) return asset except AssetNotFoundException: return None
def post_processing(self): # We handle the fact that an asset can have multiple parents by using # the entities out field as a children field. for key in self.parent_map.keys(): try: asset = assets_service.get_asset_by_shotgun_id(key) asset = assets_service.get_full_asset(asset['id']) former_children = [ Entity.get(child_id) for child_id in asset.get('entities_out', []) ] children = list(set(self.parent_map[key] + former_children)) data = {"entities_out": children} assets_service.update_asset(asset["id"], data) assets_service.clear_asset_cache(asset["id"]) except AssetNotFoundException: pass return self.parent_map