def test_add_asset_link(self): self.generate_fixture_asset_types() self.generate_fixture_asset_character() assets_service.add_asset_link(self.asset.id, self.asset_character.id) asset = assets_service.get_asset_with_relations(self.asset.id) self.assertEqual(asset["entities_out"][0], str(self.asset_character.id))
def test_import_asset(self): self.generate_fixture_asset_type() self.generate_fixture_project_status() self.generate_fixture_project() self.generate_fixture_sequence() self.generate_fixture_shot() self.shot.update({"shotgun_id": 3}) self.load_fixture("projects") self.load_fixture("assets") sg_asset = { "code": "Cake", "description": "yellow cake", "project": { "type": "Project", "id": 1, "name": "Agent 327" }, "sg_asset_type": "Props", "type": "Asset", "parents": [{ "type": "Asset", "id": 1 }], "id": 3, } api_path = "/import/shotgun/assets" self.assets = self.post(api_path, [sg_asset], 200) self.assertEqual(len(self.assets), 1) self.assets = self.get("data/assets/all") self.assertEqual(len(self.assets), 3) assets = sorted(self.assets, key=lambda x: x["name"]) asset = assets[0] asset = assets_service.get_asset_with_relations(asset["id"]) project = Project.get_by(shotgun_id=sg_asset["project"]["id"]) self.assertEqual(asset["description"], sg_asset["description"]) self.assertEqual(asset["shotgun_id"], sg_asset["id"]) self.assertEqual(asset["project_id"], str(project.id)) self.assertEqual(len(asset["entities_out"]), 0) parent = Entity.get_by(shotgun_id=1) self.assertEqual(str(parent.entities_out[0].id), asset["id"])