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)
예제 #2
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)
예제 #3
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!')
예제 #4
0
    def test_assets_tableWidget_is_filled_with_Asset_data(self):
        """testing if the assets_tableWidget is filled with asset data properly
        """

        db.setup()

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

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

        asset_vtypes = VersionType.query()\
            .filter(VersionType.type_for=='Asset')\
            .order_by(VersionType.name)\
            .all()

        admin = User.query().first()

        asset1 = Asset(proj1, 'Test Asset 1', type='Char')
        asset1.save()

        asset2 = Asset(proj1, 'Test Asset 2', type='Prop')
        asset2.save()

        asset3 = Asset(proj1, 'Test Asset 3', type='Environment')
        asset3.save()

        asset4 = Asset(proj1, 'Test Asset 4', type='Prop')
        asset4.save()

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

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

        version3 = Version(version_of=asset1,
                           base_name=asset1.code,
                           type=asset_vtypes[2],
                           created_by=admin,
                           status=conf.status_list[2])
        version3.save()

        # version for asset1 with different takes
        version4 = Version(version_of=asset1,
                           base_name=asset1.code,
                           type=asset_vtypes[3],
                           created_by=admin,
                           status=conf.status_list[3],
                           take_name='Test_A')
        version4.save()

        version5 = Version(version_of=asset1,
                           base_name=asset1.code,
                           type=asset_vtypes[4],
                           created_by=admin,
                           status=conf.status_list[4],
                           take_name='Test_A')
        version5.save()

        version6 = Version(version_of=asset1,
                           base_name=asset1.code,
                           type=asset_vtypes[5],
                           created_by=admin,
                           status=conf.status_list[4],
                           take_name='Test_B')
        version6.save()

        version7 = Version(version_of=asset1,
                           base_name=asset1.code,
                           type=asset_vtypes[5],
                           created_by=admin,
                           status=conf.status_list[4],
                           take_name='Test_B')
        version7.save()

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

        # start tests

        # What we should see shoul be:
        #
        # +-----------+-------------+--------------+--------+---------------------+
        # | Thumbnail | Type        |     Name     |  Take  | Asset Version Types |
        # +===========+=============+==============+========+=====================+
        # |  (IMAGE)  | Char        | Test Asset 1 |  MAIN  | ******************* |
        # +-----------+-------------+--------------+--------+---------------------+
        # |  (IMAGE)  | Char        | Test Asset 1 | Test_A | ******************* |
        # +-----------+-------------+--------------+--------+---------------------+
        # |  (IMAGE)  | Char        | Test Asset 1 | Test_B | ******************* |
        # +-----------+-------------+--------------+--------+---------------------+
        # |  (IMAGE)  | Environment | Test Asset 3 |  ----  | ******************* |
        # +-----------+-------------+--------------+--------+---------------------+
        # |  (IMAGE)  | Prop        | Test Asset 2 |  ----  | ******************* |
        # +-----------+-------------+--------------+--------+---------------------+
        # |  (IMAGE)  | Prop        | Test Asset 4 |  ----  | ******************* |
        # +-----------+-------------+--------------+--------+---------------------+
        #

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

        # asset1's vtypes[0] vtypes[1] vtypes[2] vtypes[3]
        # set to assets
        dialog.tabWidget.setCurrentIndex(0)
        #self.show_dialog(dialog)

        # expect to see 6 rows
        self.assertEqual(6, dialog.assets_tableWidget.rowCount())

        # expect the assets types listed in the first column
        # first three should be Char
        dialog.assets_tableWidget.setCurrentCell(0, 1)
        self.assertEqual('Char',
                         dialog.assets_tableWidget.currentItem().text())
        dialog.assets_tableWidget.setCurrentCell(1, 1)
        self.assertEqual('Char',
                         dialog.assets_tableWidget.currentItem().text())
        dialog.assets_tableWidget.setCurrentCell(2, 1)
        self.assertEqual('Char',
                         dialog.assets_tableWidget.currentItem().text())

        # next should be Environment
        dialog.assets_tableWidget.setCurrentCell(3, 1)
        self.assertEqual('Environment',
                         dialog.assets_tableWidget.currentItem().text())

        # the next two should be Prop
        dialog.assets_tableWidget.setCurrentCell(4, 1)
        self.assertEqual('Prop',
                         dialog.assets_tableWidget.currentItem().text())
        dialog.assets_tableWidget.setCurrentCell(5, 1)
        self.assertEqual('Prop',
                         dialog.assets_tableWidget.currentItem().text())
예제 #5
0
    def test_passing_a_Project_instance_will_fill_the_interface_with_the_project(
            self):
        """testing if passing a Project instance will fill the interface with
        the data coming from the given Project instance
        """

        new_client = Client(name='Client Agency 1', code='CA1')
        new_client.save()

        new_project = Project("Test Project")
        new_project.client = new_client
        new_project.width = 720
        new_project.height = 576
        new_project.pixel_aspect = 1.067
        new_project.fps = 30
        new_project.active = True

        dialog = project_properties.MainDialog(project=new_project)

        # now check if the interface is filled properly
        self.assertEqual(dialog.name_lineEdit.text(), new_project.name)

        self.assertEqual(dialog.code_lineEdit.text(), new_project.code)

        # preset name
        preset_name = dialog.resolution_comboBox.currentText()

        self.assertEqual(conf.resolution_presets[preset_name][0],
                         new_project.width)

        self.assertEqual(conf.resolution_presets[preset_name][1],
                         new_project.height)

        self.assertEqual(conf.resolution_presets[preset_name][2],
                         new_project.pixel_aspect)

        self.assertEqual(dialog.fps_spinBox.value(), new_project.fps)

        self.assertEqual(dialog.active_checkBox.isChecked(), True)

        # Advanced settings
        self.assertEqual(dialog.shot_number_prefix_lineEdit.text(),
                         new_project.shot_number_prefix)

        self.assertEqual(dialog.shot_number_padding_spinBox.value(),
                         new_project.shot_number_padding)

        #        self.assertEqual(
        #            dialog.revision_number_prefix_lineEdit.text(),
        #            new_project.rev_number_prefix
        #        )

        #        self.assertEqual(
        #            dialog.revision_number_padding_spinBox.value(),
        #            new_project.rev_number_padding
        #        )

        #        self.assertEqual(
        #            dialog.version_number_prefix_lineEdit.text(),
        #            new_project.ver_number_prefix
        #        )

        #        self.assertEqual(
        #            dialog.version_number_padding_spinBox.value(),
        #            new_project.ver_number_padding
        #        )

        self.assertEqual(dialog.structure_textEdit.toPlainText(),
                         new_project.structure)
    def test_shots_comboBox_is_filled_with_the_shots_from_the_current_sequence(
            self):
        """testing if the shots_comboBox is filled with the shots from the
        currently selected Sequence instance
        """

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

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

        # sequences
        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()

        # shots
        shot1 = Shot(seq1, 1)
        shot2 = Shot(seq1, 2)
        shot3 = Shot(seq1, 3)

        shot4 = Shot(seq2, 4)
        shot5 = Shot(seq2, 5)
        shot6 = Shot(seq2, 6)

        shot7 = Shot(seq3, 7)
        shot8 = Shot(seq3, 8)
        shot9 = Shot(seq3, 9)

        shot10 = Shot(seq4, 10)
        shot11 = Shot(seq4, 11)
        shot12 = Shot(seq4, 12)

        db.session.add_all([
            shot1, shot2, shot3, shot4, shot5, shot6, shot7, shot8, shot9,
            shot10, shot11, shot12
        ])
        db.session.commit()

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

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

        # set to seq1
        index = dialog.sequences_comboBox.findText(seq1.name)
        dialog.sequences_comboBox.setCurrentIndex(index)

        # check if shots_comboBox has 3 entries
        self.assertEqual(dialog.shots_comboBox.count(), 3)

        # check if shot1, shot2, shot3 are in the comboBox
        item_texts = []
        for i in range(3):
            dialog.shots_comboBox.setCurrentIndex(i)
            item_texts.append(dialog.shots_comboBox.currentText())

        self.assertTrue(shot1.code in item_texts)
        self.assertTrue(shot2.code in item_texts)
        self.assertTrue(shot3.code in item_texts)

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

        # set to seq4
        index = dialog.sequences_comboBox.findText(seq4.name)
        dialog.sequences_comboBox.setCurrentIndex(index)

        # check if shots_comboBox has 3 entries
        self.assertEqual(dialog.shots_comboBox.count(), 3)

        # check if shot10, shot11, shot12 are in the comboBox
        item_texts = []
        for i in range(3):
            dialog.shots_comboBox.setCurrentIndex(i)
            item_texts.append(dialog.shots_comboBox.currentText())

        self.assertTrue(shot10.code in item_texts)
        self.assertTrue(shot11.code in item_texts)
        self.assertTrue(shot12.code in item_texts)
    def button_box_ok_clicked(self):
        """runs when the ok button clicked
        """

        # if there is no project given create a new one and return it

        # create_project
        # get the data from the input fields
        name = self.name_lineEdit.text()
        code = self.code_lineEdit.text()
        # check if the code is empty
        if code == "":
            # raise an error please
            QtGui.QMessageBox.critical(
                self, "Error", "Code field can not be empty,\n"
                "Please enter a proper Code!!!")
            return

        client_name = self.clients_comboBox.currentText()
        client = Client.query().filter(Client.name == client_name).first()
        if not client:
            # just create the client
            client = Client(name=client_name)
            client.save()

        resolution_name = self.resolution_comboBox.currentText()
        resolution_data = conf.resolution_presets[resolution_name]
        fps = self.fps_spinBox.value()
        active = self.active_checkBox.isChecked()

        # advanced properties
        shot_number_padding = self.shot_number_padding_spinBox.value()
        shot_number_prefix = self.shot_number_prefix_lineEdit.text()
        rev_number_padding = self.revision_number_padding_spinBox.value()
        rev_number_prefix = self.revision_number_prefix_lineEdit.text()
        ver_number_padding = self.version_number_padding_spinBox.value()
        ver_number_prefix = self.version_number_prefix_lineEdit.text()
        structure_code = self.structure_textEdit.toPlainText()

        is_new_project = False

        if self.project is None:
            logger.debug("no project is given creating new one")
            # create the project

            self.project = Project(name=name, code=code)
            is_new_project = True

        else:
            logger.debug("updating the given project")

        # update the project
        self.project.name = name
        self.project.client = client
        self.project.fps = fps
        self.project.width = resolution_data[0]
        self.project.height = resolution_data[1]
        self.project.pixel_aspect = resolution_data[2]
        self.project.active = active
        self.project.shot_number_padding = shot_number_padding
        self.project.shot_number_prefix = shot_number_prefix
        self.project.rev_number_padding = rev_number_padding
        self.project.rev_number_prefix = rev_number_prefix
        self.project.ver_number_padding = ver_number_padding
        self.project.ver_number_prefix = ver_number_prefix
        self.project.structure = structure_code

        if is_new_project:
            self.project.create()
        else:
            self.project.save()

        # and close the dialog
        self.close()
예제 #8
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"),
        ]