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))
Exemple #2
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_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
         )
     )
Exemple #6
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")
     )
    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 update_shots_comboBox(self):
        """updates the shots_comboBox
        """

        sequence = self.get_current_sequence()
        shots = Shot.query()\
            .filter(Shot.sequence==sequence)\
            .order_by(Shot.code.asc())\
            .all()

        self.shots_comboBox.shots = shots
        self.shots_comboBox.clear()
        self.shots_comboBox.addItems(sorted(map(lambda x: x.code, shots)))
Exemple #9
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"))
 def update_shots_comboBox(self):
     """updates the shots_comboBox
     """
     
     sequence = self.get_current_sequence()
     shots = Shot.query()\
         .filter(Shot.sequence==sequence)\
         .order_by(Shot.code.asc())\
         .all()
     
     self.shots_comboBox.shots = shots
     self.shots_comboBox.clear()
     self.shots_comboBox.addItems(
         sorted(map(lambda x: x.code, shots))
     )
Exemple #11
0
 def get_next_alternate_shot_number(self, shot_number):
     """returns the next alternate shot_number number for the given shot_number number
     """
     
     # get the shot_number list
     alternate_letters = 'ABCDEFGHIJKLMNOPRSTUVWXYZ'
     
     for letter in alternate_letters:
         #check if the alternate is in the list
         
         new_shot_number = str(shot_number) + letter
         
         shot_from_db = Shot.query().\
             filter(Shot.sequence_id==self.id).\
             filter(Shot.number==new_shot_number).\
             first()
         
         if not shot_from_db:
             return new_shot_number
     
     return None
Exemple #12
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()
     )
Exemple #13
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)
    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)
Exemple #15
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!')
Exemple #16
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)
    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 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)
    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!')