Ejemplo n.º 1
0
    def test_get_next_revision_with_empty_revision(self):
        output_file = OutputFile(
            name="test",
            task_id=self.task.id,
            entity_id=self.entity.id,
            file_status_id=self.file_status.id
        )
        output_file.save()

        result = self.get(
            "project/tasks/%s/output_files/next-revision" % self.task.id
        )
        self.assertEqual(result["next_revision"], 2)
Ejemplo n.º 2
0
def create_new_output_revision(entity_id,
                               task_id,
                               person_id,
                               comment,
                               revision=0):
    try:
        output_file = get_last_output_revision(task_id, entity_id)
        revision = output_file.revision + 1
    except NoOutputFileException:
        revision = 1

    file_status_id = get_default_status().id

    output_file = OutputFile(comment=comment,
                             revision=revision,
                             task_id=task_id,
                             entity_id=entity_id,
                             person_id=person_id,
                             file_status_id=file_status_id)
    output_file.save()

    return output_file
Ejemplo n.º 3
0
class ApiDBTestCase(ApiTestCase):
    def setUp(self):
        """
        Reset database before each test.
        """
        super(ApiDBTestCase, self).setUp()

        from zou.app.utils import dbhelpers
        dbhelpers.drop_all()
        dbhelpers.create_all()
        self.log_in()

    def log_in(self):
        self.generate_fixture_user()
        self.post("auth/login", {
            "email": self.user.email,
            "password": "******"
        }, 200)

    def tearDown(self):
        """
        Delete database after each test.
        """
        from zou.app.utils import dbhelpers
        dbhelpers.drop_all()

    def generate_data(self, cls, number, **kwargs):
        """
        Generate random data for a given data model.
        """
        mixer.init_app(self.flask_app)
        return mixer.cycle(number).blend(cls, id=fields.gen_uuid, **kwargs)

    def generate_fixture_project_status(self):
        self.open_status = ProjectStatus(name="open", color="#FFFFFF")
        self.open_status.save()

    def generate_fixture_project_closed_status(self):
        self.closed_status = ProjectStatus(name="closed", color="#FFFFFF")
        self.closed_status.save()

    def generate_fixture_project(self):
        self.project = Project(name="Cosmos Landromat",
                               project_status_id=self.open_status.id)
        self.project.save()
        self.project.update(
            {"file_tree": file_tree.get_tree_from_file("simple")})

    def generate_fixture_project_closed(self):
        self.project_closed = Project(name="Old Project",
                                      project_status_id=self.closed_status.id)
        self.project_closed.save()

    def generate_fixture_project_standard(self):
        self.project_standard = Project(name="Big Buck Bunny",
                                        project_status_id=self.open_status.id)
        self.project_standard.save()
        self.project_standard.update(
            {"file_tree": file_tree.get_tree_from_file("standard")})

    def generate_fixture_entity(self):
        self.entity = Entity(name="Tree",
                             description="Description Tree",
                             project_id=self.project.id,
                             entity_type_id=self.entity_type.id)
        self.entity.save()

    def generate_fixture_entity_standard(self):
        self.entity_standard = Entity(name="Car",
                                      project_id=self.project_standard.id,
                                      entity_type_id=self.entity_type.id)
        self.entity_standard.save()

    def generate_fixture_sequence(self):
        if hasattr(self, "episode"):
            episode_id = self.episode.id
        else:
            episode_id = None

        self.sequence = Entity(name="S01",
                               project_id=self.project.id,
                               entity_type_id=self.sequence_type.id,
                               parent_id=episode_id)
        self.sequence.save()

    def generate_fixture_sequence_standard(self):
        self.sequence_standard = Entity(name="S01",
                                        project_id=self.project_standard.id,
                                        entity_type_id=self.sequence_type.id)
        self.sequence_standard.save()

    def generate_fixture_episode(self):
        self.episode = Entity(name="E01",
                              project_id=self.project.id,
                              entity_type_id=self.episode_type.id)
        self.episode.save()

    def generate_fixture_shot(self):
        self.shot = Entity(name="P01",
                           description="Description Shot 01",
                           data={
                               "fps": 25,
                               "frame_in": 0,
                               "frame_out": 100
                           },
                           project_id=self.project.id,
                           entity_type_id=self.shot_type.id,
                           parent_id=self.sequence.id)
        self.shot.save()
        self.shot_noseq = Entity(name="P01NOSEQ",
                                 project_id=self.project.id,
                                 entity_type_id=self.shot_type.id)
        self.shot_noseq.save()

    def generate_fixture_shot_standard(self):
        self.shot_standard = Entity(name="P01",
                                    description="Description Shot 01",
                                    data={
                                        "fps": 25,
                                        "frame_in": 0,
                                        "frame_out": 100
                                    },
                                    project_id=self.project_standard.id,
                                    entity_type_id=self.shot_type.id,
                                    parent_id=self.sequence_standard.id)
        self.shot_standard.save()

    def generate_fixture_user(self):
        self.user = Person(first_name="John",
                           last_name="Did",
                           email=u"*****@*****.**",
                           password=auth.encrypt_password("mypassword"))
        self.user.save()

    def generate_fixture_person(self):
        self.person = Person(first_name="John",
                             last_name="Doe",
                             email=u"*****@*****.**",
                             password=auth.encrypt_password("mypassword"))
        self.person.save()

    def generate_fixture_entity_type(self):
        self.entity_type = EntityType(name="Props")
        self.entity_type.save()
        self.shot_type = EntityType(name="Shot")
        self.shot_type.save()
        self.sequence_type = EntityType(name="Sequence")
        self.sequence_type.save()
        self.episode_type = EntityType(name="Episode")
        self.episode_type.save()

    def generate_fixture_department(self):
        self.department = Department(name="Modeling", color="#FFFFFF")
        self.department.save()
        self.department_animation = Department(name="Animation",
                                               color="#FFFFFF")
        self.department_animation.save()

    def generate_fixture_task_type(self):
        self.task_type = TaskType(name="Shaders",
                                  color="#FFFFFF",
                                  department_id=self.department.id)
        self.task_type.save()
        self.task_type_animation = TaskType(
            name="Animation",
            color="#FFFFFF",
            department_id=self.department_animation.id)
        self.task_type_animation.save()

    def generate_fixture_task_status(self):
        self.task_status = TaskStatus(name="Open",
                                      short_name="opn",
                                      color="#FFFFFF")
        self.task_status.save()

    def generate_fixture_task_status_wip(self):
        self.task_status_wip = TaskStatus(name="WIP",
                                          short_name="wip",
                                          color="#FFFFFF")
        self.task_status_wip.save()

    def generate_fixture_task_status_to_review(self):
        self.task_status_to_review = TaskStatus(name="To review",
                                                short_name="pndng",
                                                color="#FFFFFF")
        self.task_status_to_review.save()

    def generate_fixture_assigner(self):
        self.assigner = Person(first_name="Ema", last_name="Peel")
        self.assigner.save()

    def generate_fixture_task(self):
        start_date = fields.get_date_object("2017-02-20")
        due_date = fields.get_date_object("2017-02-28")
        real_start_date = fields.get_date_object("2017-02-22")
        self.task = Task(name="Super modeling",
                         project_id=self.project.id,
                         task_type_id=self.task_type.id,
                         task_status_id=self.task_status.id,
                         entity_id=self.entity.id,
                         assignees=[self.person],
                         assigner_id=self.assigner.id,
                         duration=50,
                         estimation=40,
                         start_date=start_date,
                         due_date=due_date,
                         real_start_date=real_start_date)
        self.task.save()

    def generate_fixture_task_standard(self):
        start_date = fields.get_date_object("2017-02-20")
        due_date = fields.get_date_object("2017-02-28")
        real_start_date = fields.get_date_object("2017-02-22")
        self.task_standard = Task(name="Super modeling",
                                  project_id=self.project_standard.id,
                                  task_type_id=self.task_type.id,
                                  task_status_id=self.task_status.id,
                                  entity_id=self.entity_standard.id,
                                  assignees=[self.person],
                                  assigner_id=self.assigner.id,
                                  duration=50,
                                  estimation=40,
                                  start_date=start_date,
                                  due_date=due_date,
                                  real_start_date=real_start_date)
        self.task_standard.save()

    def generate_fixture_shot_task(self):
        self.shot_task = Task(
            name="Super animation",
            project_id=self.project.id,
            task_type_id=self.task_type_animation.id,
            task_status_id=self.task_status.id,
            entity_id=self.shot.id,
            assignees=[self.person],
            assigner_id=self.assigner.id,
        )
        self.shot_task.save()

    def generate_fixture_shot_task_standard(self):
        self.shot_task_standard = Task(
            name="Super animation",
            project_id=self.project_standard.id,
            task_type_id=self.task_type_animation.id,
            task_status_id=self.task_status.id,
            entity_id=self.shot_standard.id,
            assignees=[self.person],
            assigner_id=self.assigner.id)
        self.shot_task_standard.save()

    def generate_fixture_file_status(self):
        self.file_status = FileStatus(name="To review", color="#FFFFFF")
        self.file_status.save()

    def generate_fixture_working_file(self):
        self.working_file = WorkingFile(name="S01_P01_modeling",
                                        comment="",
                                        revision=1,
                                        task_id=self.task.id,
                                        entity_id=self.entity.id,
                                        person_id=self.person.id)
        self.working_file.save()

    def generate_fixture_shot_working_file(self):
        self.working_file = WorkingFile(name="S01_P01_animation",
                                        comment="",
                                        revision=1,
                                        task_id=self.task.id,
                                        entity_id=self.shot.id,
                                        person_id=self.person.id)
        self.working_file.save()

    def generate_fixture_output_file(self):
        self.output_file = OutputFile(comment="",
                                      revision=1,
                                      task_id=self.task.id,
                                      entity_id=self.entity.id,
                                      person_id=self.person.id,
                                      file_status_id=self.file_status.id)
        self.output_file.save()

    def get_fixture_file_path(self, relative_path):
        current_path = os.getcwd()
        file_path_fixture = os.path.join(current_path, "test", "fixtures",
                                         relative_path)
        return file_path_fixture