Пример #1
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 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))
Пример #4
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)
Пример #5
0
 def test_project_attribute_is_read_only(self):
     """testing if the project attribute is read-only
     """
     new_proj2 = Project("TEST_PROJECT2")
     new_proj2.save()
     self.assertRaises(AttributeError, setattr, self.test_sequence,
                       "project", new_proj2)
Пример #6
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_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')
Пример #8
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_projects_comboBox_is_filled_with_projects_on_the_database(self):
        """testing if the projects_comboBox is filled with Project instances
        from the database
        """
        
        # create a couple of projects
        project1 = Project("Test Project 1")
        project2 = Project("Test Project 2")
        project3 = Project("Test Project 3")
        
        project3.active = False
        
        project1.save()
        project2.save()
        project3.save()
        
        # open UI
        dialog = project_manager.MainDialog()
        #self.show_dialog(dialog)

        
        # check if the projects are listed there
        self.assertEqual(dialog.projects_comboBox.count(), 3)

        item_texts = []
        for i in range(3):
            dialog.projects_comboBox.setCurrentIndex(i)
            item_texts.append(dialog.projects_comboBox.currentText())
        
        self.assertTrue(project1.name in item_texts)
        self.assertTrue(project2.name in item_texts)
        self.assertTrue(project3.name in item_texts)
Пример #10
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)
Пример #11
0
    def test_UI_will_edit_the_given_Project_instance(self):
        """testing if a Project instance is passed the interface will allow the
        given Project instance to be edited
        """

        new_client = Client(name='Test Client 1')
        new_client.save()

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

        dialog = project_properties.MainDialog(project=new_project)

        # now edit the project from the UI
        new_name = "Test Project New Name"
        new_fps = 50
        dialog.name_lineEdit.setText(new_name)
        new_client_2_name = 'Test Client 2'
        dialog.clients_comboBox.lineEdit().setText(new_client_2_name)
        dialog.fps_spinBox.setValue(new_fps)
        dialog.resolution_comboBox.setCurrentIndex(3)
        preset_name = dialog.resolution_comboBox.currentText()
        resolution_data = conf.resolution_presets[preset_name]
        dialog.active_checkBox.setChecked(False)
        dialog.shot_number_prefix_lineEdit.setText("PL")
        dialog.shot_number_padding_spinBox.setValue(5)
        dialog.revision_number_prefix_lineEdit.setText("rev")
        dialog.revision_number_padding_spinBox.setValue(3)
        dialog.version_number_prefix_lineEdit.setText("ver")
        dialog.version_number_padding_spinBox.setValue(5)
        new_structure = "This is the new structure\nwith three lines\n" + \
                        "and this is the third line"
        dialog.structure_textEdit.setText(new_structure)

        # hit ok
        QTest.mouseClick(dialog.buttonBox.buttons()[0], Qt.LeftButton)

        # now check the data
        self.assertEqual(new_project.name, new_name)
        self.assertEqual(new_project.client.name, new_client_2_name)
        # check if a client is created with that name

        new_client_2 = Client.query().filter(
            Client.name == new_client_2_name).first()
        self.assertIsInstance(new_client_2, Client)

        self.assertEqual(new_project.fps, new_fps)
        self.assertEqual(new_project.width, resolution_data[0])
        self.assertEqual(new_project.height, resolution_data[1])
        self.assertEqual(new_project.pixel_aspect, resolution_data[2])
        self.assertEqual(new_project.active, False)
        self.assertEqual(new_project.shot_number_padding, 5)
        self.assertEqual(new_project.shot_number_prefix, "PL")
        self.assertEqual(new_project.rev_number_padding, 3)
        self.assertEqual(new_project.rev_number_prefix, "rev")
        self.assertEqual(new_project.ver_number_padding, 5)
        self.assertEqual(new_project.ver_number_prefix, "ver")
        self.assertEqual(new_project.structure, new_structure)
    def test_UI_will_edit_the_given_Project_instance(self):
        """testing if a Project instance is passed the interface will allow the
        given Project instance to be edited
        """
        
        new_client = Client(name='Test Client 1')
        new_client.save()
        
        new_project = Project("Test Project")
        new_project.create()
        
        dialog = project_properties.MainDialog(project=new_project)
        
        # now edit the project from the UI
        new_name = "Test Project New Name"
        new_fps = 50
        dialog.name_lineEdit.setText(new_name)
        new_client_2_name = 'Test Client 2'
        dialog.clients_comboBox.lineEdit().setText(new_client_2_name)
        dialog.fps_spinBox.setValue(new_fps)
        dialog.resolution_comboBox.setCurrentIndex(3)
        preset_name = dialog.resolution_comboBox.currentText()
        resolution_data = conf.resolution_presets[preset_name]
        dialog.active_checkBox.setChecked(False)
        dialog.shot_number_prefix_lineEdit.setText("PL")
        dialog.shot_number_padding_spinBox.setValue(5)
        dialog.revision_number_prefix_lineEdit.setText("rev")
        dialog.revision_number_padding_spinBox.setValue(3)
        dialog.version_number_prefix_lineEdit.setText("ver")
        dialog.version_number_padding_spinBox.setValue(5)
        new_structure = "This is the new structure\nwith three lines\n" + \
                        "and this is the third line"
        dialog.structure_textEdit.setText(new_structure)
        
        # hit ok
        QTest.mouseClick(dialog.buttonBox.buttons()[0], Qt.LeftButton)

        # now check the data
        self.assertEqual(new_project.name, new_name)
        self.assertEqual(new_project.client.name, new_client_2_name)
        # check if a client is created with that name
        
        new_client_2 = Client.query().filter(Client.name==new_client_2_name).first()
        self.assertIsInstance(new_client_2, Client)
        
        self.assertEqual(new_project.fps, new_fps)
        self.assertEqual(new_project.width, resolution_data[0])
        self.assertEqual(new_project.height, resolution_data[1])
        self.assertEqual(new_project.pixel_aspect, resolution_data[2])
        self.assertEqual(new_project.active, False)
        self.assertEqual(new_project.shot_number_padding, 5)
        self.assertEqual(new_project.shot_number_prefix, "PL")
        self.assertEqual(new_project.rev_number_padding, 3)
        self.assertEqual(new_project.rev_number_prefix, "rev")
        self.assertEqual(new_project.ver_number_padding, 5)
        self.assertEqual(new_project.ver_number_prefix, "ver")
        self.assertEqual(new_project.structure, new_structure)
 def test_code_lineEdit_is_disabled_when_an_existing_Project_is_passed(self):
     """testing if the code_lineEdit is disabled when an existing Project
     instance is passed to the UI
     """
     new_project = Project("Test Project 1")
     new_project.create()
     
     dialog = project_properties.MainDialog(project=new_project)
     
     self.assertFalse(dialog.code_lineEdit.isEnabled())
    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)
Пример #15
0
    def test_code_lineEdit_is_disabled_when_an_existing_Project_is_passed(
            self):
        """testing if the code_lineEdit is disabled when an existing Project
        instance is passed to the UI
        """
        new_project = Project("Test Project 1")
        new_project.create()

        dialog = project_properties.MainDialog(project=new_project)

        self.assertFalse(dialog.code_lineEdit.isEnabled())
Пример #16
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)
Пример #17
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__code_is_not_unique_for_the_different_project(self):
        """testing if no IntegrityError will be raised when the _code attribute
        is not unique for to different projects
        """

        project1 = Project("CODE_TEST_PROJECT_1")
        project1.save()

        project2 = Project("CODE_TEST_PROJECT_2")
        project2.save()

        vbase1 = VersionableBase()
        vbase1._code = "Test"
        vbase1._project = project1

        db.session.add(vbase1)
        db.session.commit()

        vbase2 = VersionableBase()
        vbase2._code = "Test"
        vbase2._project = project2

        db.session.add(vbase2)

        # do not expect any IntegrityError
        db.session.commit()
Пример #19
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"),
        ]
Пример #20
0
    def setUp(self):
        """setup the test settings with environment variables
        """
        # -----------------------------------------------------------------
        # 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_PROJ1")
        self.test_project.create()
        self.test_project.save()

        self.kwargs = {
            #            "project": self.test_project,
            "name": "Test VType",
            "code": "TVT",
            "path": "{{project.full_path}}/Sequences/{{sequence.code}}/SHOTS/{{version.base_name}}/{{type.code}}",
            "filename": "{{version.base_name}}_{{version.take_name}}_{{type.code}}_v{{'%03d'|format(version.version_number)}}_{{version.created_by.initials}}",
            "environments": ["MAYA", "HOUDINI"],
            "output_path": "SHOTS/{{version.base_name}}/{{type.code}}/OUTPUT/{{version.take_name}}",
            "extra_folders": """{{version.path}}/exports
            {{version.path}}/cache
            """,
            "type_for": "Shot",
        }

        self.test_versionType = VersionType(**self.kwargs)
        self.test_versionType.save()

        self._name_test_values = [
            ("base name", "Base_Name"),
            ("123123 base_name", "Base_Name"),
            ("123432!+!'^+Base_NAme323^+'^%&+%&324", "Base_NAme323324"),
            ("    ---base 9s_name", "Base_9s_Name"),
            ("    ---base 9s-name", "Base_9s_Name"),
            (
                " multiple     spaces are    converted to under     scores",
                "Multiple_Spaces_Are_Converted_To_Under_Scores",
            ),
            ("camelCase", "CamelCase"),
            ("CamelCase", "CamelCase"),
            ("_Project_Setup_", "Project_Setup"),
            ("_PROJECT_SETUP_", "PROJECT_SETUP"),
            ("FUL_3D", "FUL_3D"),
            ("BaseName", "BaseName"),
            ("baseName", "BaseName"),
            (" baseName", "BaseName"),
            (" base name", "Base_Name"),
            (" 12base name", "Base_Name"),
            (" 12 base name", "Base_Name"),
            (" 12 base name 13", "Base_Name_13"),
            (">£#>$#£½$ 12 base £#$£#$£½¾{½{ name 13", "Base_Name_13"),
            ("_base_name_", "Base_Name"),
        ]
Пример #21
0
 def _validate_name(self, key, name):
     """validates the given name
     """
     
     name = Project._condition_name(name)
     
     return name
Пример #22
0
    def setUp(self):
        """setup the tests
        """
        # -----------------------------------------------------------------
        # start of the setUp
        # create the environment variable and point it to a temp directory
        conf.database_url = "sqlite://"

        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

        # create a test project
        self.project = Project("Test Project")
        self.project.create()

        # create a test asset
        self.asset1 = Asset(self.project, "Test Asset 1")

        # version type
        self.asset_vtypes = VersionType.query()\
            .filter(VersionType.type_for == "Asset").all()

        self.shot_vtypes = VersionType.query()\
            .filter(VersionType.type_for == "Shot").all()

        self.user1 = User(name="Test User 1", email="*****@*****.**")

        # create a test version
        self.kwargs = {
            "version_of": self.asset1,
            "base_name": self.asset1.code,
            "type": self.asset_vtypes[0],
            "created_by": self.user1,
            "extension": "ma"
        }

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

        # create the environment instance
        self.mEnv = mayaEnv.Maya()

        # just renew the scene
        pm.newFile(force=True)
Пример #23
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)
Пример #24
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)
Пример #25
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)
Пример #26
0
    def test_save_as_sets_the_fps(self):
        """testing if the save_as method sets the fps value correctly
        """

        # create two projects with different fps values
        # first create a new scene and save it under the first project
        # and then save it under the other project
        # and check if the fps follows the project values

        project1 = Project("FPS_TEST_PROJECT_1")
        project1.fps = 24
        project1.create()

        project2 = Project("FPS_TEST_PROJECT_2")
        project2.fps = 30
        project2.save()

        # create assets
        asset1 = Asset(project1, "Test Asset 1")
        asset1.save()

        asset2 = Asset(project2, "Test Asset 2")
        asset2.save()

        # create versions
        version1 = Version(version_of=asset1,
                           base_name=asset1.code,
                           type=self.asset_vtypes[0],
                           created_by=self.user1)

        version2 = Version(version_of=asset2,
                           base_name=asset2.code,
                           type=self.asset_vtypes[0],
                           created_by=self.user1)

        # save the current scene for asset1
        self.mEnv.save_as(version1)

        # check the fps value
        self.assertEqual(self.mEnv.get_fps(), 24)

        # now save it for asset2
        self.mEnv.save_as(version2)

        # check the fps value
        self.assertEqual(self.mEnv.get_fps(), 30)
Пример #27
0
 def test_save_as_sets_the_fps(self):
     """testing if the save_as method sets the fps value correctly
     """
     
     # create two projects with different fps values
     # first create a new scene and save it under the first project
     # and then save it under the other project
     # and check if the fps follows the project values
     
     project1 = Project("FPS_TEST_PROJECT_1")
     project1.fps = 24
     project1.create()
     
     project2 = Project("FPS_TEST_PROJECT_2")
     project2.fps = 30
     project2.save()
     
     # create assets
     asset1 = Asset(project1, "Test Asset 1")
     asset1.save()
     
     asset2 = Asset(project2, "Test Asset 2")
     asset2.save()
     
     # create versions
     version1 = Version(
         version_of=asset1,
         base_name=asset1.code,
         type=self.asset_vtypes[0],
         created_by=self.user1
     )
     
     version2 = Version(
         version_of=asset2,
         base_name=asset2.code,
         type=self.asset_vtypes[0],
         created_by=self.user1
     )
     
     # save the current scene for asset1
     self.mEnv.save_as(version1)
     
     # check the fps value
     self.assertEqual(
         self.mEnv.get_fps(),
         24
     )
     
     # now save it for asset2
     self.mEnv.save_as(version2)
     
     # check the fps value
     self.assertEqual(
         self.mEnv.get_fps(),
         30
     )
Пример #28
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()
Пример #29
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()
Пример #30
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)
Пример #31
0
 def test_save_as_references_to_a_version_in_same_workspace_are_replaced_with_abs_path_with_env_variable(self):
     """testing if the save_as method updates the references paths with an
     absolute path starting with conf.repository_env_key for references to
     a version in the same project thus the referenced path is relative
     """
     
     # create project
     proj1 = Project("Proj1")
     proj1.save()
     proj1.create()
     
     # create assets
     asset1 = Asset(proj1, "Asset 1")
     asset1.save()
     
     # create a version of asset vtype 
     vers1 = Version(asset1, asset1.code, self.asset_vtypes[0], self.user1)
     vers1.save()
     
     # save it
     self.mEnv.save_as(vers1)
     
     # new scene
     pm.newFile(force=True)
     
     # create another version with different type
     vers2 = Version(asset1, asset1.code, self.asset_vtypes[1], self.user1)
     vers2.save()
     
     # reference the other version
     self.mEnv.reference(vers1)
     
     # save it
     self.mEnv.save_as(vers2)
     
     # now check if the referenced vers1 starts with $REPO
     refs = pm.listReferences()
     
     # there should be only one ref
     self.assertTrue(len(refs)==1)
     
     # and the path should start with conf.repository_env_key
     self.assertTrue(
         refs[0].unresolvedPath().startswith("$" + conf.repository_env_key)
     )
Пример #32
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)
Пример #33
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)
Пример #34
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()
     )
Пример #35
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()
    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)
 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
         )
     )
Пример #38
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()
    def test_projects_comboBox_index_is_0_on_init(self):
        """testing if the projects_comboBox is set to the first project on the
        list when __init__
        """

        project1 = Project("Test Project 1")
        project2 = Project("Test Project 2")
        project3 = Project("Test Project 3")
        
        project1.save()
        project2.save()
        project3.save()
        
        dialog = project_manager.MainDialog()
        
        self.assertEqual(dialog.projects_comboBox.currentIndex(), 0)
Пример #40
0
 def test_reference_creates_references_to_Versions_in_other_workspaces_loaded(self):
     """testing if reference method creates references to Versions with
     different VersionType and the reference state will be loaded
     """
     
     proj1 = Project("Test Project 1")
     proj1.create()
     proj1.save()
 
     asset1 = Asset(proj1, "Test Asset 1")
     asset1.save()
 
     vers1 = Version(asset1, asset1.code, self.asset_vtypes[0], self.user1)
     vers1.save()
 
     vers2 = Version(asset1, asset1.code, self.asset_vtypes[1], self.user1)
     vers2.save()
 
     self.mEnv.save_as(vers1)
 
     pm.newFile(force=True)
 
     self.mEnv.save_as(vers2)
 
     # refence vers1 to vers2
     self.mEnv.reference(vers1)
 
     # now check if the referenced files unresolved path is already starting
     # with conf.repository_env_key
     
     refs = pm.listReferences()
 
     # there should be only one reference
     self.assertEqual(len(refs), 1)
 
     # the unresolved path should start with $REPO
     self.assertTrue(
         refs[0].unresolvedPath().startswith("$" + conf.repository_env_key)
     )
     
     self.assertTrue(refs[0].isLoaded())
Пример #41
0
 def test_save_as_of_a_scene_with_two_references_to_the_same_version(self):
     """testing if the case where the current maya scene has two references
     to the same file is gracefully handled by assigning the version only
     once
     """
     
     # create project
     proj1 = Project("Proj1")
     proj1.save()
     proj1.create()
     
     # create assets
     asset1 = Asset(proj1, "Asset 1")
     asset1.save()
     
     # create a version of asset vtype 
     vers1 = Version(asset1, asset1.code, self.asset_vtypes[0], self.user1)
     vers1.save()
     
     # save it
     self.mEnv.save_as(vers1)
     
     # new scene
     pm.newFile(force=True)
     
     # create another version with different type
     vers2 = Version(asset1, asset1.code, self.asset_vtypes[1], self.user1)
     vers2.save()
     
     # reference the other version twice
     self.mEnv.reference(vers1)
     self.mEnv.reference(vers1)
     
     # save it and expect no InvalidRequestError
     self.mEnv.save_as(vers2)
     
     self.mEnv.reference(vers1)
     vers3 = Version(asset1, asset1.code, self.asset_vtypes[1], self.user1)
     vers3.save()
     
     self.mEnv.save_as(vers3)
 def test__code_is_not_unique_for_the_different_project(self):
     """testing if no IntegrityError will be raised when the _code attribute
     is not unique for to different projects
     """
     
     project1 = Project("CODE_TEST_PROJECT_1")
     project1.save()
     
     project2 = Project("CODE_TEST_PROJECT_2")
     project2.save()
     
     vbase1 = VersionableBase()
     vbase1._code = "Test"
     vbase1._project = project1
     
     db.session.add(vbase1)
     db.session.commit()
     
     vbase2 = VersionableBase()
     vbase2._code = "Test"
     vbase2._project = project2
     
     db.session.add(vbase2)
     
     # do not expect any IntegrityError
     db.session.commit()
Пример #43
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)
Пример #44
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)
Пример #45
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)
Пример #46
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()
Пример #47
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
    def test__code_is_not_unique_for_the_same_project(self):
        """testing if a IntegrityError will be raised when the _code attribute
        is not unique for the same project
        """

        project = Project("CODE_TEST_PROJECT")
        project.save()

        vbase1 = VersionableBase()
        vbase1._code = "Test"
        vbase1._project = project

        db.session.add(vbase1)
        db.session.commit()

        vbase2 = VersionableBase()
        vbase2._code = "Test"
        vbase2._project = project

        db.session.add(vbase2)

        # now expect an IntegrityError
        self.assertRaises(IntegrityError, db.session.commit)
Пример #49
0
 def _validate_code(self, key, code):
     """validates the given code value
     """
     
     if code is None:
         code = self.name
     
     if not isinstance(code, (str, unicode)):
         raise TypeError("Sequence.code should be an instance of str or "
                         "unicode, not %s" % type(code))
     
     code = Project._condition_code(code)
     
     return code
Пример #50
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)
Пример #51
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)
    def test__code_is_not_unique_for_the_same_project(self):
        """testing if a IntegrityError will be raised when the _code attribute
        is not unique for the same project
        """

        project = Project("CODE_TEST_PROJECT")
        project.save()
        
        vbase1 = VersionableBase()
        vbase1._code = "Test"
        vbase1._project = project

        db.session.add(vbase1)
        db.session.commit()

        vbase2 = VersionableBase()
        vbase2._code = "Test"
        vbase2._project = project

        db.session.add(vbase2)

        # now expect an IntegrityError
        self.assertRaises(IntegrityError, db.session.commit)
Пример #53
0
    def _validate_project(self, project):
        """validates the given project value
        """

        if not isinstance(project, Project) and \
           not isinstance(project, str):
            raise TypeError("BackUp.project should be an instance of"
                            "oyProjectManager.models.project.Project instance")

        if project == "":
            raise ValueError

        if isinstance(project, (str, unicode)):
            project = Project(name=project)

        if not project.exists:
            raise RuntimeError("The project doesn't exists, so it can not be "
                               "backup")

        return project
Пример #54
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)
Пример #55
0
    def update_project_comboBox(self):
        """Updates the projects_comboBox
        """

        # fill projects
        projects = Project.query()\
            .order_by(Project.name.asc())\
            .all()

        # cache the projects
        self.projects_comboBox.projects = projects

        self.projects_comboBox.clear()
        #self.projects_comboBox.addItems(map(lambda x: x.name, projects))
        for i, project in enumerate(projects):
            if project.active:
                self.projects_comboBox.addItem(project.name)
            else:
                self.projects_comboBox.addItem(
                    QtGui.QIcon(
                        ":/trolltech/styles/commonstyle/images/stop-24.png"),
                    project.name)
Пример #56
0
    def test_save_as_references_to_a_version_in_same_workspace_are_replaced_with_abs_path_with_env_variable(
            self):
        """testing if the save_as method updates the references paths with an
        absolute path starting with conf.repository_env_key for references to
        a version in the same project thus the referenced path is relative
        """

        # create project
        proj1 = Project("Proj1")
        proj1.save()
        proj1.create()

        # create assets
        asset1 = Asset(proj1, "Asset 1")
        asset1.save()

        # create a version of asset vtype
        vers1 = Version(asset1, asset1.code, self.asset_vtypes[0], self.user1)
        vers1.save()

        # save it
        self.mEnv.save_as(vers1)

        # new scene
        pm.newFile(force=True)

        # create another version with different type
        vers2 = Version(asset1, asset1.code, self.asset_vtypes[1], self.user1)
        vers2.save()

        # reference the other version
        self.mEnv.reference(vers1)

        # save it
        self.mEnv.save_as(vers2)

        # now check if the referenced vers1 starts with $REPO
        refs = pm.listReferences()

        # there should be only one ref
        self.assertTrue(len(refs) == 1)

        # and the path should start with conf.repository_env_key
        self.assertTrue(
            refs[0].unresolvedPath().startswith("$" + conf.repository_env_key))
Пример #57
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)
Пример #58
0
    def test_reference_creates_references_to_Versions_in_other_workspaces_loaded(
            self):
        """testing if reference method creates references to Versions with
        different VersionType and the reference state will be loaded
        """

        proj1 = Project("Test Project 1")
        proj1.create()
        proj1.save()

        asset1 = Asset(proj1, "Test Asset 1")
        asset1.save()

        vers1 = Version(asset1, asset1.code, self.asset_vtypes[0], self.user1)
        vers1.save()

        vers2 = Version(asset1, asset1.code, self.asset_vtypes[1], self.user1)
        vers2.save()

        self.mEnv.save_as(vers1)

        pm.newFile(force=True)

        self.mEnv.save_as(vers2)

        # refence vers1 to vers2
        self.mEnv.reference(vers1)

        # now check if the referenced files unresolved path is already starting
        # with conf.repository_env_key

        refs = pm.listReferences()

        # there should be only one reference
        self.assertEqual(len(refs), 1)

        # the unresolved path should start with $REPO
        self.assertTrue(
            refs[0].unresolvedPath().startswith("$" + conf.repository_env_key))

        self.assertTrue(refs[0].isLoaded())