def test_import_task(self): self.load_task() self.assertEqual(len(self.tasks), 1) self.tasks = self.get("data/tasks") self.assertEqual(len(self.tasks), 1) task = self.tasks[0] project = Project.get_by(name=self.sg_task["project"]["name"]) task_type = \ TaskType.get_by(name=self.sg_task["step"]["name"].split(" ")[1]) task_status = TaskStatus.get_by( short_name=self.sg_task["sg_status_list"]) assets = asset_info.get_assets( {"shotgun_id": self.sg_task["entity"]["id"]}) entity = assets[0] assigner = Person.get_by( last_name=self.sg_task["created_by"]["name"].split(" ")[1]) assignee = Person.get_by( last_name=self.sg_task["task_assignees"][0]["name"].split(" ")[1]) self.assertEqual(task["name"], self.sg_task["cached_display_name"]) self.assertEqual(task["duration"], self.sg_task["duration"]) self.assertEqual(task["shotgun_id"], self.sg_task["id"]) self.assertEqual(task["project_id"], str(project.id)) self.assertEqual(task["task_type_id"], str(task_type.id)) self.assertEqual(task["task_status_id"], str(task_status.id)) self.assertEqual(task["entity_id"], str(entity.id)) self.assertEqual(task["assigner_id"], str(assigner.id)) self.assertEqual(task["assignees"][0], str(assignee.id))
def test_remove_asset(self): self.generate_fixture_entity() path = "data/projects/%s/asset-types/%s/assets/%s" % ( self.project.id, self.entity_type.id, self.entity.id) self.delete(path) assets = asset_info.get_assets() self.assertEquals(len(assets), 0)
def get(self, project_id): """ Retrieve all assets for given project. """ criterions = query.get_query_criterions_from_request(request) criterions["project_id"] = project_id assets = asset_info.get_assets(criterions) return Entity.serialize_list(assets)
def test_create_asset(self): events.register("asset:new", "handle_event", self) self.asset_data = {"name": "car", "description": "Test description"} path = "data/projects/%s/asset-types/%s/assets/new" % ( self.project.id, self.entity_type.id) asset = self.post(path, self.asset_data) assets = asset_info.get_assets() self.assertIsNotNone(asset.get("id", None)) self.assertEquals(len(assets), 1) self.assertEquals(assets[0].name, self.asset_data["name"].capitalize()) self.assertEquals(assets[0].description, self.asset_data["description"])
def save_entity(self, data): entity = None entities = asset_info.get_assets({"shotgun_id": data["shotgun_id"]}) if len(entities) > 0: entity = entities[0] if entity is None: entity = Entity(**data) entity.save() current_app.logger.info("Entity created: %s" % entity) else: entity.update(data) current_app.logger.info("Entity updated: %s" % entity) return entity
def get_asset_map(self): assets = asset_info.get_assets() return {asset.shotgun_id: asset.id for asset in assets}
def test_get_assets(self): assets = asset_info.get_assets() self.assertEqual(len(assets), 1) self.assertEqual(assets[0].name, "Tree")