def test_update_casting(self): self.shot_id = str(self.shot.id) self.asset_id = str(self.asset.id) self.asset_character_id = str(self.asset_character.id) casting = breakdown_service.get_casting(self.shot.id) self.assertListEqual(casting, []) new_casting = [{ "asset_id": self.asset_id, "nb_occurences": 1 }, { "asset_id": self.asset_character_id, "nb_occurences": 3 }] breakdown_service.update_casting(self.shot.id, new_casting) casting = breakdown_service.get_casting(self.shot.id) casting = sorted(casting, key=lambda x: x["nb_occurences"]) self.assertEquals(casting[0]["asset_id"], new_casting[0]["asset_id"]) self.assertEquals(casting[0]["nb_occurences"], new_casting[0]["nb_occurences"]) self.assertEquals(casting[1]["asset_id"], new_casting[1]["asset_id"]) self.assertEquals(casting[1]["nb_occurences"], new_casting[1]["nb_occurences"]) self.assertEquals(casting[1]["asset_name"], self.asset_character.name) self.assertEquals(casting[1]["asset_type_name"], self.asset_type_character.name) cast_in = breakdown_service.get_cast_in(self.asset_character.id) self.assertEquals(cast_in[0]["shot_name"], self.shot.name) self.assertEquals(cast_in[0]["sequence_name"], self.sequence.name) self.assertEquals(cast_in[0]["episode_name"], self.episode.name)
def get(self, shot_id): """ Resource to retrieve the casting of a given shot. """ shot = shots_service.get_shot(shot_id) user_service.check_project_access(shot["project_id"]) return breakdown_service.get_casting(shot_id)
def test_get_sequence_casting(self): self.shot_id = str(self.shot.id) self.sequence_id = str(self.sequence.id) self.asset_id = str(self.asset.id) self.asset_character_id = str(self.asset_character.id) casting = breakdown_service.get_casting(self.shot.id) self.assertListEqual(casting, []) new_casting = [ { "asset_id": self.asset_id, "nb_occurences": 1 }, { "asset_id": self.asset_character_id, "nb_occurences": 3 }, ] breakdown_service.update_casting(self.shot.id, new_casting) self.generate_fixture_shot("SH02") new_casting = [{"asset_id": self.asset_id, "nb_occurences": 1}] breakdown_service.update_casting(self.shot.id, new_casting) casting = breakdown_service.get_sequence_casting(self.sequence.id) self.maxDiff = 10000 self.assertTrue(self.shot_id in casting) self.assertTrue(str(self.shot.id) in casting) self.assertEqual(len(casting[self.shot_id]), 2) self.assertEqual(len(casting[str(self.shot.id)]), 1)
def get(self, asset_id): """ Resource to retrieve the casting of a given asset. """ asset = assets_service.get_asset(asset_id) user_service.check_project_access(asset["project_id"]) return breakdown_service.get_casting(asset_id)
def get(self, shot_id): """ Resource to retrieve the casting of a given shot. """ shot = shots_service.get_shot(shot_id) if not permissions.has_manager_permissions(): user_service.check_has_task_related(shot["project_id"]) return breakdown_service.get_casting(shot_id)
def get(self, asset_id): """ Resource to retrieve the casting of a given asset. --- tags: - Assets parameters: - in: path name: asset_id required: True schema: type: UUID example: a24a6ea4-ce75-4665-a070-57453082c25 responses: 200: description: Casting of given asset """ asset = assets_service.get_asset(asset_id) user_service.check_project_access(asset["project_id"]) user_service.check_entity_access(asset_id) return breakdown_service.get_casting(asset_id)
def test_get_episode_casting(self): casting = breakdown_service.get_casting(self.shot.id) self.assertListEqual(casting, []) new_casting = [ { "asset_id": self.asset_id, "nb_occurences": 1 }, { "asset_id": self.asset_character_id, "nb_occurences": 3 }, ] self.put( "/data/projects/%s/entities/%s/casting" % (self.project_id, self.episode_id), new_casting, ) casting = self.get("/data/projects/%s/entities/%s/casting" % (self.project_id, self.episode_id)) self.assertEquals(len(casting), 2) self.assertEquals(casting[0]["asset_name"], "Rabbit") self.assertEquals(casting[1]["asset_name"], "Tree")
def get(self, project_id, entity_id): """ Resource to retrieve the casting of a given entity. """ user_service.check_project_access(project_id) return breakdown_service.get_casting(entity_id)