Esempio n. 1
0
    def test_get_asset_type_casting(self):
        self.shot_id = str(self.shot.id)
        self.sequence_id = str(self.sequence.id)
        self.asset_type_environment_id = str(self.asset_type_environment.id)
        self.asset_props_id = str(self.asset.id)
        self.asset_character_id = str(self.asset_character.id)
        self.generate_fixture_asset(
            "Forest", "", self.asset_type_environment_id
        )
        self.forest_id = str(self.asset.id)

        casting = breakdown_service.get_asset_type_casting(
            self.project_id, self.asset_type_environment_id
        )
        self.assertDictEqual(casting, {})
        new_casting = [
            {"asset_id": self.asset_props_id, "nb_occurences": 3},
            {"asset_id": self.asset_character_id, "nb_occurences": 1},
        ]
        breakdown_service.update_casting(self.asset.id, new_casting)
        self.generate_fixture_asset("Park", "", self.asset_type_environment_id)
        new_casting = [{"asset_id": self.asset_props_id, "nb_occurences": 1}]
        breakdown_service.update_casting(self.asset.id, new_casting)
        casting = breakdown_service.get_asset_type_casting(
            self.project_id, self.asset_type_environment_id
        )
        self.maxDiff = 10000
        self.assertTrue(self.forest_id in casting)
        self.assertTrue(str(self.asset.id) in casting)
        self.assertEqual(len(casting[self.forest_id]), 2)
        self.assertEqual(len(casting[str(self.asset.id)]), 1)
Esempio n. 2
0
    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)
Esempio n. 3
0
    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)
Esempio n. 4
0
 def put(self, shot_id):
     """
     Resource to allow the modification of assets linked to a shot.
     """
     casting = request.json
     permissions.check_manager_permissions()
     return breakdown_service.update_casting(shot_id, casting)
Esempio n. 5
0
 def put(self, project_id, entity_id):
     """
     Resource to allow the modification of assets linked to an entity.
     """
     casting = request.json
     user_service.check_manager_project_access(project_id)
     return breakdown_service.update_casting(entity_id, casting)
Esempio n. 6
0
 def put(self, asset_id):
     """
     Resource to allow the modification of assets linked to a asset.
     """
     casting = request.json
     asset = assets_service.get_asset(asset_id)
     user_service.check_manager_project_access(asset["project_id"])
     return breakdown_service.update_casting(asset_id, casting)
Esempio n. 7
0
 def put(self, shot_id):
     """
     Resource to allow the modification of assets linked to a shot.
     """
     casting = request.json
     shot = shots_service.get_shot(shot_id)
     user_service.check_project_access(shot["project_id"])
     return breakdown_service.update_casting(shot_id, casting)
Esempio n. 8
0
 def put(self, asset_id):
     """
     Resource to allow the modification of assets linked to a asset.
     ---
     tags:
         - Assets
     parameters:
       - in: path
         name: asset_id
         required: True
         schema:
             type: UUID
             example: a24a6ea4-ce75-4665-a070-57453082c25       
     responses:
         200:
             description: Modification of assets linked to given asset    
     """
     casting = request.json
     asset = assets_service.get_asset(asset_id)
     user_service.check_manager_project_access(asset["project_id"])
     return breakdown_service.update_casting(asset_id, casting)
Esempio n. 9
0
    def test_is_asset_ready(self):
        self.generate_fixture_department()
        self.generate_fixture_task_type()
        self.generate_fixture_task_status()
        self.generate_fixture_person()
        self.generate_fixture_assigner()
        self.task_type_compositing = tasks_service.get_or_create_task_type(
            self.department_animation.serialize(),
            "compositing",
            color="#FFFFFF",
            short_name="compo",
            for_entity="Shot",
        )
        self.task_type_layout_id = str(self.task_type_layout.id)
        self.task_type_animation_id = str(self.task_type_animation.id)
        self.task_type_compositing_id = self.task_type_compositing["id"]
        projects_service.create_project_task_type_link(
            self.project_id, self.task_type_layout_id, 1
        )
        projects_service.create_project_task_type_link(
            self.project_id, self.task_type_animation_id, 2
        )
        projects_service.create_project_task_type_link(
            self.project_id, self.task_type_compositing_id, 3
        )
        self.task_layout = self.generate_fixture_shot_task(
            task_type_id=self.task_type_layout_id
        )
        self.task_animation = self.generate_fixture_shot_task(
            task_type_id=self.task_type_animation_id
        )
        self.task_compositing = self.generate_fixture_shot_task(
            task_type_id=self.task_type_compositing_id
        )
        priority_map = breakdown_service._get_task_type_priority_map(
            self.project_id
        )
        self.assertEqual(priority_map[self.task_type_layout_id], 1)
        self.assertEqual(priority_map[self.task_type_animation_id], 2)
        self.assertEqual(priority_map[self.task_type_compositing_id], 3)
        asset = {"ready_for": str(self.task_type_animation.id)}
        self.assertTrue(
            breakdown_service._is_asset_ready(
                asset, self.task_layout, priority_map
            )
        )
        self.assertTrue(
            breakdown_service._is_asset_ready(
                asset, self.task_animation, priority_map
            )
        )
        self.assertFalse(
            breakdown_service._is_asset_ready(
                asset, self.task_compositing, priority_map
            )
        )

        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)
        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)
        asset = assets_service.get_asset_raw(self.asset_id)
        asset.update({"ready_for": self.task_type_animation_id})
        char = assets_service.get_asset_raw(self.asset_character_id)
        char.update({"ready_for": self.task_type_compositing_id})

        breakdown_service.refresh_casting_stats(asset.serialize())
        self.task_layout = tasks_service.get_task(self.task_layout.id)
        self.task_animation = tasks_service.get_task(self.task_animation.id)
        self.task_compositing = tasks_service.get_task(
            self.task_compositing.id
        )
        self.assertEqual(self.task_layout["nb_assets_ready"], 2)
        self.assertEqual(self.task_animation["nb_assets_ready"], 2)
        self.assertEqual(self.task_compositing["nb_assets_ready"], 1)