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__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()
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()
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))
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)
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 )
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)
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)
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_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_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_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_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_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_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)
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)
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) )
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))
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)
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)
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() )
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 ) )
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)
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())
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_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_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())
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)
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)
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_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)
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)
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_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)
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)
def test_code_argument_is_not_unique_for_different_projects_2(self): """testing if no code argument is unique for different projects will not raise IntegrityError """ p1 = Project("Migros Kanguru", "MIGROS_KANGURU") p1.save() p2 = Project("Migros M-Label", "MIGROS_M_LABEL") p2.save() s1 = Sequence(p2, "TVC", "TVC") s1.save() p3 = Project("Fairy Obelix Booster", "FAIRY_OBELIX_BOOSTER") p3.save() s2 = Sequence(p3, "TVC", "TVC") s2.save()
def test_code_argument_is_not_unique_for_different_projects_2(self): """testing if no code argument is unique for different projects will not raise IntegrityError """ p1 = Project("Migros Kanguru", "MIGROS_KANGURU") p1.save() p2 = Project("Migros M-Label", "MIGROS_M_LABEL") p2.save() s1 = Sequence(p2, "TVC", "TVC") s1.save() p3 = Project("Fairy Obelix Booster", "FAIRY_OBELIX_BOOSTER") p3.save() s2 = Sequence(p3, "TVC", "TVC") s2.save()
def test_projects_comboBox_caches_Project_instances_in_projects_attribute(self): """testing if the projects_comboBox caches the Project instances in an attribute called projects """ 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.assertTrue(hasattr(dialog.projects_comboBox, "projects")) self.assertTrue(project1 in dialog.projects_comboBox.projects) self.assertTrue(project2 in dialog.projects_comboBox.projects) self.assertTrue(project3 in dialog.projects_comboBox.projects)
def test_projects_comboBox_caches_Project_instances_in_projects_attribute( self): """testing if the projects_comboBox caches the Project instances in an attribute called projects """ 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.assertTrue(hasattr(dialog.projects_comboBox, "projects")) self.assertTrue(project1 in dialog.projects_comboBox.projects) self.assertTrue(project2 in dialog.projects_comboBox.projects) self.assertTrue(project3 in dialog.projects_comboBox.projects)
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() )
class MainDialog(QtGui.QDialog, project_properties_UI.Ui_Dialog): """Dialog to edit project properties If a :class:`~oyProjectManager.models.project.Project` instance is also passed it will edit the given project. If no Project is passed then it will create and return a new one. """ def __init__(self, parent=None, project=None): super(MainDialog, self).__init__(parent) self.setupUi(self) if db.session is None: db.setup() self.resolution_presets = conf.resolution_presets self.project = project self._setup_signals() self._setup_defaults() self.update_UI_from_project(self.project) def _setup_signals(self): """sets up signals """ # cancel button QtCore.QObject.connect( self.buttonBox, QtCore.SIGNAL("rejected()"), self.close ) # ok button QtCore.QObject.connect( self.buttonBox, QtCore.SIGNAL("accepted()"), self.button_box_ok_clicked ) # changing the name of the project should also update the code # if the code field is empty QtCore.QObject.connect( self.name_lineEdit, QtCore.SIGNAL("textChanged(QString)"), self.name_edited ) def set_resolution_to_default(self): # set the resolution to the default preset index = self.resolution_comboBox.findText( conf.default_resolution_preset ) self.resolution_comboBox.setCurrentIndex(index) def _setup_defaults(self): """sets up the default values """ self.resolution_comboBox.addItems( sorted(conf.resolution_presets.keys()) ) self.set_resolution_to_default() # clients clients = map( lambda x: x.name, Client.query().order_by(Client.name.asc()).all() ) self.clients_comboBox.clear() self.clients_comboBox.addItems(clients) # set the fps to conf.default_fps self.fps_spinBox.setValue(conf.default_fps) # set active_checkBox to true self.active_checkBox.setChecked(True) # if a project is given don't let the user to try to change the code # attribute if self.project is not None: self.code_lineEdit.setEnabled(False) # advanced properties self.shot_number_padding_spinBox.setValue(conf.shot_number_padding) self.shot_number_prefix_lineEdit.setText(conf.shot_number_prefix) self.revision_number_padding_spinBox.setValue(conf.rev_number_padding) self.revision_number_prefix_lineEdit.setText(conf.rev_number_prefix) self.version_number_padding_spinBox.setValue(conf.ver_number_padding) self.version_number_prefix_lineEdit.setText(conf.ver_number_prefix) self.structure_textEdit.setText(conf.project_structure) def update_UI_from_project(self, project): """Updates the UI with the info from the given project instance :param project: The :class:`~oyProjectManager.models.project.Project` instance which the UI data will be read from. """ # if a project is given update the UI with the given project info if project is None: return self.name_lineEdit.setText(project.name) self.code_lineEdit.setText(project.code) if project.client: index = self.clients_comboBox.findText(project.client.name) if index != -1: self.clients_comboBox.setCurrentIndex(index) self.fps_spinBox.setValue(project.fps) self.active_checkBox.setChecked(project.active) # advanced properties self.shot_number_prefix_lineEdit.setText(project.shot_number_prefix) self.shot_number_padding_spinBox.setValue(project.shot_number_padding) self.revision_number_prefix_lineEdit.setText(project.rev_number_prefix) self.revision_number_padding_spinBox.setValue( project.rev_number_padding ) self.version_number_prefix_lineEdit.setText(project.ver_number_prefix) self.version_number_padding_spinBox.setValue(project.ver_number_padding) self.structure_textEdit.setText(project.structure) # set the resolution preset_key = None for key in conf.resolution_presets.keys(): if conf.resolution_presets[key] == [project.width, project.height, project.pixel_aspect]: preset_key = key break if preset_key is not None: index = self.resolution_comboBox.findText(preset_key) self.resolution_comboBox.setCurrentIndex(index) else: # set it to custom self.resolution_comboBox.setCurrentIndex( self.resolution_comboBox.count()-1 ) 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() def name_edited(self, new_name): """called by the ui event when the text in project name lineEdit changed, it updates the code field if the code field is empty :param new_name: the changed name """ # update only if the code field is empty import re new_code = re.sub(r'([^A-Z0-9]+)([\-\s]*)', '_', new_name.upper()) self.code_lineEdit.setText(new_code)
class VersionTypeTester(unittest.TestCase): """tests the VersionType class """ 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"), ] def tearDown(self): """cleanup the test """ # set the db.session to None db.session = None # delete the temp folder shutil.rmtree(self.temp_config_folder) shutil.rmtree(self.temp_projects_folder) def test_name_argument_is_None(self): """testing if a TypeError will be raised when the name argument is None """ self.kwargs["name"] = None self.assertRaises(TypeError, VersionType, **self.kwargs) def test_name_attribute_is_None(self): """testing if a TypeError will be raised when the name attribute is set to None """ self.assertRaises(TypeError, setattr, self.test_versionType, "name", None) def test_name_argument_is_not_a_string(self): """testing if a TypeError will be raised when the name argument is not a string or unicode instance """ self.kwargs["name"] = 123 self.assertRaises(TypeError, VersionType, **self.kwargs) def test_name_attribute_is_not_a_string(self): """testing if a TypeError will be raised when the name argument is not a string or unicode instance """ self.assertRaises(TypeError, setattr, self.test_versionType, "name", 8) def test_name_argument_is_working_properly(self): """testing if the name argument is working properly and sets the name attribute correctly """ self.assertEqual(self.kwargs["name"], self.test_versionType.name) def test_name_attribute_is_working_properly(self): """testing if the name attribute is working properly """ test_value = "New Name" self.test_versionType.name = test_value self.assertEqual(test_value, self.test_versionType.name) def test_name_attribute_is_not_unique(self): """testing if an IntegrityError error will be raised when the name argument is not unique """ # creating a new VersionType should raise the ?? error new_vtype = VersionType(**self.kwargs) self.assertRaises(IntegrityError, new_vtype.save) def test_code_argument_is_skipped(self): """testing if a TypeError will be raised when the code argument is skipped """ self.kwargs.pop("code") self.assertRaises(TypeError, VersionType, **self.kwargs) def test_code_argument_is_None(self): """testing if a TypeError will be raised when the code argument is None """ self.kwargs["code"] = None self.assertRaises(TypeError, VersionType, **self.kwargs) def test_code_attribute_is_None(self): """testing if a TypeError will be raised when the code attribute is set to None """ self.assertRaises(TypeError, setattr, self.test_versionType, "code", None) def test_code_argument_is_not_a_string(self): """testing if a TypeError will be raised when the code argument is not a string or unicode instance """ self.kwargs["code"] = 123 self.assertRaises(TypeError, VersionType, **self.kwargs) def test_code_attribute_is_not_a_string(self): """testing if a TypeError will be raised when the code argument is not a string or unicode instance """ self.assertRaises(TypeError, setattr, self.test_versionType, "code", 8) def test_code_argument_is_working_properly(self): """testing if the code argument is working properly and sets the code attribute correctly """ self.assertEqual(self.kwargs["code"], self.test_versionType.code) def test_code_attribute_is_working_properly(self): """testing if the code attribute is working properly """ test_value = "New Name" self.test_versionType.code = test_value self.assertEqual(test_value, self.test_versionType.code) def test_code_attribute_is_not_unique(self): """testing if an IntegrityError error will be raised when the code argument is not unique """ # creating a new VersionType should raise the IntegrityError self.kwargs["name"] = "A Different Name" new_vtype = VersionType(**self.kwargs) self.assertRaises(IntegrityError, new_vtype.save) def test_filename_argument_is_skipped(self): """testing if a TypeError will be raised when the filename argument is skipped """ self.kwargs.pop("filename") self.assertRaises(TypeError, VersionType, **self.kwargs) def test_filename_argument_is_empty_string(self): """testing if a ValueError will be raised when the filename argument is an empty string """ self.kwargs["filename"] = "" self.assertRaises(ValueError, VersionType, **self.kwargs) def test_filename_attribute_is_empty_string(self): """testing if a ValueError will be raised when the filename attribute is set to an empty string """ self.assertRaises(ValueError, setattr, self.test_versionType, "filename", "") def test_filename_argument_is_not_a_string(self): """testing if a TypeError will be raised when the filename argument is not a string instance """ self.kwargs["filename"] = 13245 self.assertRaises(TypeError, VersionType, **self.kwargs) def test_filename_attribute_is_not_a_string(self): """testing if a TypeError will be raised when the filename attribute is not a string instance """ self.assertRaises(TypeError, setattr, self.test_versionType, "filename", 23412) def test_filename_argument_is_working_properly(self): """testing if the filename attribute is initialized correctly with the same value of the filename argument """ self.assertEqual(self.test_versionType.filename, self.kwargs["filename"]) def test_filename_attribute_is_working_properly(self): """testing if the filename attribute is working properly """ test_value = "test_filename" self.test_versionType.filename = test_value self.assertEqual(self.test_versionType.filename, test_value) def test_path_argument_is_skipped(self): """testing if a TypeError will be raised when the path argument is skipped """ self.kwargs.pop("path") self.assertRaises(TypeError, VersionType, **self.kwargs) def test_path_argument_is_empty_string(self): """testing if a ValueError will be raised when the path argument is an empty string """ self.kwargs["path"] = "" self.assertRaises(ValueError, VersionType, **self.kwargs) def test_path_attribute_is_empty_string(self): """testing if a ValueError will be raised when the path attribute is set to an empty string """ self.assertRaises(ValueError, setattr, self.test_versionType, "path", "") def test_path_argument_is_not_a_string(self): """testing if a TypeError will be raised when the path argument is not a string instance """ self.kwargs["path"] = 13245 self.assertRaises(TypeError, VersionType, **self.kwargs) def test_path_attribute_is_not_a_string(self): """testing if a TypeError will be raised when the path attribute is not a string instance """ self.assertRaises(TypeError, setattr, self.test_versionType, "path", 23412) def test_path_argument_is_working_properly(self): """testing if the path attribute is initialized correctly with the same value of the path argument """ self.assertEqual(self.test_versionType.path, self.kwargs["path"]) def test_path_attribute_is_working_properly(self): """testing if the path attribute is working properly """ test_value = "test_path" self.test_versionType.path = test_value self.assertEqual(self.test_versionType.path, test_value) def test_output_path_argument_is_skipped(self): """testing if a TypeError will be raised when the output_path argument is skipped """ self.kwargs.pop("output_path") self.assertRaises(TypeError, VersionType, **self.kwargs) def test_output_path_argument_is_empty_string(self): """testing if a ValueError will be raised when the output_path argument is an empty string """ self.kwargs["output_path"] = "" self.assertRaises(ValueError, VersionType, **self.kwargs) def test_output_path_attribute_is_empty_string(self): """testing if a ValueError will be raised when the output_path attribute is set to an empty string """ self.assertRaises(ValueError, setattr, self.test_versionType, "output_path", "") def test_output_path_argument_is_not_a_string(self): """testing if a TypeError will be raised when the output_path argument is not a string instance """ self.kwargs["output_path"] = 13245 self.assertRaises(TypeError, VersionType, **self.kwargs) def test_output_path_attribute_is_not_a_string(self): """testing if a TypeError will be raised when the output_path attribute is not a string instance """ self.assertRaises(TypeError, setattr, self.test_versionType, "output_path", 23412) def test_output_path_argument_is_working_properly(self): """testing if the output_path attribute is initialized correctly with the same value of the output_path argument """ self.assertEqual(self.test_versionType.output_path, self.kwargs["output_path"]) def test_output_path_attribute_is_working_properly(self): """testing if the output_path attribute is working properly """ test_value = "test_output_path" self.test_versionType.output_path = test_value self.assertEqual(self.test_versionType.output_path, test_value) def test_extra_folders_argument_is_skipped(self): """testing if the extra_folders argument is skipped the extra_folders attribute will be an empty string """ self.kwargs.pop("extra_folders") new_version_type = VersionType(**self.kwargs) self.assertEqual(new_version_type.extra_folders, "") def test_extra_folders_argument_is_None(self): """testing if the extra_folders attribute is going to be an empty string when the extra folders argument is given as None """ self.kwargs["extra_folders"] = None new_version_type = VersionType(**self.kwargs) self.assertEqual(new_version_type.extra_folders, "") def test_extra_folders_attribute_is_None(self): """testing if the extra_folders attribute will be an empty list when it is set to None """ self.test_versionType.extra_folders = None self.assertEqual(self.test_versionType.extra_folders, "") def test_extra_folders_argument_is_not_a_string_instance(self): """testing if a TypeError will be raised when the extra_folders argument is not a string or unicode instance """ self.kwargs["extra_folders"] = 123 self.assertRaises(TypeError, VersionType, **self.kwargs) def test_extra_folders_attribute_is_not_a_string_instance(self): """testing if a TypeError will be raised when the extra_folders attribute is set to something other than a string or unicode instance """ self.assertRaises(TypeError, setattr, self.test_versionType, "extra_folders", 23423) def test_extra_folders_argument_is_working_properly(self): """testing if the extra_folders attribute will be set to the same value with the extra_folders argument while initialization """ self.assertEqual(self.test_versionType.extra_folders, self.kwargs["extra_folders"]) def test_extra_folders_attribute_is_working_properly(self): """testing if the extra_folders attribute is working properly """ test_value = "extra_folders" self.test_versionType.extra_folders = test_value self.assertEqual(self.test_versionType.extra_folders, test_value) def test_environments_argument_is_skipped(self): """testing if a TypeError will be raised when the environments argument is skipped """ self.kwargs.pop("environments") self.assertRaises(TypeError, VersionType, **self.kwargs) def test_environments_argument_is_None(self): """testing if a TypeError will be raised when the environments argument is None """ self.kwargs["environments"] = None self.assertRaises(TypeError, VersionType, **self.kwargs) def test_environments_attribute_is_None(self): """testing if a TypeError will be raised when the environments attribute is set to None """ self.assertRaises(TypeError, setattr, self.test_versionType, "environments", None) def test_environments_argument_is_not_a_list(self): """testing if a TypeError will be raised when the environments argument is not a list instance """ self.kwargs["environments"] = 12354 self.assertRaises(TypeError, VersionType, **self.kwargs) def test_environments_attribute_is_not_a_list(self): """testing if a TypeError will be raised when the environments attribute is set to something other than a list """ self.assertRaises(TypeError, setattr, self.test_versionType, "environments", 123) def test_environments_argument_is_not_a_list_of_strings(self): """testing if a TypeError will be raised when the environments argument is not a list of strings """ self.kwargs["environments"] = [123, "MAYA"] self.assertRaises(TypeError, VersionType, **self.kwargs) def test_environments_attribute_is_not_a_list_of_strings(self): """testing if a TypeError will be raised when the environments attribute is not a list of strings """ self.assertRaises(TypeError, setattr, self.test_versionType, "environments", [123, "MAYA"]) def test_environments_argument_works_properly(self): """testing if the environments attribute will be initialized correctly with the environments argument """ test_value = ["MAYA", "HOUDINI"] self.kwargs["environments"] = test_value new_vtype = VersionType(**self.kwargs) for env in test_value: self.assertTrue(env in new_vtype.environments) def test_environments_attribute_works_properly(self): """testing if the environments attribute is working properly """ test_value = ["MAYA", "HOUDINI", "NUKE", "3DEQUALIZER"] self.test_versionType.environments = test_value for env in test_value: self.assertTrue(env in self.test_versionType.environments) def test_type_for_argument_is_skipped(self): """testing if a TypeError will be raised when the type_for argument is skipped """ self.kwargs.pop("type_for") self.assertRaises(TypeError, VersionType, **self.kwargs) def test_type_for_argument_is_None(self): """testing if a TypeError will be raised when the type_for argument is None """ self.kwargs["type_for"] = None self.assertRaises(TypeError, VersionType, **self.kwargs) def test_type_for_argument_is_not_a_string_or_integer(self): """testing if a TypeError will be raised when the type_for argument is not a string or unicode or an integer """ self.kwargs["type_for"] = [12] self.assertRaises(TypeError, VersionType, **self.kwargs) def test_type_for_argument_is_working_properly(self): """testing if the type_for argument is working properly """ self.kwargs["name"] = "Test Animation" self.kwargs["code"] = "TA" self.kwargs["type_for"] = "Asset" new_vtype = VersionType(**self.kwargs) new_vtype.save() self.assertEqual(new_vtype.type_for, "Asset") def test_type_for_attribute_is_read_only(self): """testing if type_for attribute is read-only """ self.assertRaises(AttributeError, setattr, self.test_versionType, "type_for", "Asset") def test_save_method_saves_the_version_type_to_the_database(self): """testing if the save method saves the current VersionType to the database """ self.kwargs["name"] = "Test Animation" self.kwargs["code"] = "TA" new_vtype = VersionType(**self.kwargs) new_vtype.save() code = new_vtype.code environments = new_vtype.environments filename = new_vtype.filename name = new_vtype.name output_path = new_vtype.output_path path = new_vtype.path type_for = new_vtype.type_for # del new_vtype new_vtypeDB = VersionType.query().filter_by(name=self.kwargs["name"]).first() self.assertEqual(code, new_vtypeDB.code) self.assertEqual(filename, new_vtypeDB.filename) self.assertEqual(name, new_vtypeDB.name) self.assertEqual(output_path, new_vtypeDB.output_path) self.assertEqual(path, new_vtypeDB.path) self.assertEqual(type_for, new_vtypeDB.type_for) self.assertEqual(environments, new_vtypeDB.environments) def test__eq__(self): """testing the equality operator """ verst1 = VersionType( name="Test Type", code="TT", path="path", filename="filename", output_path="output_path", environments=["MAYA", "NUKE"], type_for="Asset", ) verst2 = VersionType( name="Test Type", code="TT", path="path", filename="filename", output_path="output_path", environments=["MAYA", "NUKE"], type_for="Asset", ) verst3 = VersionType( name="Test Type 2", code="TT", path="path", filename="filename", output_path="output_path", environments=["MAYA", "NUKE"], type_for="Asset", ) verst4 = VersionType( name="Test Type 3", code="TT3", path="path", filename="filename", output_path="output_path", environments=["MAYA", "NUKE"], type_for="Asset", ) self.assertTrue(verst1 == verst2) self.assertFalse(verst1 == verst3) self.assertFalse(verst3 == verst4) def test__ne__(self): """testing the equality operator """ verst1 = VersionType( name="Test Type", code="TT", path="path", filename="filename", output_path="output_path", environments=["MAYA", "NUKE"], type_for="Asset", ) verst2 = VersionType( name="Test Type", code="TT", path="path", filename="filename", output_path="output_path", environments=["MAYA", "NUKE"], type_for="Asset", ) verst3 = VersionType( name="Test Type 2", code="TT", path="path", filename="filename", output_path="output_path", environments=["MAYA", "NUKE"], type_for="Asset", ) verst4 = VersionType( name="Test Type 3", code="TT3", path="path", filename="filename", output_path="output_path", environments=["MAYA", "NUKE"], type_for="Asset", ) self.assertFalse(verst1 != verst2) self.assertTrue(verst1 != verst3) self.assertTrue(verst3 != verst4)
class SequenceTester(unittest.TestCase): """tests the Sequence class """ 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"), ] def tearDown(self): """cleanup the test """ # set the db.session to None db.session = None # delete the temp folder shutil.rmtree(self.temp_config_folder) shutil.rmtree(self.temp_projects_folder) def test_setup_is_working_fine(self): """testing if test setup is working fine """ # now create a repository and ask the server path and check if it # matches the test_settings repo = Repository() # BUG: works only under linux fix it later self.assertEqual(repo.server_path, self.temp_projects_folder) def test_project_argument_is_skipped(self): """testing if a TypeError will be raised when the project argument is skipped """ self.kwargs.pop("project") self.assertRaises(TypeError, Sequence, **self.kwargs) def test_project_argument_is_None(self): """testing if a TypeError will be raised when a None passed with the project argument """ self.kwargs["project"] = None self.assertRaises(TypeError, Sequence, **self.kwargs) 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) def test_project_argument_is_not_a_Project_instance(self): """testing if a TypeError will be raised when the project argument is not a oyProjectManager.models.project.Project instance """ self.kwargs["project"] = "Test Project" self.assertRaises(TypeError, Sequence, **self.kwargs) def test___eq___operator(self): """testing the __eq__ (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_EQ_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.assertTrue(seq1 == seq2) self.assertFalse(seq1 == seq3) self.assertFalse(seq1 == seq4) self.assertFalse(seq3 == seq4) 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) def test_code_argument_is_skipped(self): """testing if the code attribute will equal to name argument if it is skipped """ self.kwargs.pop("code") self.kwargs["name"] = "Test Sequence" expected_value = "Test_Sequence" new_seq1 = Sequence(**self.kwargs) self.assertEqual(new_seq1.code, expected_value) def test_code_argument_is_formatted_correctly(self): """testing if the code attribute is formatted correctly on Sequence instance creation """ self.kwargs["name"] = "TEST_SEQ1" for test_value in self._name_test_values: self.kwargs["code"] = test_value[0] expected_value = test_value[2] new_sequence = Sequence(**self.kwargs) self.assertEqual(new_sequence.code, expected_value) def test_code_argument_is_None(self): """testing if the code argument is given as None the code attribute will be set to the same value with the name attribute """ self.kwargs["code"] = None self.kwargs["name"] = "Test Sequence" expected_value = "Test_Sequence" new_seq1 = Sequence(**self.kwargs) self.assertEqual(new_seq1.code, expected_value) def test_code_argument_is_not_a_string_instance(self): """testing if a TypeError will be raised when the given code argument is not an instance of str or unicode """ self.kwargs["code"] = 23123 self.assertRaises(TypeError, Sequence, **self.kwargs) def test_description_attribute_is_working_properly(self): """testing if the description attribute is working properly """ test_value = "test description" self.test_sequence.description = test_value self.assertEqual(self.test_sequence.description, test_value) def test_name_argument_is_skipped(self): """testing if a TypeError will be raised when the name argument is skipped """ self.kwargs.pop("name") self.assertRaises(TypeError, Sequence, **self.kwargs) def test_name_argument_is_None(self): """testing if a TypeError will be raised when the name argument is None """ self.kwargs["name"] = None self.assertRaises(TypeError, Sequence, **self.kwargs) def test_name_attribute_is_None(self): """testing if a TypeError will be raised when the name attribute is set to None """ self.assertRaises(TypeError, setattr, self.test_sequence, "name", None) def test_name_argument_is_not_a_string_or_unicode_instance(self): """testing if a TypeError will be raised when the name argument is not an instance of string or unicode """ self.kwargs["name"] = 23423 self.assertRaises(TypeError, Sequence, **self.kwargs) def test_name_attribute_is_not_a_string_or_unicode_instance(self): """testing if a TypeError will be raised when the name attribute is not an instance of string or unicode """ self.assertRaises(TypeError, setattr, self.test_sequence, "name", 2131) def test_name_argument_is_working_properly(self): """testing if the name attribute is set properly with the given value for the name argument """ test_value = "Test Sequence With Name" self.kwargs["name"] = test_value new_seq = Sequence(**self.kwargs) self.assertEqual(new_seq.name, test_value) def test_name_attribute_is_working_properly(self): """testing if the name attribute is working properly """ test_value = "Test Sequence New Name" self.test_sequence.name = test_value self.assertEqual(self.test_sequence.name, test_value) def test_name_argument_formatting(self): """testing if the name will be formatted correctly when creating a new project. """ for test_value in self._name_test_values: self.kwargs["name"] = test_value[0] expected_name = test_value[1] new_sequence = Sequence(**self.kwargs) self.assertEqual(new_sequence.name, expected_name) def test_name_attribute_formatting(self): """testing if the name property will be formatted correctly. """ for test_value in self._name_test_values: self.test_sequence.name = test_value[0] expected_name = test_value[1] self.assertEqual(self.test_sequence.name, expected_name)
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!')
class MainDialog(QtGui.QDialog, project_properties_UI.Ui_Dialog): """Dialog to edit project properties If a :class:`~oyProjectManager.models.project.Project` instance is also passed it will edit the given project. If no Project is passed then it will create and return a new one. """ def __init__(self, parent=None, project=None): super(MainDialog, self).__init__(parent) self.setupUi(self) if db.session is None: db.setup() self.resolution_presets = conf.resolution_presets self.project = project self._setup_signals() self._setup_defaults() self.update_UI_from_project(self.project) def _setup_signals(self): """sets up signals """ # cancel button QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL("rejected()"), self.close) # ok button QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL("accepted()"), self.button_box_ok_clicked) # changing the name of the project should also update the code # if the code field is empty QtCore.QObject.connect(self.name_lineEdit, QtCore.SIGNAL("textChanged(QString)"), self.name_edited) def set_resolution_to_default(self): # set the resolution to the default preset index = self.resolution_comboBox.findText( conf.default_resolution_preset) self.resolution_comboBox.setCurrentIndex(index) def _setup_defaults(self): """sets up the default values """ self.resolution_comboBox.addItems( sorted(conf.resolution_presets.keys())) self.set_resolution_to_default() # clients clients = map(lambda x: x.name, Client.query().order_by(Client.name.asc()).all()) self.clients_comboBox.clear() self.clients_comboBox.addItems(clients) # set the fps to conf.default_fps self.fps_spinBox.setValue(conf.default_fps) # set active_checkBox to true self.active_checkBox.setChecked(True) # if a project is given don't let the user to try to change the code # attribute if self.project is not None: self.code_lineEdit.setEnabled(False) # advanced properties self.shot_number_padding_spinBox.setValue(conf.shot_number_padding) self.shot_number_prefix_lineEdit.setText(conf.shot_number_prefix) self.revision_number_padding_spinBox.setValue(conf.rev_number_padding) self.revision_number_prefix_lineEdit.setText(conf.rev_number_prefix) self.version_number_padding_spinBox.setValue(conf.ver_number_padding) self.version_number_prefix_lineEdit.setText(conf.ver_number_prefix) self.structure_textEdit.setText(conf.project_structure) def update_UI_from_project(self, project): """Updates the UI with the info from the given project instance :param project: The :class:`~oyProjectManager.models.project.Project` instance which the UI data will be read from. """ # if a project is given update the UI with the given project info if project is None: return self.name_lineEdit.setText(project.name) self.code_lineEdit.setText(project.code) if project.client: index = self.clients_comboBox.findText(project.client.name) if index != -1: self.clients_comboBox.setCurrentIndex(index) self.fps_spinBox.setValue(project.fps) self.active_checkBox.setChecked(project.active) # advanced properties self.shot_number_prefix_lineEdit.setText(project.shot_number_prefix) self.shot_number_padding_spinBox.setValue(project.shot_number_padding) self.revision_number_prefix_lineEdit.setText(project.rev_number_prefix) self.revision_number_padding_spinBox.setValue( project.rev_number_padding) self.version_number_prefix_lineEdit.setText(project.ver_number_prefix) self.version_number_padding_spinBox.setValue( project.ver_number_padding) self.structure_textEdit.setText(project.structure) # set the resolution preset_key = None for key in conf.resolution_presets.keys(): if conf.resolution_presets[key] == [ project.width, project.height, project.pixel_aspect ]: preset_key = key break if preset_key is not None: index = self.resolution_comboBox.findText(preset_key) self.resolution_comboBox.setCurrentIndex(index) else: # set it to custom self.resolution_comboBox.setCurrentIndex( self.resolution_comboBox.count() - 1) 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() def name_edited(self, new_name): """called by the ui event when the text in project name lineEdit changed, it updates the code field if the code field is empty :param new_name: the changed name """ # update only if the code field is empty import re new_code = re.sub(r'([^A-Z0-9]+)([\-\s]*)', '_', new_name.upper()) self.code_lineEdit.setText(new_code)
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)
class SequenceTester(unittest.TestCase): """tests the Sequence class """ 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"), ] def tearDown(self): """cleanup the test """ # set the db.session to None db.session = None # delete the temp folder shutil.rmtree(self.temp_config_folder) shutil.rmtree(self.temp_projects_folder) def test_setup_is_working_fine(self): """testing if test setup is working fine """ # now create a repository and ask the server path and check if it # matches the test_settings repo = Repository() # BUG: works only under linux fix it later self.assertEqual(repo.server_path, self.temp_projects_folder) def test_project_argument_is_skipped(self): """testing if a TypeError will be raised when the project argument is skipped """ self.kwargs.pop("project") self.assertRaises(TypeError, Sequence, **self.kwargs) def test_project_argument_is_None(self): """testing if a TypeError will be raised when a None passed with the project argument """ self.kwargs["project"] = None self.assertRaises(TypeError, Sequence, **self.kwargs) 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) def test_project_argument_is_not_a_Project_instance(self): """testing if a TypeError will be raised when the project argument is not a oyProjectManager.models.project.Project instance """ self.kwargs["project"] = "Test Project" self.assertRaises(TypeError, Sequence, **self.kwargs) def test___eq___operator(self): """testing the __eq__ (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_EQ_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.assertTrue(seq1 == seq2) self.assertFalse(seq1 == seq3) self.assertFalse(seq1 == seq4) self.assertFalse(seq3 == seq4) 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) def test_code_argument_is_skipped(self): """testing if the code attribute will equal to name argument if it is skipped """ self.kwargs.pop("code") self.kwargs["name"] = "Test Sequence" expected_value = "Test_Sequence" new_seq1 = Sequence(**self.kwargs) self.assertEqual(new_seq1.code, expected_value) def test_code_argument_is_formatted_correctly(self): """testing if the code attribute is formatted correctly on Sequence instance creation """ self.kwargs["name"] = "TEST_SEQ1" for test_value in self._name_test_values: self.kwargs["code"] = test_value[0] expected_value = test_value[2] new_sequence = Sequence(**self.kwargs) self.assertEqual(new_sequence.code, expected_value) def test_code_argument_is_None(self): """testing if the code argument is given as None the code attribute will be set to the same value with the name attribute """ self.kwargs["code"] = None self.kwargs["name"] = "Test Sequence" expected_value = "Test_Sequence" new_seq1 = Sequence(**self.kwargs) self.assertEqual(new_seq1.code, expected_value) def test_code_argument_is_not_a_string_instance(self): """testing if a TypeError will be raised when the given code argument is not an instance of str or unicode """ self.kwargs["code"] = 23123 self.assertRaises(TypeError, Sequence, **self.kwargs) def test_description_attribute_is_working_properly(self): """testing if the description attribute is working properly """ test_value = "test description" self.test_sequence.description = test_value self.assertEqual(self.test_sequence.description, test_value) def test_name_argument_is_skipped(self): """testing if a TypeError will be raised when the name argument is skipped """ self.kwargs.pop("name") self.assertRaises(TypeError, Sequence, **self.kwargs) def test_name_argument_is_None(self): """testing if a TypeError will be raised when the name argument is None """ self.kwargs["name"] = None self.assertRaises(TypeError, Sequence, **self.kwargs) def test_name_attribute_is_None(self): """testing if a TypeError will be raised when the name attribute is set to None """ self.assertRaises(TypeError, setattr, self.test_sequence, "name", None) def test_name_argument_is_not_a_string_or_unicode_instance(self): """testing if a TypeError will be raised when the name argument is not an instance of string or unicode """ self.kwargs["name"] = 23423 self.assertRaises(TypeError, Sequence, **self.kwargs) def test_name_attribute_is_not_a_string_or_unicode_instance(self): """testing if a TypeError will be raised when the name attribute is not an instance of string or unicode """ self.assertRaises(TypeError, setattr, self.test_sequence, "name", 2131) def test_name_argument_is_working_properly(self): """testing if the name attribute is set properly with the given value for the name argument """ test_value = "Test Sequence With Name" self.kwargs["name"] = test_value new_seq = Sequence(**self.kwargs) self.assertEqual(new_seq.name, test_value) def test_name_attribute_is_working_properly(self): """testing if the name attribute is working properly """ test_value = "Test Sequence New Name" self.test_sequence.name = test_value self.assertEqual(self.test_sequence.name, test_value) def test_name_argument_formatting(self): """testing if the name will be formatted correctly when creating a new project. """ for test_value in self._name_test_values: self.kwargs["name"] = test_value[0] expected_name = test_value[1] new_sequence = Sequence(**self.kwargs) self.assertEqual(new_sequence.name, expected_name) def test_name_attribute_formatting(self): """testing if the name property will be formatted correctly. """ for test_value in self._name_test_values: self.test_sequence.name = test_value[0] expected_name = test_value[1] self.assertEqual(self.test_sequence.name, expected_name)
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())
class VersionTypeTester(unittest.TestCase): """tests the VersionType class """ 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"), ] def tearDown(self): """cleanup the test """ # set the db.session to None db.session = None # delete the temp folder shutil.rmtree(self.temp_config_folder) shutil.rmtree(self.temp_projects_folder) def test_name_argument_is_None(self): """testing if a TypeError will be raised when the name argument is None """ self.kwargs["name"] = None self.assertRaises(TypeError, VersionType, **self.kwargs) def test_name_attribute_is_None(self): """testing if a TypeError will be raised when the name attribute is set to None """ self.assertRaises(TypeError, setattr, self.test_versionType, "name", None) def test_name_argument_is_not_a_string(self): """testing if a TypeError will be raised when the name argument is not a string or unicode instance """ self.kwargs["name"] = 123 self.assertRaises(TypeError, VersionType, **self.kwargs) def test_name_attribute_is_not_a_string(self): """testing if a TypeError will be raised when the name argument is not a string or unicode instance """ self.assertRaises(TypeError, setattr, self.test_versionType, "name", 8) def test_name_argument_is_working_properly(self): """testing if the name argument is working properly and sets the name attribute correctly """ self.assertEqual(self.kwargs["name"], self.test_versionType.name) def test_name_attribute_is_working_properly(self): """testing if the name attribute is working properly """ test_value = "New Name" self.test_versionType.name = test_value self.assertEqual(test_value, self.test_versionType.name) def test_name_attribute_is_not_unique(self): """testing if an IntegrityError error will be raised when the name argument is not unique """ # creating a new VersionType should raise the ?? error new_vtype = VersionType(**self.kwargs) self.assertRaises(IntegrityError, new_vtype.save) def test_code_argument_is_skipped(self): """testing if a TypeError will be raised when the code argument is skipped """ self.kwargs.pop("code") self.assertRaises(TypeError, VersionType, **self.kwargs) def test_code_argument_is_None(self): """testing if a TypeError will be raised when the code argument is None """ self.kwargs["code"] = None self.assertRaises(TypeError, VersionType, **self.kwargs) def test_code_attribute_is_None(self): """testing if a TypeError will be raised when the code attribute is set to None """ self.assertRaises(TypeError, setattr, self.test_versionType, "code", None) def test_code_argument_is_not_a_string(self): """testing if a TypeError will be raised when the code argument is not a string or unicode instance """ self.kwargs["code"] = 123 self.assertRaises(TypeError, VersionType, **self.kwargs) def test_code_attribute_is_not_a_string(self): """testing if a TypeError will be raised when the code argument is not a string or unicode instance """ self.assertRaises(TypeError, setattr, self.test_versionType, "code", 8) def test_code_argument_is_working_properly(self): """testing if the code argument is working properly and sets the code attribute correctly """ self.assertEqual(self.kwargs["code"], self.test_versionType.code) def test_code_attribute_is_working_properly(self): """testing if the code attribute is working properly """ test_value = "New Name" self.test_versionType.code = test_value self.assertEqual(test_value, self.test_versionType.code) def test_code_attribute_is_not_unique(self): """testing if an IntegrityError error will be raised when the code argument is not unique """ # creating a new VersionType should raise the IntegrityError self.kwargs["name"] = "A Different Name" new_vtype = VersionType(**self.kwargs) self.assertRaises(IntegrityError, new_vtype.save) def test_filename_argument_is_skipped(self): """testing if a TypeError will be raised when the filename argument is skipped """ self.kwargs.pop("filename") self.assertRaises(TypeError, VersionType, **self.kwargs) def test_filename_argument_is_empty_string(self): """testing if a ValueError will be raised when the filename argument is an empty string """ self.kwargs["filename"] = "" self.assertRaises(ValueError, VersionType, **self.kwargs) def test_filename_attribute_is_empty_string(self): """testing if a ValueError will be raised when the filename attribute is set to an empty string """ self.assertRaises(ValueError, setattr, self.test_versionType, "filename", "") def test_filename_argument_is_not_a_string(self): """testing if a TypeError will be raised when the filename argument is not a string instance """ self.kwargs["filename"] = 13245 self.assertRaises(TypeError, VersionType, **self.kwargs) def test_filename_attribute_is_not_a_string(self): """testing if a TypeError will be raised when the filename attribute is not a string instance """ self.assertRaises(TypeError, setattr, self.test_versionType, "filename", 23412) def test_filename_argument_is_working_properly(self): """testing if the filename attribute is initialized correctly with the same value of the filename argument """ self.assertEqual(self.test_versionType.filename, self.kwargs["filename"]) def test_filename_attribute_is_working_properly(self): """testing if the filename attribute is working properly """ test_value = "test_filename" self.test_versionType.filename = test_value self.assertEqual(self.test_versionType.filename, test_value) def test_path_argument_is_skipped(self): """testing if a TypeError will be raised when the path argument is skipped """ self.kwargs.pop("path") self.assertRaises(TypeError, VersionType, **self.kwargs) def test_path_argument_is_empty_string(self): """testing if a ValueError will be raised when the path argument is an empty string """ self.kwargs["path"] = "" self.assertRaises(ValueError, VersionType, **self.kwargs) def test_path_attribute_is_empty_string(self): """testing if a ValueError will be raised when the path attribute is set to an empty string """ self.assertRaises(ValueError, setattr, self.test_versionType, "path", "") def test_path_argument_is_not_a_string(self): """testing if a TypeError will be raised when the path argument is not a string instance """ self.kwargs["path"] = 13245 self.assertRaises(TypeError, VersionType, **self.kwargs) def test_path_attribute_is_not_a_string(self): """testing if a TypeError will be raised when the path attribute is not a string instance """ self.assertRaises(TypeError, setattr, self.test_versionType, "path", 23412) def test_path_argument_is_working_properly(self): """testing if the path attribute is initialized correctly with the same value of the path argument """ self.assertEqual(self.test_versionType.path, self.kwargs["path"]) def test_path_attribute_is_working_properly(self): """testing if the path attribute is working properly """ test_value = "test_path" self.test_versionType.path = test_value self.assertEqual(self.test_versionType.path, test_value) def test_output_path_argument_is_skipped(self): """testing if a TypeError will be raised when the output_path argument is skipped """ self.kwargs.pop("output_path") self.assertRaises(TypeError, VersionType, **self.kwargs) def test_output_path_argument_is_empty_string(self): """testing if a ValueError will be raised when the output_path argument is an empty string """ self.kwargs["output_path"] = "" self.assertRaises(ValueError, VersionType, **self.kwargs) def test_output_path_attribute_is_empty_string(self): """testing if a ValueError will be raised when the output_path attribute is set to an empty string """ self.assertRaises(ValueError, setattr, self.test_versionType, "output_path", "") def test_output_path_argument_is_not_a_string(self): """testing if a TypeError will be raised when the output_path argument is not a string instance """ self.kwargs["output_path"] = 13245 self.assertRaises(TypeError, VersionType, **self.kwargs) def test_output_path_attribute_is_not_a_string(self): """testing if a TypeError will be raised when the output_path attribute is not a string instance """ self.assertRaises(TypeError, setattr, self.test_versionType, "output_path", 23412) def test_output_path_argument_is_working_properly(self): """testing if the output_path attribute is initialized correctly with the same value of the output_path argument """ self.assertEqual(self.test_versionType.output_path, self.kwargs["output_path"]) def test_output_path_attribute_is_working_properly(self): """testing if the output_path attribute is working properly """ test_value = "test_output_path" self.test_versionType.output_path = test_value self.assertEqual(self.test_versionType.output_path, test_value) def test_extra_folders_argument_is_skipped(self): """testing if the extra_folders argument is skipped the extra_folders attribute will be an empty string """ self.kwargs.pop("extra_folders") new_version_type = VersionType(**self.kwargs) self.assertEqual(new_version_type.extra_folders, "") def test_extra_folders_argument_is_None(self): """testing if the extra_folders attribute is going to be an empty string when the extra folders argument is given as None """ self.kwargs["extra_folders"] = None new_version_type = VersionType(**self.kwargs) self.assertEqual(new_version_type.extra_folders, "") def test_extra_folders_attribute_is_None(self): """testing if the extra_folders attribute will be an empty list when it is set to None """ self.test_versionType.extra_folders = None self.assertEqual(self.test_versionType.extra_folders, "") def test_extra_folders_argument_is_not_a_string_instance(self): """testing if a TypeError will be raised when the extra_folders argument is not a string or unicode instance """ self.kwargs["extra_folders"] = 123 self.assertRaises(TypeError, VersionType, **self.kwargs) def test_extra_folders_attribute_is_not_a_string_instance(self): """testing if a TypeError will be raised when the extra_folders attribute is set to something other than a string or unicode instance """ self.assertRaises(TypeError, setattr, self.test_versionType, "extra_folders", 23423) def test_extra_folders_argument_is_working_properly(self): """testing if the extra_folders attribute will be set to the same value with the extra_folders argument while initialization """ self.assertEqual(self.test_versionType.extra_folders, self.kwargs["extra_folders"]) def test_extra_folders_attribute_is_working_properly(self): """testing if the extra_folders attribute is working properly """ test_value = "extra_folders" self.test_versionType.extra_folders = test_value self.assertEqual(self.test_versionType.extra_folders, test_value) def test_environments_argument_is_skipped(self): """testing if a TypeError will be raised when the environments argument is skipped """ self.kwargs.pop("environments") self.assertRaises(TypeError, VersionType, **self.kwargs) def test_environments_argument_is_None(self): """testing if a TypeError will be raised when the environments argument is None """ self.kwargs["environments"] = None self.assertRaises(TypeError, VersionType, **self.kwargs) def test_environments_attribute_is_None(self): """testing if a TypeError will be raised when the environments attribute is set to None """ self.assertRaises(TypeError, setattr, self.test_versionType, "environments", None) def test_environments_argument_is_not_a_list(self): """testing if a TypeError will be raised when the environments argument is not a list instance """ self.kwargs["environments"] = 12354 self.assertRaises(TypeError, VersionType, **self.kwargs) def test_environments_attribute_is_not_a_list(self): """testing if a TypeError will be raised when the environments attribute is set to something other than a list """ self.assertRaises(TypeError, setattr, self.test_versionType, "environments", 123) def test_environments_argument_is_not_a_list_of_strings(self): """testing if a TypeError will be raised when the environments argument is not a list of strings """ self.kwargs["environments"] = [123, "MAYA"] self.assertRaises(TypeError, VersionType, **self.kwargs) def test_environments_attribute_is_not_a_list_of_strings(self): """testing if a TypeError will be raised when the environments attribute is not a list of strings """ self.assertRaises(TypeError, setattr, self.test_versionType, "environments", [123, "MAYA"]) def test_environments_argument_works_properly(self): """testing if the environments attribute will be initialized correctly with the environments argument """ test_value = ["MAYA", "HOUDINI"] self.kwargs["environments"] = test_value new_vtype = VersionType(**self.kwargs) for env in test_value: self.assertTrue(env in new_vtype.environments) def test_environments_attribute_works_properly(self): """testing if the environments attribute is working properly """ test_value = ["MAYA", "HOUDINI", "NUKE", "3DEQUALIZER"] self.test_versionType.environments = test_value for env in test_value: self.assertTrue(env in self.test_versionType.environments) def test_type_for_argument_is_skipped(self): """testing if a TypeError will be raised when the type_for argument is skipped """ self.kwargs.pop("type_for") self.assertRaises(TypeError, VersionType, **self.kwargs) def test_type_for_argument_is_None(self): """testing if a TypeError will be raised when the type_for argument is None """ self.kwargs["type_for"] = None self.assertRaises(TypeError, VersionType, **self.kwargs) def test_type_for_argument_is_not_a_string_or_integer(self): """testing if a TypeError will be raised when the type_for argument is not a string or unicode or an integer """ self.kwargs["type_for"] = [12] self.assertRaises(TypeError, VersionType, **self.kwargs) def test_type_for_argument_is_working_properly(self): """testing if the type_for argument is working properly """ self.kwargs["name"] = "Test Animation" self.kwargs["code"] = "TA" self.kwargs["type_for"] = "Asset" new_vtype = VersionType(**self.kwargs) new_vtype.save() self.assertEqual(new_vtype.type_for, "Asset") def test_type_for_attribute_is_read_only(self): """testing if type_for attribute is read-only """ self.assertRaises(AttributeError, setattr, self.test_versionType, "type_for", "Asset") def test_save_method_saves_the_version_type_to_the_database(self): """testing if the save method saves the current VersionType to the database """ self.kwargs["name"] = "Test Animation" self.kwargs["code"] = "TA" new_vtype = VersionType(**self.kwargs) new_vtype.save() code = new_vtype.code environments = new_vtype.environments filename = new_vtype.filename name = new_vtype.name output_path = new_vtype.output_path path = new_vtype.path type_for = new_vtype.type_for # del new_vtype new_vtypeDB = VersionType.query().\ filter_by(name=self.kwargs["name"]).first() self.assertEqual(code, new_vtypeDB.code) self.assertEqual(filename, new_vtypeDB.filename) self.assertEqual(name, new_vtypeDB.name) self.assertEqual(output_path, new_vtypeDB.output_path) self.assertEqual(path, new_vtypeDB.path) self.assertEqual(type_for, new_vtypeDB.type_for) self.assertEqual(environments, new_vtypeDB.environments) def test__eq__(self): """testing the equality operator """ verst1 = VersionType(name="Test Type", code="TT", path="path", filename="filename", output_path="output_path", environments=["MAYA", "NUKE"], type_for="Asset") verst2 = VersionType(name="Test Type", code="TT", path="path", filename="filename", output_path="output_path", environments=["MAYA", "NUKE"], type_for="Asset") verst3 = VersionType(name="Test Type 2", code="TT", path="path", filename="filename", output_path="output_path", environments=["MAYA", "NUKE"], type_for="Asset") verst4 = VersionType(name="Test Type 3", code="TT3", path="path", filename="filename", output_path="output_path", environments=["MAYA", "NUKE"], type_for="Asset") self.assertTrue(verst1 == verst2) self.assertFalse(verst1 == verst3) self.assertFalse(verst3 == verst4) def test__ne__(self): """testing the equality operator """ verst1 = VersionType(name="Test Type", code="TT", path="path", filename="filename", output_path="output_path", environments=["MAYA", "NUKE"], type_for="Asset") verst2 = VersionType(name="Test Type", code="TT", path="path", filename="filename", output_path="output_path", environments=["MAYA", "NUKE"], type_for="Asset") verst3 = VersionType(name="Test Type 2", code="TT", path="path", filename="filename", output_path="output_path", environments=["MAYA", "NUKE"], type_for="Asset") verst4 = VersionType(name="Test Type 3", code="TT3", path="path", filename="filename", output_path="output_path", environments=["MAYA", "NUKE"], type_for="Asset") self.assertFalse(verst1 != verst2) self.assertTrue(verst1 != verst3) self.assertTrue(verst3 != verst4)
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!')