def test_sequences_comboBox_is_filled_with_sequences_from_the_current_project(
            self):
        """testing if the sequences_comboBox is filled with the correct
        sequences from the currently chosen Project instance
        """
        project1 = Project("Test Project 1")
        project2 = Project("Test Project 2")

        project1.create()
        project2.create()

        project1.save()
        project2.save()

        seq1 = Sequence(project1, "Test Sequence 1")
        seq1.save()
        seq2 = Sequence(project1, "Test Sequence 2")
        seq2.save()
        seq3 = Sequence(project2, "Test Sequence 3")
        seq3.save()
        seq4 = Sequence(project2, "Test Sequence 4")
        seq4.save()

        # create dialog
        dialog = project_manager.MainDialog()
        #        self.show_dialog(dialog)

        # set the project to project2
        index = dialog.projects_comboBox.findText(project2.name)
        dialog.projects_comboBox.setCurrentIndex(index)

        # check if the sequences_comboBox is filled with correct data
        self.assertEqual(dialog.sequences_comboBox.count(), 2)

        item_texts = []
        for i in range(2):
            dialog.sequences_comboBox.setCurrentIndex(i)
            item_texts.append(dialog.sequences_comboBox.currentText())

        self.assertTrue(seq3.name in item_texts)
        self.assertTrue(seq4.name in item_texts)

        # set the project to project1
        index = dialog.projects_comboBox.findText(project1.name)
        dialog.projects_comboBox.setCurrentIndex(index)

        # check if the sequences_comboBox is filled with correct data
        self.assertEqual(dialog.sequences_comboBox.count(), 2)

        item_texts = []
        for i in range(2):
            dialog.sequences_comboBox.setCurrentIndex(i)
            item_texts.append(dialog.sequences_comboBox.currentText())

        self.assertTrue(seq1.name in item_texts)
        self.assertTrue(seq2.name in item_texts)
Beispiel #2
0
    def test_code_argument_is_not_unique_for_same_project(self):
        """testing if the code argument is not unique raises IntegrityError
        """

        test_project = Project("Test Project for Name Uniqueness")
        test_project.save()

        test_seq1 = Sequence(test_project, "Seq1A", "SEQ1")
        test_seq1.save()

        test_seq2 = Sequence(test_project, "Seq1B", "SEQ1")
        self.assertRaises(IntegrityError, test_seq2.save)
    def test_sequences_comboBox_caches_Sequence_instances_in_sequences_attribute(
            self):
        """testing if the sequence_comboBox caches the Sequence instances in
        an attribute called Sequence
        """

        project1 = Project("Test Project 1")
        project1.create()

        project2 = Project("Test Project 2")
        project2.create()

        seq1 = Sequence(project1, "Test Sequence 1")
        seq1.save()

        seq2 = Sequence(project1, "Test Sequence 2")
        seq2.save()

        seq3 = Sequence(project2, "Test Sequence 3")
        seq3.save()

        seq4 = Sequence(project2, "Test Sequence 4")
        seq4.save()

        seq5 = Sequence(project2, "Test Sequence 5")
        seq5.save()

        dialog = project_manager.MainDialog()

        self.assertTrue(hasattr(dialog.sequences_comboBox, "sequences"))

        # set it to project1
        index = dialog.projects_comboBox.findText(project1.name)
        dialog.projects_comboBox.setCurrentIndex(index)

        # check if sequences_comboBox.sequences has 3 elements
        self.assertEqual(len(dialog.sequences_comboBox.sequences), 2)

        # check if all the sequences are there
        self.assertTrue(seq1 in dialog.sequences_comboBox.sequences)
        self.assertTrue(seq2 in dialog.sequences_comboBox.sequences)

        # set it to project2
        index = dialog.projects_comboBox.findText(project2.name)
        dialog.projects_comboBox.setCurrentIndex(index)

        # check if sequences_comboBox.sequences has 3 elements
        self.assertEqual(len(dialog.sequences_comboBox.sequences), 3)

        # check if all the sequences are there
        self.assertTrue(seq3 in dialog.sequences_comboBox.sequences)
        self.assertTrue(seq4 in dialog.sequences_comboBox.sequences)
        self.assertTrue(seq5 in dialog.sequences_comboBox.sequences)
Beispiel #4
0
    def test_add_alternative_shot_is_working_properly(self):
        """testing if the add_alternative_shot method is working properly
        """

        new_proj = Project("Test Project")
        new_proj.create()

        new_seq = Sequence(new_proj, "Test Sequence", "TEST_SEQ1")
        new_seq.save()

        new_shot = Shot(new_seq, 1)
        new_shot.save()

        # check if the sequence has only one shot
        self.assertEqual(len(new_seq.shots), 1)

        # now create an alternative to this shot
        new_seq.add_alternative_shot(1)

        # now check if the sequence has two shots
        self.assertEqual(len(new_seq.shots), 2)

        # and the second shots number is 1A
        self.assertEqual(new_seq.shots[1].number, "1A")

        # add a new alternative
        new_seq.add_alternative_shot("1")

        # check if there is three shots
        self.assertEqual(len(new_seq.shots), 3)

        # and the third shots number is 1B
        self.assertEqual(new_seq.shots[2].number, "1B")
    def test_edit_shot_button_opens_up_shot_editor_with_the_given_shot(self):
        """testing if hitting the edit shot button opens up the shot_editor
        dialog
        """
        proj1 = Project('Test Project')
        proj1.save()

        seq1 = Sequence(proj1, 'Test Sequence')
        seq1.save()

        shot = Shot(seq1, 1, 2, 435)
        shot.handle_at_start = 23
        shot.handle_at_end = 12
        shot.save()

        dialog1 = project_manager.MainDialog()
        #        self.show_dialog(dialog1)

        # hit to the edit shot button
        #        QTest.mouseClick(
        #            dialog1.edit_shot_pushButton,
        #            QtCore.Qt.LeftButton
        #        )

        # check if the shot_editor dialog is opened
        # HOW ????
        self.fail('test is not finished yet')
    def new_sequence_pushButton_clicked(self):
        """runs when new_sequence_pushButton is clicked
        """

        project = self.get_current_project()

        if project is None:
            return

        dialog = QtGui.QInputDialog()

        new_sequence_name, ok = dialog.getText(self, "Add Sequence",
                                               "New Sequence Name")

        if ok:
            if new_sequence_name != "":
                new_sequence = Sequence(project, new_sequence_name)
                new_sequence.save()
                new_sequence.create()

                # update sequence_comboBox
                self.update_sequences_comboBox()

                # set it to the new project
                index = self.sequences_comboBox.findText(new_sequence.name)
                self.sequences_comboBox.setCurrentIndex(index)
Beispiel #7
0
    def test_database_simple_data(self):
        """testing if the database file has the necessary information related to
        the Sequence
        """

        new_proj = Project(name="TEST_PROJECT")
        new_proj.create()

        test_seq_name = "TEST_SEQ1"
        new_seq = Sequence(new_proj, test_seq_name)
        new_seq.save()
        new_seq.create()

        # fill it with some non default values
        description = new_seq.description = "Test description"
        new_seq.save()

        # now check if the database is created correctly
        del new_seq

        # create the seq from scratch and let it read the database
        new_seq = db.session.query(Sequence).first()

        # now check if it was able to get these data
        self.assertEqual(description, new_seq.description)
    def test_create_project_structure_pushButton_creates_project_structure(
            self):
        """testing if using the create_project_pushButton creates the project
        structure
        """

        # create a project
        proj = Project("Test Project")
        proj.save()

        # create a sequence
        seq = Sequence(proj, "Sequence")
        seq.save()

        # create a shot
        shot = Shot(seq, 1)
        shot.save()

        # check if there is no shot folder
        project_path = os.path.join(self.temp_projects_folder,
                                    "Test_Project/Shots/SH001")

        self.assertFalse(os.path.exists(project_path))

        # hit create_structure_pushButton
        dialog = project_manager.MainDialog()

        QTest.mouseClick(dialog.create_project_structure_pushButton,
                         Qt.LeftButton)

        # check if the shot folder has been created
        self.assertTrue(os.path.exists(project_path))
Beispiel #9
0
    def test_code_argument_is_not_unique_for_different_projects(self):
        """testing if no code argument is unique for different projects will
        not raise IntegrityError
        """

        test_project1 = Project("Test Project for Name Uniqueness 1")
        test_project1.save()

        test_project2 = Project("Test Project for Name Uniqueness 2")
        test_project2.save()

        test_seq1 = Sequence(test_project1, "SEQ1A", "SEQ1A")
        test_seq1.save()

        test_seq2 = Sequence(test_project2, "SEQ1B", "SEQ1A")
        test_seq2.save()  # no Integrity Error
Beispiel #10
0
    def test_deleting_a_sequence_will_also_delete_the_related_shots(self):
        """testing if deleting a sequence will also delete the related shots
        """
        proj1 = Project('Test Project 1')
        proj1.save()

        seq1 = Sequence(proj1, 'Seq1')
        seq1.save()

        seq2 = Sequence(proj1, 'Seq2')
        seq2.save()

        shot1 = Shot(seq1, 1)
        shot1.save()

        shot2 = Shot(seq1, 2)
        shot2.save()

        shot3 = Shot(seq2, 1)
        shot3.save()

        shot4 = Shot(seq2, 2)
        shot4.save()

        # check if they are in session
        self.assertIn(proj1, db.session)
        self.assertIn(seq1, db.session)
        self.assertIn(seq2, db.session)
        self.assertIn(shot1, db.session)
        self.assertIn(shot2, db.session)
        self.assertIn(shot3, db.session)
        self.assertIn(shot4, db.session)

        # delete seq1
        db.session.delete(seq1)
        db.session.commit()

        # check if all the objects which must be deleted are really deleted
        self.assertNotIn(seq1, db.session)
        self.assertNotIn(shot1, db.session)
        self.assertNotIn(shot2, db.session)

        # and others are in
        self.assertIn(proj1, db.session)
        self.assertIn(seq2, db.session)
        self.assertIn(shot3, db.session)
        self.assertIn(shot4, db.session)
Beispiel #11
0
 def test_name_argument_is_working_properly(self):
     """testing if the name attribute is set properly with the given value
     for the name argument
     """
     test_value = "Test Sequence With Name"
     self.kwargs["name"] = test_value
     new_seq = Sequence(**self.kwargs)
     self.assertEqual(new_seq.name, test_value)
Beispiel #12
0
 def test_code_argument_is_skipped(self):
     """testing if the code attribute will equal to name argument if it is
     skipped
     """
     self.kwargs.pop("code")
     self.kwargs["name"] = "Test Sequence"
     expected_value = "Test_Sequence"
     new_seq1 = Sequence(**self.kwargs)
     self.assertEqual(new_seq1.code, expected_value)
Beispiel #13
0
 def test_name_argument_formatting(self):
     """testing if the name will be formatted correctly when creating a
     new project.
     """
     for test_value in self._name_test_values:
         self.kwargs["name"] = test_value[0]
         expected_name = test_value[1]
         new_sequence = Sequence(**self.kwargs)
         self.assertEqual(new_sequence.name, expected_name)
Beispiel #14
0
 def test_code_argument_is_None(self):
     """testing if the code argument is given as None the code attribute
     will be set to the same value with the name attribute
     """
     self.kwargs["code"] = None
     self.kwargs["name"] = "Test Sequence"
     expected_value = "Test_Sequence"
     new_seq1 = Sequence(**self.kwargs)
     self.assertEqual(new_seq1.code, expected_value)
Beispiel #15
0
    def test_creating_two_different_sequences_and_calling_create(self):
        """testing if no error will be raised when creating two different
        Sequences for the same Project and calling the Sequences.create()
        in mixed order
        """

        new_proj = Project(name="TEST_PROJECT")
        new_proj.create()

        new_seq1 = Sequence(new_proj, "TEST_SEQ1")
        new_seq2 = Sequence(new_proj, "TEST_SEQ2")

        new_seq1.save()
        new_seq2.save()

        #        print "calling new_seq1.create"
        new_seq1.create()
        #        print "calling new_seq2.create"
        new_seq2.create()
Beispiel #16
0
    def test_code_argument_is_not_unique_for_different_projects_2(self):
        """testing if no code argument is unique for different projects will
        not raise IntegrityError
        """

        p1 = Project("Migros Kanguru", "MIGROS_KANGURU")
        p1.save()

        p2 = Project("Migros M-Label", "MIGROS_M_LABEL")
        p2.save()

        s1 = Sequence(p2, "TVC", "TVC")
        s1.save()

        p3 = Project("Fairy Obelix Booster", "FAIRY_OBELIX_BOOSTER")
        p3.save()

        s2 = Sequence(p3, "TVC", "TVC")
        s2.save()
 def update_sequences_comboBox(self):
     """updates the sequences_comboBox according to the current project
     """
     project = self.get_current_project()
     sequences = Sequence.query()\
         .filter(Sequence.project==project)\
         .order_by(Sequence.name.asc())\
         .all()
     self.sequences_comboBox.sequences = sequences
     self.sequences_comboBox.clear()
     self.sequences_comboBox.addItems(map(lambda x: x.name, sequences))
 def update_sequences_comboBox(self):
     """updates the sequences_comboBox according to the current project
     """
     project = self.get_current_project()
     sequences = Sequence.query()\
         .filter(Sequence.project==project)\
         .order_by(Sequence.name.asc())\
         .all()
     self.sequences_comboBox.sequences = sequences
     self.sequences_comboBox.clear()
     self.sequences_comboBox.addItems(map(lambda x: x.name, sequences))
Beispiel #19
0
    def test_code_argument_is_formatted_correctly(self):
        """testing if the code attribute is formatted correctly on Sequence
        instance creation
        """
        self.kwargs["name"] = "TEST_SEQ1"
        for test_value in self._name_test_values:
            self.kwargs["code"] = test_value[0]
            expected_value = test_value[2]

            new_sequence = Sequence(**self.kwargs)

            self.assertEqual(new_sequence.code, expected_value)
Beispiel #20
0
    def test_database_recreation_of_sequence_object(self):
        """testing if the database file has the necessary information related to
        the Sequence
        """

        new_proj = Project(name="TEST_PROJECT")
        new_proj.create()

        test_seq_name = "TEST_SEQ1"
        new_seq = Sequence(new_proj, test_seq_name)
        new_seq.save()

        description = new_seq.description

        # now check if the database is created correctly
        del new_seq

        # create the seq from scratch and let it read the database
        new_seq = Sequence(new_proj, test_seq_name)

        # now check if it was able to get these data
        self.assertEqual(new_seq.description, description)
Beispiel #21
0
    def test___ne___operator(self):
        """testing the __ne__ (not equal) operator
        """

        # create a new project and two sequence
        # then create three new sequence objects to compare each of them
        # with the other

        new_proj = Project("TEST_PROJECT_FOR_NE_TEST")
        new_proj.create()

        seq1 = Sequence(new_proj, "SEQ1")
        seq2 = Sequence(new_proj, "SEQ1")
        seq3 = Sequence(new_proj, "SEQ2")

        new_proj2 = Project("TEST_PROJECT2")
        new_proj2.create()
        seq4 = Sequence(new_proj2, "SEQ3")

        self.assertFalse(seq1 != seq2)
        self.assertTrue(seq1 != seq3)
        self.assertTrue(seq1 != seq4)
        self.assertTrue(seq3 != seq4)
Beispiel #22
0
    def test_deleting_a_sequence_will_not_delete_the_related_project(self):
        """testing if deleting a sequence will not delete the related project
        """
        proj1 = Project('Test Project 1')
        proj1.save()

        seq1 = Sequence(proj1, 'Test Sequence 1')
        seq1.save()

        seq2 = Sequence(proj1, 'Test Sequence 2')
        seq2.save()

        # check if they are in the session
        self.assertIn(proj1, db.session)
        self.assertIn(seq1, db.session)
        self.assertIn(seq2, db.session)

        db.session.delete(seq1)
        db.session.commit()

        self.assertIn(proj1, db.session)
        self.assertNotIn(seq1, db.session)
        self.assertIn(seq2, db.session)
Beispiel #23
0
    def setUp(self):
        """set up the test in class level
        """
        # -----------------------------------------------------------------
        # start of the setUp
        conf.database_url = "sqlite://"

        # create the environment variable and point it to a temp directory
        self.temp_config_folder = tempfile.mkdtemp()
        self.temp_projects_folder = tempfile.mkdtemp()

        os.environ["OYPROJECTMANAGER_PATH"] = self.temp_config_folder
        os.environ[conf.repository_env_key] = self.temp_projects_folder

        self.test_project = Project("Test Project")
        self.test_project.save()

        self.kwargs = {
            "project": self.test_project,
            "name": "Test Sequence",
            "code": "TEST_SEQUENCE"
        }

        self.test_sequence = Sequence(**self.kwargs)

        self._name_test_values = [
            # (input, name, code)
            ("test sequence", "test sequence", "test_sequence"),
            ("123 test sequence", "123 test sequence", "123_test_sequence"),
            ("£#$£#$test£#$£#$sequence", "testsequence", "testsequence"),
            ("_123test sequence", "_123test sequence", "_123test_sequence"),
            ("CamelCase", "CamelCase", "CamelCase"),
            ("234CamelCase", "234CamelCase", "234CamelCase"),
            ("camelCase", "camelCase", "camelCase"),
            ("CamelCase", "CamelCase", "CamelCase"),
            ("minus-sign", "minus-sign", "minus-sign"),
            ("123432!+!'^+Test_SEquence323^+'^%&+%&324",
             "123432Test_SEquence323324", "123432Test_SEquence323324"),
            ("    ---test 9s_sequence", "test 9s_sequence",
             "test_9s_sequence"),
            ("    ---test 9s-sequence", "test 9s-sequence",
             "test_9s-sequence"),
            (" multiple     spaces are    converted to under     scores",
             "multiple     spaces are    converted to under     scores",
             "multiple_spaces_are_converted_to_under_scores"),
            ("_Sequence_Setup_", "_Sequence_Setup_", "_Sequence_Setup_"),
            ("_SEQUENCE_SETUP_", "_SEQUENCE_SETUP_", "_SEQUENCE_SETUP_"),
            ("FUL_3D", "FUL_3D", "FUL_3D"),
        ]
Beispiel #24
0
    def test_add_shots_method_creates_shots_based_on_the_given_range_formulat(
            self):
        """testing if the add_shots will create shots based on the
        shot_range_formula argument
        """

        new_proj = Project(name="Test Project")
        new_proj.create()

        new_seq1 = Sequence(new_proj, "Test Sequence 1", "TEST_SEQ1")
        new_seq1.save()

        expected_shot_numbers = [
            '1', '2', '3', '4', '5', '6', '7', '8', '10', '12', '13', '14',
            '15', '304_SB_0403_0040'
        ]

        # assert there is no shots in the sequence
        self.assertTrue(len(new_seq1.shots) == 0)

        # add a new shot
        new_seq1.add_shots("1")
        self.assertTrue(len(new_seq1.shots) == 1)
        self.assertTrue(new_seq1.shots[0].number in expected_shot_numbers)

        # add a couple of shots
        new_seq1.add_shots("2,3,4")
        self.assertTrue(len(new_seq1.shots) == 4)
        self.assertTrue(new_seq1.shots[1].number in expected_shot_numbers)
        self.assertTrue(new_seq1.shots[2].number in expected_shot_numbers)
        self.assertTrue(new_seq1.shots[3].number in expected_shot_numbers)

        # add a couple of more
        #new_seq1.add_shots("5-8,10,12-15")
        new_seq1.add_shots("5,6,7,8,10,12,13,14,15,304_sb_0403_0040")

        self.assertTrue(len(new_seq1.shots) == 14)
        self.assertIn(new_seq1.shots[4].number, expected_shot_numbers)
        self.assertIn(new_seq1.shots[5].number, expected_shot_numbers)
        self.assertIn(new_seq1.shots[6].number, expected_shot_numbers)
        self.assertIn(new_seq1.shots[7].number, expected_shot_numbers)
        self.assertIn(new_seq1.shots[8].number, expected_shot_numbers)
        self.assertIn(new_seq1.shots[9].number, expected_shot_numbers)
        self.assertIn(new_seq1.shots[10].number, expected_shot_numbers)
        self.assertIn(new_seq1.shots[11].number, expected_shot_numbers)
        self.assertIn(new_seq1.shots[12].number, expected_shot_numbers)
        self.assertIn(new_seq1.shots[13].number, expected_shot_numbers)
Beispiel #25
0
    def test_calling_create_multiple_times(self):
        """testing if no error will be raised when calling Sequence.create
        multiple times
        """

        new_proj = Project(name="TEST_PROJECT")
        new_proj.create()

        new_seq = Sequence(new_proj, "TEST_SEQ")
        new_seq.save()

        # now call create multiple times
        new_seq.create()
        new_seq.create()
        new_seq.create()
        new_seq.create()
        new_seq.create()
Beispiel #26
0
    def test_add_shots_method_will_remove_the_shot_prefix_if_the_given_shot_starts_with_it(
            self):
        """testing if the add_shots method will remove the shot prefix in the
        given shot code if it starts with the shot prefix of the project
        """
        proj1 = Project('Test Proj1')
        proj1.save()

        seq1 = Sequence(proj1, 'Test Seq1')
        seq1.save()

        # now try to add a shot with the name SH001
        seq1.add_shots(proj1.shot_number_prefix + "001")

        # now check the first shot of the seq1 has a shot number of 1 and the
        # code is SH001
        self.assertEqual("1", seq1.shots[0].number)
        self.assertEqual('SH001', seq1.shots[0].code)
Beispiel #27
0
 def test_shot_argument_is_a_shot_instance_will_fill_the_ui_with_shot_info(self):
     """testing if the ui is filled with correct info coming from the given
     shot
     """
     
     proj1 = Project('Test Project')
     proj1.save()
     
     seq1 = Sequence(proj1, 'Test Sequence')
     seq1.save()
     
     shot = Shot(seq1, 1, 2, 435)
     shot.handle_at_start = 23
     shot.handle_at_end = 12
     shot.save()
     
     dialog = shot_editor.MainDialog(shot=shot)
     
     # test if the "Editing Shot: SH001" is correctly updated
     self.assertEqual(
         shot.code,
         dialog.shot_name_label.text()
     )
     
     # test frame range info
     self.assertEqual(
         shot.start_frame,
         dialog.start_frame_spinBox.value()
     )
     
     self.assertEqual(
         shot.end_frame,
         dialog.end_frame_spinBox.value()
     )
     
     self.assertEqual(
         shot.handle_at_start,
         dialog.handle_at_start_spinBox.value()
     )
     
     self.assertEqual(
         shot.handle_at_end,
         dialog.handle_at_end_spinBox.value()
     )
Beispiel #28
0
    def test_add_shots_is_working_properly_for_projects_with_no_shot_number_prefix(
            self):
        """testing if the add_shots method working properly for projects with
        no or empty shot_number_prefix
        """
        proj1 = Project('proj1', 'proj1')
        proj1.shot_number_prefix = ""
        proj1.shot_number_padding = 0
        proj1.save()

        seq1 = Sequence(proj1, 'seq91')
        seq1.save()

        shot_code = 'VFX91-3'
        seq1.add_shots(shot_code)
        # should complete without any error

        shot = seq1.shots[0]
        self.assertEqual(shot.code, shot_code)
Beispiel #29
0
    def test_shot_info_of_the_given_shot_is_updated_correctly(self):
        """testing if the shot info is updated when clicked to ok
        """
        
        proj1 = Project('Test Project')
        proj1.save()
        
        seq1 = Sequence(proj1, 'Test Sequence')
        seq1.save()
        
        shot = Shot(seq1, 1, 2, 435)
        shot.handle_at_start = 23
        shot.handle_at_end = 12
        shot.save()
        
        start_frame = 132
        end_frame = 250
        handle_at_start = 11
        handle_at_end = 32
        
        dialog = shot_editor.MainDialog(shot=shot)
#        self.show_dialog(dialog)
        
        # now update the values
        dialog.start_frame_spinBox.setValue(start_frame)
        dialog.end_frame_spinBox.setValue(end_frame)
        dialog.handle_at_start_spinBox.setValue(handle_at_start)
        dialog.handle_at_end_spinBox.setValue(handle_at_end)
        
        # hit ok
        QTest.mouseClick(
            dialog.buttonBox.buttons()[0],
            QtCore.Qt.LeftButton
        )
        
        # now check if the shot is updated
        self.assertEqual(start_frame, shot.start_frame)
        self.assertEqual(end_frame, shot.end_frame)
        self.assertEqual(handle_at_start, shot.handle_at_start)
        self.assertEqual(handle_at_end, shot.handle_at_end)
Beispiel #30
0
    def test_save_as_sets_the_render_file_name_for_Shots(self):
        """testing if the save_as sets the render file name correctly
        """

        test_seq = Sequence(self.project, "Test Sequence 1")
        test_seq.save()

        test_shot = Shot(test_seq, 1)
        test_shot.save()

        self.kwargs["type"] = self.shot_vtypes[0]
        self.kwargs["version_of"] = test_shot

        self.version1 = Version(**self.kwargs)

        self.mEnv.save_as(self.version1)

        # check if the path equals to
        expected_path = self.version1.output_path + \
                        "/<Layer>/"+ self.version1.project.code + "_" + \
                        self.version1.version_of.sequence.code + "_" + \
                        self.version1.base_name +"_" + \
                        self.version1.take_name + \
                            "_<Layer>_<RenderPass>_<Version>"

        image_path = os.path.join(pm.workspace.path,
                                  pm.workspace.fileRules['image']).replace(
                                      "\\", "/")

        expected_path = utils.relpath(
            image_path,
            expected_path,
        )

        dRG = pm.PyNode("defaultRenderGlobals")

        self.assertEqual(expected_path, dRG.getAttr("imageFilePrefix"))
Beispiel #31
0
    def test_shots_tableWidget_is_filled_with_Shot_data(self):
        """testing if the shots_tableWidget is filled with shot data properly
        """
        db.setup()

        # create a project
        proj1 = Project('Test Project 1')
        proj1.save()

        proj2 = Project('Test Project 2')
        proj2.save()

        shot_vtypes = VersionType.query()\
            .filter(VersionType.type_for=='Shot')\
            .order_by(VersionType.name)\
            .all()

        admin = User.query().first()

        # seqs for proj1
        seq1 = Sequence(proj1, 'Test Seq 1')
        seq1.save()

        seq2 = Sequence(proj1, 'Test Seq 2')
        seq2.save()

        # seqs for proj2
        seq3 = Sequence(proj2, 'Test Seq 3')
        seq3.save()

        seq4 = Sequence(proj2, 'Test Seq 4')
        seq4.save()

        # shots for seq1
        shot1 = Shot(seq1, 1)
        shot1.save()

        shot2 = Shot(seq1, 2)
        shot2.save()

        shot3 = Shot(seq1, 3)
        shot3.save()

        # shots for seq2
        shot4 = Shot(seq2, 4)
        shot4.save()

        shot5 = Shot(seq2, 5)
        shot5.save()

        shot6 = Shot(seq2, 6)
        shot6.save()

        # shots for seq3
        shot7 = Shot(seq3, 7)
        shot7.save()

        shot8 = Shot(seq3, 8)
        shot8.save()

        # shots for seq4
        shot9 = Shot(seq4, 9)
        shot9.save()

        shot10 = Shot(seq4, 10)
        shot10.save()

        # versions for shot1
        version1 = Version(version_of=shot1,
                           base_name=shot1.code,
                           type=shot_vtypes[0],
                           created_by=admin,
                           status=conf.status_list[0])
        version1.save()

        version2 = Version(version_of=shot1,
                           base_name=shot1.code,
                           type=shot_vtypes[1],
                           created_by=admin,
                           status=conf.status_list[1])
        version2.save()

        # versions for shot2
        version3 = Version(version_of=shot2,
                           base_name=shot2.code,
                           type=shot_vtypes[2],
                           created_by=admin,
                           status=conf.status_list[2])
        version3.save()

        version4 = Version(
            version_of=shot2,
            base_name=shot2.code,
            type=shot_vtypes[3],
            created_by=admin,
            status=conf.status_list[3],
        )
        version4.save()

        # versions for shot3
        version5 = Version(
            version_of=shot3,
            base_name=shot3.code,
            type=shot_vtypes[4],
            created_by=admin,
            status=conf.status_list[4],
        )
        version5.save()

        version6 = Version(
            version_of=shot3,
            base_name=shot3.code,
            type=shot_vtypes[5],
            created_by=admin,
            status=conf.status_list[4],
        )
        version6.save()

        # versions for shot4
        version7 = Version(version_of=shot4,
                           base_name=shot4.code,
                           type=shot_vtypes[5],
                           created_by=admin,
                           status=conf.status_list[4])
        version7.save()

        version8 = Version(version_of=shot4,
                           base_name=shot4.code,
                           type=shot_vtypes[5],
                           created_by=admin,
                           status=conf.status_list[0])
        version8.save()

        dialog = status_manager.MainDialog()
        #        self.show_dialog(dialog)

        # start tests

        # set the project to project1
        dialog.projects_comboBox.setCurrentIndex(0)

        #self.show_dialog(dialog)

        # asset1's vtypes[0] vtypes[1] vtypes[2] vtypes[3]
        self.fail('test is not finished yet!')
 def fill_shots_tableWidget(self):
     """fills the shots_tableWidget
     """
     
     # TODO: merge cells of the same shot, or at least paint them in some other color
     
     # clear the tableWidget
     self.shots_tableWidget.clear()
     
     shot_vtypes = VersionType.query()\
         .filter(VersionType.type_for=='Shot')\
         .order_by(VersionType.name)\
         .all()
     
     shot_vtype_codes = map(lambda x: x.code, shot_vtypes)
     
     labels = ['Thumbnail', 'Sequence', 'Number', 'Take']
     labels.extend(map(lambda x: x.code, shot_vtypes))
     
     #logger.debug('shot_tableWidget.labels: %s' % labels)
     
     self.shots_tableWidget.setColumnCount(len(labels))
     self.shots_tableWidget.setHorizontalHeaderLabels(labels)
     
     # get the project
     project = self.get_current_project()
     
     if project is None:
         return
     
     # get all the shots for the sequence
     sequences = Sequence.query()\
         .filter(Sequence.project==project)\
         .order_by(Sequence.name)\
         .all()
     
     shot_count = db.query(func.count(Shot.id))\
         .join(Sequence)\
         .filter(Sequence.id==Shot.sequence_id)\
         .filter(Sequence.project==project)\
         .all()[0][0]
     
     # set the row count for all shots in that sequence
     self.shots_tableWidget.setRowCount(shot_count)
     
     items = []
     row = 0
     column = 0
     for sequence in sequences:    
         shots = Shot.query()\
             .filter(Shot.sequence==sequence)\
             .order_by(Shot.number)\
             .all()
         
         # sort according to numbers
         shots.sort(key=lambda x: utils.embedded_numbers(x.number))
         
         #logger.debug('shots of sequence %s is %s' % (sequence.name, shots))
         
         # feed the shots to the list
         
         previous_shot = None
         for shot in shots:
             take_names = map(
                 lambda x: x[0],
                 db.query(distinct(Version.take_name))
                     .filter(Version.version_of==shot)
                     .all()
             )
             
             if not len(take_names):
                 take_names = ['-']
             
             for take_name in take_names:
                 # add the seq name to the first column
                 column = 0
                 item = QtGui.QTableWidgetItem()
                 item.setTextAlignment(0x0004 | 0x0080)
                 #set the thumbnail
                 if os.path.exists(shot.thumbnail_full_path):
                     thumbnail_full_path = shot.thumbnail_full_path
                     pixmap = QtGui.QPixmap(thumbnail_full_path)
                     pixmap = pixmap.scaled(
                         conf.thumbnail_size[0] / 2,
                         conf.thumbnail_size[1] / 2,
                         QtCore.Qt.KeepAspectRatio,
                         QtCore.Qt.SmoothTransformation
                     )
                     brush = QtGui.QBrush(pixmap)
                     item.has_thumbnail = True
                     item.setBackground(brush)
                 else:
                     item.has_thumbnail = False
                 items.append(item)
                 
                 column = 1
                 item = QtGui.QTableWidgetItem(sequence.name)
                 item.setTextAlignment(0x0004 | 0x0080)
                 #self.shots_tableWidget.setItem(row, column, item)
                 items.append(item)
                 
                 # add the shot code to the second column
                 column = 2
                 item = QtGui.QTableWidgetItem(shot.code)
                 item.setTextAlignment(0x0004 | 0x0080)
                 #self.shots_tableWidget.setItem(row, column, item)
                 items.append(item)
                 
                 # add the take name to the third column
                 column = 3
                 item = QtGui.QTableWidgetItem(take_name)
                 item.setTextAlignment(0x0004 | 0x0080)
                 #self.assets_tableWidget.setItem(row, column, item)
                 items.append(item)
             
                 for type_code in shot_vtype_codes:
                     column += 1
                     
                     # get the latest version of that type and take
                     version = Version.query()\
                         .join(VersionType)\
                         .filter(Version.version_of==shot)\
                         .filter(Version.type_id==VersionType.id)\
                         .filter(VersionType.code==type_code)\
                         .filter(Version.take_name==take_name)\
                         .order_by(Version.version_number.desc())\
                         .first()
                     
                     if version:
                         # mark the status of that type in that take
                         item = QtGui.QTableWidgetItem(
                             version.status + '\n' + version.created_by.name
                         )
                         item.setTextAlignment(0x0004 | 0x0080)
                         
                         # set the color according to status
                         index = conf.status_list.index(version.status)
                         bgcolor = conf.status_bg_colors[index]
                         fgcolor = conf.status_fg_colors[index]
                         
                         bg = item.background()
                         bg.setColor(QtGui.QColor(*bgcolor))
                         item.setBackground(bg)
                         
                         fg = item.foreground()
                         fg.setColor(QtGui.QColor(*fgcolor))
                         item.setForeground(fg)
                         
                         try:
                             item.setBackgroundColor(QtGui.QColor(*bgcolor))
                         except AttributeError: # for PySide
                             pass
                         
                         # set this version to the item
                         item.version = version
                         
                     else:
                         # set the background color to black
                         item = QtGui.QTableWidgetItem('-')
                         item.setTextAlignment(0x0004 | 0x0080)
                         bg = item.background()
                         bg.setColor(QtGui.QColor(0, 0, 0))
                         item.setBackground(bg)
                         
                         try:
                             item.setBackgroundColor(QtGui.QColor(0, 0, 0))
                         except AttributeError: # for PySide
                             pass
                         
                         # set the version to None for this item
                         item.version = None
                     
                     items.append(item)
                 
                 row += 1
     
     self.shots_tableWidget.setRowCount(row)
     
     item_index = 0
     for r in range(row):
         for c in range(column + 1):
             item = items[item_index]
             self.shots_tableWidget.setItem(r, c, item)
             item_index += 1
     
     # adjust the row heights accordingly
     self.shots_tableWidget.resizeRowsToContents()
     
     # need to pass over the first rows again
     # to resize the thumbnail cell
     for r in range(row):
         item_index = r * (column + 1)
         item = items[item_index]
         if item.has_thumbnail:
             # scale the row height
             self.shots_tableWidget.setRowHeight(
                 r,
                 conf.thumbnail_size[1] / 2
             )
     
     # resize columns to fit the content
     self.shots_tableWidget.resizeColumnsToContents()
     
     # set the column width
     self.shots_tableWidget.setColumnWidth(0, conf.thumbnail_size[0] / 2)