def setUp(self): """create test data """ super(StructureViewsUnitTestCase, self).setUp() from stalker import db, FilenameTemplate, Structure self.test_filename_template1 = FilenameTemplate( name='Asset Filename Template 1', target_entity_type='Asset', path='/some/path/template/code', filename='file_name_template_code') db.DBSession.add(self.test_filename_template1) self.test_filename_template2 = FilenameTemplate( name='Asset Filename Template 2', target_entity_type='Asset', path='/some/path/template/code', filename='file_name_template_code') db.DBSession.add(self.test_filename_template2) self.test_filename_template3 = FilenameTemplate( name='Asset Filename Template 3', target_entity_type='Asset', path='/some/path/template/code', filename='file_name_template_code') db.DBSession.add(self.test_filename_template3) self.test_structure1 = Structure( name='Test Structure 1', created_by=self.admin, templates=[ self.test_filename_template1, self.test_filename_template2 ], custom_template='custom template code here', ) db.DBSession.add(self.test_structure1) self.test_structure2 = Structure( name='Test Structure 2', created_by=self.admin, templates=[ self.test_filename_template1, self.test_filename_template2 ], custom_template='custom template code here', ) db.DBSession.add(self.test_structure2) self.test_structure3 = Structure( name='Test Structure 3', created_by=self.admin, templates=[ self.test_filename_template1, self.test_filename_template2 ], custom_template='custom template code here', ) db.DBSession.add(self.test_structure3) db.DBSession.commit()
def test_equality_operator(self): """testing equality of two Structure objects """ new_structure2 = Structure(**self.kwargs) self.kwargs["custom_template"] = "a test custom template" new_structure3 = Structure(**self.kwargs) self.kwargs["custom_template"] = self.test_structure.custom_template self.kwargs["templates"] = self.test_templates2 new_structure4 = Structure(**self.kwargs) assert self.test_structure == new_structure2 assert not self.test_structure == new_structure3 assert not self.test_structure == new_structure4
def test_inequality_operator(self): """testing inequality of two Structure objects """ new_structure2 = Structure(**self.kwargs) self.kwargs["custom_template"] = "a test custom template" new_structure3 = Structure(**self.kwargs) self.kwargs["custom_template"] = self.test_structure.custom_template self.kwargs["templates"] = self.test_templates2 new_structure4 = Structure(**self.kwargs) self.assertFalse(self.test_structure != new_structure2) self.assertTrue(self.test_structure != new_structure3) self.assertTrue(self.test_structure != new_structure4)
def test_templates_argument_can_be_None(self): """testing if no error will be raised when the templates argument is None """ self.kwargs["templates"] = None new_structure = Structure(**self.kwargs) self.assertTrue(isinstance(new_structure, Structure))
def test_custom_template_argument_is_None(self): """testing if no error will be raised when the custom_template argument is None. """ self.kwargs["custom_template"] = None new_structure = Structure(**self.kwargs) self.assertEqual(new_structure.custom_template, "")
def test_custom_template_argument_is_empty_string(self): """testing if no error will be raised when the custom_template argument is an empty string """ self.kwargs["custom_template"] = "" new_structure = Structure(**self.kwargs) self.assertEqual(new_structure.custom_template, "")
def test_templates_argument_can_be_skipped(self): """testing if no error will be raised when the templates argument is skipped """ self.kwargs.pop("templates") new_structure = Structure(**self.kwargs) self.assertTrue(isinstance(new_structure, Structure))
def test_templates_argument_is_working_properly(self): """testing if the templates argument value is correctly passed to the templates attribute """ # test the correct value self.kwargs["templates"] = self.test_templates new_structure = Structure(**self.kwargs) self.assertEqual(new_structure.templates, self.test_templates)
def setUp(self): """set up the test """ db.setup() db.init() self.temp_path = tempfile.mkdtemp() self.repo = Repository( name='Test Repository', linux_path=self.temp_path, windows_path=self.temp_path, osx_path=self.temp_path ) self.status_new = Status.query.filter_by(code='NEW').first() self.status_wip = Status.query.filter_by(code='WIP').first() self.status_cmpl = Status.query.filter_by(code='CMPL').first() self.project_status_list = \ StatusList.query.filter_by(target_entity_type='Project').first() self.task_filename_template = FilenameTemplate( name='Task Filename Template', target_entity_type='Task', path='{{project.code}}/{%- for parent_task in parent_tasks -%}' '{{parent_task.nice_name}}/{%- endfor -%}', filename='{{version.nice_name}}' '_v{{"%03d"|format(version.version_number)}}{{extension}}' ) self.project_structure = Structure( name='Project Structure', templates=[self.task_filename_template] ) self.project = Project( name='Test Project', code='TP', status_list=self.project_status_list, repository=self.repo, structure=self.project_structure ) self.task = Task( name='Test Task', project=self.project ) from stalker.db.session import DBSession DBSession.add(self.task) DBSession.commit() self.version = Version( task=self.task ) self.kwargs = { 'name': 'Photoshop', 'extensions': ['psd'], 'structure': ['Outputs'] } self.external_env = ExternalEnv(**self.kwargs)
def setUp(self): """setting up the tests """ super(StructureTester, self).setUp() from stalker import db, Type vers_type = Type(name="Version", code='vers', target_entity_type="FilenameTemplate") db.DBSession.add(vers_type) ref_type = Type(name="Reference", code='ref', target_entity_type="FilenameTemplate") db.DBSession.add(ref_type) db.DBSession.commit() # type templates from stalker import FilenameTemplate self.asset_template = FilenameTemplate(name="Test Asset Template", target_entity_type="Asset", type=vers_type) self.shot_template = FilenameTemplate(name="Test Shot Template", target_entity_type="Shot", type=vers_type) self.reference_template = FilenameTemplate( name="Test Reference Template", target_entity_type="Link", type=ref_type) self.test_templates = [ self.asset_template, self.shot_template, self.reference_template ] self.test_templates2 = [self.asset_template] self.custom_template = "a custom template" self.test_type = Type( name="Commercial Structure", code='comm', target_entity_type='Structure', ) # keyword arguments self.kwargs = { "name": "Test Structure", "description": "This is a test structure", "templates": self.test_templates, "custom_template": self.custom_template, "type": self.test_type, } self.test_structure = Structure(**self.kwargs) db.DBSession.add(self.test_structure) db.DBSession.commit()
def accept(self): """overridden accept method """ if not self.name_lineEdit.is_valid: QtWidgets.QMessageBox.critical(self, 'Error', 'Please fix <b>name</b> field!') return name = self.name_lineEdit.text() custom_template = self.custom_template_plainTextEdit.toPlainText() filename_template_items = \ self.filename_templates_double_list_widget.secondary_items() filename_template_ids = [] for item in filename_template_items: filename_template_id = \ int(item.text().split('(')[-1].split(')')[0]) filename_template_ids.append(filename_template_id) from stalker import FilenameTemplate filename_templates = FilenameTemplate.query\ .filter(FilenameTemplate.id.in_(filename_template_ids)).all() from stalker import Structure from stalker.db.session import DBSession logged_in_user = self.get_logged_in_user() if self.mode == 'Create': # Create a new Structure try: structure = Structure(name=name, templates=filename_templates, custom_template=custom_template, created_by=logged_in_user) self.structure = structure DBSession.add(structure) DBSession.commit() except Exception as e: DBSession.rollback() QtWidgets.QMessageBox.critical(self, 'Error', str(e)) return elif self.mode == 'Update': # Update the structure try: self.structure.name = name self.structure.templates = filename_templates self.structure.custom_template = custom_template self.structure.updated_by = logged_in_user DBSession.add(self.structure) DBSession.commit() except Exception as e: DBSession.rollback() QtWidgets.QMessageBox.critical(self, 'Error', str(e)) return super(MainDialog, self).accept()
def test_templates_argument_only_accepts_list(self): """testing if a TypeError will be raised when the given templates argument is not a list """ self.kwargs["templates"] = 1 with self.assertRaises(TypeError) as cm: Structure(**self.kwargs) self.assertEqual(str(cm.exception), 'Incompatible collection type: int is not list-like')
def test_custom_template_argument_is_not_a_string(self): """testing if a TypeError will be raised when the custom_template argument is not a string """ self.kwargs['custom_template'] = ["this is not a string"] with pytest.raises(TypeError) as cm: Structure(**self.kwargs) assert str(cm.value) == \ 'Structure.custom_template should be a string not list'
def test_custom_template_argument_is_not_a_string(self): """testing if a TypeError will be raised when the custom_template argument is not a string """ self.kwargs['custom_template'] = ["this is not a string"] with self.assertRaises(TypeError) as cm: Structure(**self.kwargs) self.assertEqual( str(cm.exception), 'Structure.custom_template should be a string not list')
def test_templates_argument_accepts_only_list_of_FilenameTemplate_instances(self): """testing if a TypeError will be raised when the templates argument is a list but the elements are not all instances of FilenameTemplate class. """ test_value = [1, 1.2, "a string"] self.kwargs["templates"] = test_value with pytest.raises(TypeError) as cm: Structure(**self.kwargs) assert str(cm.value) == \ 'All the elements in the Structure.templates should be a ' \ 'stalker.models.template.FilenameTemplate instance not int'
def test_templates_argument_accepts_only_list_of_FilenameTemplate_instances( self): """testing if a TypeError will be raised when the templates argument is a list but the elements are not all instances of FilenameTemplate class. """ test_value = [1, 1.2, "a string"] self.kwargs["templates"] = test_value self.assertRaises(TypeError, Structure, **self.kwargs) # test the correct value self.kwargs["templates"] = self.test_templates new_structure = Structure(**self.kwargs) self.assertTrue(isinstance(new_structure, Structure))
def setUp(self): """setting up the tests """ vers_type = Type(name="Version", code='vers', target_entity_type="FilenameTemplate") ref_type = Type(name="Reference", code='ref', target_entity_type="FilenameTemplate") # type templates self.asset_template = FilenameTemplate(name="Test Asset Template", target_entity_type="Asset", type=vers_type) self.shot_template = FilenameTemplate(name="Test Shot Template", target_entity_type="Shot", type=vers_type) self.reference_template = FilenameTemplate( name="Test Reference Template", target_entity_type="Link", type=ref_type) self.test_templates = [ self.asset_template, self.shot_template, self.reference_template ] self.test_templates2 = [self.asset_template] self.custom_template = "a custom template" self.test_type = Type( name="Commercial Structure", code='comm', target_entity_type=Structure, ) # keyword arguments self.kwargs = { "name": "Test Structure", "description": "This is a test structure", "templates": self.test_templates, "custom_template": self.custom_template, "type": self.test_type, } self.test_structure = Structure(**self.kwargs)
def test_generic_data_attribute_can_hold_a_wide_variety_of_object_types( self): """testing if the generic_data attribute can hold any kind of object as a list """ new_simple_entity = SimpleEntity(**self.kwargs) from stalker import User test_user = User( name='email', login='******', email='*****@*****.**', password='******', ) from stalker import Department test_department = Department(name='department1') from stalker import Repository test_repo = Repository( name='Test Repository', code='TR', ) from stalker import Structure test_struct = Structure(name='Test Project Structure') from stalker import Project test_proj = Project( name='Test Project 1', code='tp1', repository=test_repo, structure=test_struct, ) new_simple_entity.generic_data.extend( [test_proj, test_struct, test_repo, test_department, test_user]) # now check if it is added to the database correctly del new_simple_entity new_simple_entity_db = SimpleEntity.query \ .filter_by(name=self.kwargs['name']) \ .first() assert test_proj in new_simple_entity_db.generic_data assert test_struct in new_simple_entity_db.generic_data assert test_repo in new_simple_entity_db.generic_data assert test_department in new_simple_entity_db.generic_data assert test_user in new_simple_entity_db.generic_data
def setUp(self): """set up the test """ db.setup() db.init() self.user1 = User( name='Test User 1', login='******', email='*****@*****.**', password='******' ) DBSession.add(self.user1) self.user2 = User( name='Test User 2', login='******', email='*****@*****.**', password='******' ) DBSession.add(self.user2) self.user3 = User( name='Test User 2', login='******', email='*****@*****.**', password='******' ) DBSession.add(self.user3) # Review Statuses self.status_new = Status.query.filter_by(code='NEW').first() self.status_rrev = Status.query.filter_by(code='RREV').first() self.status_app = Status.query.filter_by(code='APP').first() # Task Statuses self.status_wfd = Status.query.filter_by(code='WFD').first() self.status_rts = Status.query.filter_by(code='RTS').first() self.status_wip = Status.query.filter_by(code='WIP').first() self.status_prev = Status.query.filter_by(code='PREV').first() self.status_hrev = Status.query.filter_by(code='HREV').first() self.status_drev = Status.query.filter_by(code='DREV').first() self.status_cmpl = Status.query.filter_by(code='CMPL').first() self.project_status_list = StatusList( target_entity_type='Project', statuses=[ self.status_new, self.status_wip, self.status_cmpl ] ) DBSession.add(self.project_status_list) self.temp_path = tempfile.mkdtemp() self.repo = Repository( name='Test Repository', linux_path=self.temp_path, windows_path=self.temp_path, osx_path=self.temp_path ) DBSession.add(self.repo) self.structure = Structure( name='Test Project Structure' ) DBSession.add(self.structure) self.project = Project( name='Test Project', code='TP', status_list=self.project_status_list, repository=self.repo ) DBSession.add(self.project) self.task1 = Task( name='Test Task 1', project=self.project, resources=[self.user1], responsible=[self.user2] ) DBSession.add(self.task1) self.task2 = Task( name='Test Task 2', project=self.project, responsible=[self.user1] ) DBSession.add(self.task2) self.task3 = Task( name='Test Task 3', parent=self.task2, resources=[self.user1] ) DBSession.add(self.task3) self.task4 = Task( name='Test Task 4', project=self.project, resources=[self.user1], depends=[self.task3], responsible=[self.user2], schedule_timing=2, schedule_unit='h' ) DBSession.add(self.task4) self.task5 = Task( name='Test Task 5', project=self.project, resources=[self.user2], depends=[self.task3], responsible=[self.user2], schedule_timing=2, schedule_unit='h' ) DBSession.add(self.task5) self.task6 = Task( name='Test Task 6', project=self.project, resources=[self.user3], depends=[self.task3], responsible=[self.user2], schedule_timing=2, schedule_unit='h' ) DBSession.add(self.task6) self.kwargs = { 'task': self.task1, 'reviewer': self.user1 } #self.review = Review(**self.kwargs) #DBSession.add(self.review) # add everything to the db DBSession.commit()
windows_path='T:/stalker_tests/') # create a Structure for our flat project flat_task_template = FilenameTemplate( name='Flat Task Template', target_entity_type='Task', path='{{project.code}}', # everything will be under the same folder filename='{{task.nice_name}}_{{version.take_name}}' '_v{{"%03d"|format(version.version_number)}}{{extension}}' # you can customize this as you wish, you can even use a uuid4 # as the file name ) flat_struct = Structure( name='Flat Project Structure', templates=[flat_task_template] # we need another template for Assets, # Shots and Sequences but I'm skipping it # for now ) # query a couple of statuses status_new = Status.query.filter_by(code='NEW').first() status_wip = Status.query.filter_by(code='WIP').first() status_cmpl = Status.query.filter_by(code='CMPL').first() proj_statuses = StatusList(name='Project Statuses', target_entity_type='Project', statuses=[status_new, status_wip, status_cmpl]) p1 = Project(name='Flat Project Example', code='FPE', status_list=proj_statuses,
def create_empty_project(): """creates empty project test data """ from stalker.db.session import DBSession from stalker import (Task, Asset, Type, Sequence, Shot, Version, FilenameTemplate, Repository, Project, Structure) repo = Repository(name='Test Repository', code='TR', windows_path='T:/', linux_path='/mnt/T/', osx_path='/Volumes/T/') task_filename_template = FilenameTemplate( name='Task Filename Template', path='$REPO{{project.repository.code}}/{{project.code}}/' '{%- for parent_task in parent_tasks -%}{{parent_task.nice_name}}' '/{%- endfor -%}', filename= '{{version.nice_name}}_v{{"%03d"|format(version.version_number)}}', target_entity_type='Task') asset_filename_template = FilenameTemplate( name='Asset Filename Template', path='$REPO{{project.repository.code}}/{{project.code}}/' '{%- for parent_task in parent_tasks -%}{{parent_task.nice_name}}' '/{%- endfor -%}', filename= '{{version.nice_name}}_v{{"%03d"|format(version.version_number)}}', target_entity_type='Asset') shot_filename_template = FilenameTemplate( name='Shot Filename Template', path='$REPO{{project.repository.code}}/{{project.code}}/' '{%- for parent_task in parent_tasks -%}{{parent_task.nice_name}}' '/{%- endfor -%}', filename= '{{version.nice_name}}_v{{"%03d"|format(version.version_number)}}', target_entity_type='Shot') sequence_filename_template = FilenameTemplate( name='Sequence Filename Template', path='$REPO{{project.repository.code}}/{{project.code}}/' '{%- for parent_task in parent_tasks -%}{{parent_task.nice_name}}' '/{%- endfor -%}', filename= '{{version.nice_name}}_v{{"%03d"|format(version.version_number)}}', target_entity_type='Sequence') structure = Structure(name='Default Project Structure', templates=[ task_filename_template, asset_filename_template, shot_filename_template, sequence_filename_template ]) DBSession.add_all([ structure, task_filename_template, asset_filename_template, shot_filename_template, sequence_filename_template ]) DBSession.commit() project = Project( name='Test Project', code='TP', repository=repo, structure=structure, ) DBSession.add(project) DBSession.commit() yield project
def create_project(): """creates test data """ from stalker.db.session import DBSession from stalker import (Task, Asset, Type, Sequence, Shot, Version, FilenameTemplate, Repository, Project, Structure) repo = Repository(name='Test Repository', code='TR', windows_path='T:/', linux_path='/mnt/T/', osx_path='/Volumes/T/') task_filename_template = FilenameTemplate( name='Task Filename Template', path='$REPO{{project.repository.code}}/{{project.code}}/' '{%- for parent_task in parent_tasks -%}{{parent_task.nice_name}}' '/{%- endfor -%}', filename= '{{version.nice_name}}_v{{"%03d"|format(version.version_number)}}', target_entity_type='Task') asset_filename_template = FilenameTemplate( name='Asset Filename Template', path='$REPO{{project.repository.code}}/{{project.code}}/' '{%- for parent_task in parent_tasks -%}{{parent_task.nice_name}}' '/{%- endfor -%}', filename= '{{version.nice_name}}_v{{"%03d"|format(version.version_number)}}', target_entity_type='Asset') shot_filename_template = FilenameTemplate( name='Shot Filename Template', path='$REPO{{project.repository.code}}/{{project.code}}/' '{%- for parent_task in parent_tasks -%}{{parent_task.nice_name}}' '/{%- endfor -%}', filename= '{{version.nice_name}}_v{{"%03d"|format(version.version_number)}}', target_entity_type='Shot') sequence_filename_template = FilenameTemplate( name='Sequence Filename Template', path='$REPO{{project.repository.code}}/{{project.code}}/' '{%- for parent_task in parent_tasks -%}{{parent_task.nice_name}}' '/{%- endfor -%}', filename= '{{version.nice_name}}_v{{"%03d"|format(version.version_number)}}', target_entity_type='Sequence') structure = Structure(name='Default Project Structure', templates=[ task_filename_template, asset_filename_template, shot_filename_template, sequence_filename_template ]) DBSession.add_all([ structure, task_filename_template, asset_filename_template, shot_filename_template, sequence_filename_template ]) DBSession.commit() project = Project( name='Test Project', code='TP', repository=repo, structure=structure, ) DBSession.add(project) DBSession.commit() assets_task = Task(name='Assets', project=project) characters_task = Task(name='Characters', parent=assets_task) props_task = Task(name='Props', parent=assets_task) environments_task = Task(name='Environments', parent=assets_task) sequences_task = Task(name='Sequences', project=project) # Asset Types char_type = Type(name='Character', code='Char', target_entity_type='Asset') prop_type = Type(name='Prop', code='Prop', target_entity_type='Asset') exterior_type = Type(name='Exterior', code='Exterior', target_entity_type='Asset') interior_type = Type(name='Interior', code='Interior', target_entity_type='Asset') # Task Types model_type = Type(name='Model', code='Model', target_entity_type='Task') look_dev_type = Type(name='Look Development', code='LookDev', target_entity_type='Task') rig_type = Type(name='Rig', code='Rig', target_entity_type='Task') layout_type = Type(name='Layout', code='Layout', target_entity_type='Task') anim_type = \ Type(name='Animation', code='Animation', target_entity_type='Task') camera_type = Type(name='Camera', code='Camera', target_entity_type='Task') plate_type = Type(name='Plate', code='Plate', target_entity_type='Task') fx_type = Type(name='FX', code='FX', target_entity_type='Task') lighting_type = \ Type(name='Lighting', code='Lighting', target_entity_type='Task') comp_type = Type(name='Comp', code='Comp', target_entity_type='Task') DBSession.add_all([ char_type, prop_type, exterior_type, interior_type, model_type, look_dev_type, rig_type, layout_type, anim_type, camera_type, plate_type, fx_type, lighting_type, comp_type ]) DBSession.commit() # char1 char1 = Asset(name='Char1', code='Char1', parent=characters_task, type=char_type) model = Task(name='Model', type=model_type, parent=char1) look_dev_task = Task(name='LookDev', type=look_dev_type, parent=char1) rig = Task(name='Rig', type=rig_type, parent=char1) DBSession.add_all([char1, model, look_dev_task, rig]) DBSession.commit() # char2 char2 = Asset(name='Char2', code='Char2', parent=characters_task, type=char_type) model = Task(name='Model', type=model_type, parent=char2) look_dev_task = Task(name='LookDev', type=look_dev_type, parent=char2) rig = Task(name='Rig', type=rig_type, parent=char2) DBSession.add_all([char2, model, look_dev_task, rig]) DBSession.commit() # prop1 prop1 = \ Asset(name='Prop2', code='Prop2', parent=props_task, type=prop_type) model = Task(name='Model', type=model_type, parent=prop1) look_dev_task = Task(name='LookDev', type=look_dev_type, parent=prop1) DBSession.add_all([prop1, model, look_dev_task]) DBSession.commit() # prop2 prop2 = \ Asset(name='Prop2', code='Prop2', parent=props_task, type=prop_type) model = Task(name='Model', type=model_type, parent=prop2) look_dev_task = Task(name='LookDev', type=look_dev_type, parent=prop2) DBSession.add_all([prop2, model, look_dev_task]) DBSession.commit() # environments # env1 env1 = Asset(name='Env1', code='Env1', type=exterior_type, parent=environments_task) layout_task = Task(name='Layout', type=layout_type, parent=env1) props_task = Task(name='Props', parent=env1) yapi1_asset = \ Asset(name='Yapi1', code='Yapi1', type=prop_type, parent=props_task) model_task = Task(name='Model', type=model_type, parent=yapi1_asset) look_dev_task = \ Task(name='LookDev', type=look_dev_type, parent=yapi1_asset) DBSession.add_all([ env1, layout_task, props_task, yapi1_asset, model_task, look_dev_task ]) DBSession.commit() # env2 env2 = Asset(name='Env2', code='Env2', type=exterior_type, parent=environments_task) layout_task = Task(name='Layout', type=layout_type, parent=env2) props_task = Task(name='Props', parent=env2) yapi1_asset = \ Asset(name='Yapi2', code='Yapi2', type=prop_type, parent=props_task) model_task = Task(name='Model', type=model_type, parent=yapi1_asset) look_dev_task = \ Task(name='LookDev', type=look_dev_type, parent=yapi1_asset) DBSession.add_all([ env2, layout_task, props_task, yapi1_asset, model_task, look_dev_task ]) DBSession.commit() # sequences and shots seq1 = Sequence(name='Seq1', code='Seq1', parent=sequences_task) edit_task = Task(name='Edit', parent=seq1) shots_task = Task(name='Shots', parent=seq1) DBSession.add_all([seq1, edit_task, shots_task]) DBSession.commit() # shot1 shot1 = Shot(name='Seq001_001_0010', code='Seq001_001_0010', sequences=[seq1], parent=shots_task) anim_task = Task(name='Anim', type=anim_type, parent=shot1) camera_task = Task(name='Camera', type=camera_type, parent=shot1) plate_task = Task(name='Plate', type=plate_type, parent=shot1) fx_task = Task(name='FX', type=fx_type, parent=shot1) lighting_task = Task(name='Lighting', type=lighting_type, parent=shot1) comp_task = Task(name='Comp', type=comp_type, parent=shot1) DBSession.add_all([ shot1, anim_task, camera_task, plate_task, fx_task, lighting_task, comp_task ]) DBSession.commit() # shot2 shot2 = Shot(name='Seq001_001_0020', code='Seq001_001_0020', sequences=[seq1], parent=shots_task) anim_task = Task(name='Anim', type=anim_type, parent=shot2) camera_task = Task(name='Camera', type=camera_type, parent=shot2) plate_task = Task(name='Plate', type=plate_type, parent=shot2) fx_task = Task(name='FX', type=fx_type, parent=shot2) lighting_task = Task(name='Lighting', type=lighting_type, parent=shot2) comp_task = Task(name='Comp', type=comp_type, parent=shot2) DBSession.add_all([ shot2, anim_task, camera_task, plate_task, fx_task, lighting_task, comp_task ]) DBSession.commit() # shot3 shot3 = Shot(name='Seq001_001_0030', code='Seq001_001_0030', sequences=[seq1], parent=shots_task) anim_task = Task(name='Anim', type=anim_type, parent=shot3) camera_task = Task(name='Camera', type=camera_type, parent=shot3) plate_task = Task(name='Plate', type=plate_type, parent=shot3) fx_task = Task(name='FX', type=fx_type, parent=shot3) lighting_task = Task(name='Lighting', type=lighting_type, parent=shot3) comp_task = Task(name='Comp', type=comp_type, parent=shot3) DBSession.add_all([ shot3, anim_task, camera_task, plate_task, fx_task, lighting_task, comp_task ]) DBSession.commit() # Seq2 # sequences and shots seq2 = Sequence(name='Seq2', code='Seq2', parent=sequences_task) edit_task = Task(name='Edit', parent=seq2) shots_task = Task(name='Shots', parent=seq2) DBSession.add_all([seq2, edit_task, shots_task]) DBSession.commit() # shot1 shot1 = Shot(name='Seq002_001_0010', code='Seq002_001_0010', sequences=[seq2], parent=shots_task) anim_task = Task(name='Anim', type=anim_type, parent=shot1) camera_task = Task(name='Camera', type=camera_type, parent=shot1) plate_task = Task(name='Plate', type=plate_type, parent=shot1) fx_task = Task(name='FX', type=fx_type, parent=shot1) lighting_task = Task(name='Lighting', type=lighting_type, parent=shot1) comp_task = Task(name='Comp', type=comp_type, parent=shot1) DBSession.add_all([ shot1, anim_task, camera_task, plate_task, fx_task, lighting_task, comp_task ]) DBSession.commit() # shot2 shot2 = Shot(name='Seq002_001_0020', code='Seq002_001_0020', sequences=[seq2], parent=shots_task) anim_task = Task(name='Anim', type=anim_type, parent=shot2) camera_task = Task(name='Camera', type=camera_type, parent=shot2) plate_task = Task(name='Plate', type=plate_type, parent=shot2) fx_task = Task(name='FX', type=fx_type, parent=shot2) lighting_task = Task(name='Lighting', type=lighting_type, parent=shot2) comp_task = Task(name='Comp', type=comp_type, parent=shot2) DBSession.add_all([ shot2, anim_task, camera_task, plate_task, fx_task, lighting_task, comp_task ]) DBSession.commit() # shot3 shot3 = Shot(name='Seq002_001_0030', code='Seq002_001_0030', sequences=[seq2], parent=shots_task) anim_task = Task(name='Anim', type=anim_type, parent=shot3) camera_task = Task(name='Camera', type=camera_type, parent=shot3) plate_task = Task(name='Plate', type=plate_type, parent=shot3) fx_task = Task(name='FX', type=fx_type, parent=shot3) lighting_task = Task(name='Lighting', type=lighting_type, parent=shot3) comp_task = Task(name='Comp', type=comp_type, parent=shot3) DBSession.add_all([ shot3, anim_task, camera_task, plate_task, fx_task, lighting_task, comp_task ]) DBSession.commit() yield project
def setUp(self): """set up the test """ super(TaskDependencyTestCase, self).setUp() # get statuses from stalker import Status self.status_new = Status.query.filter_by(code="NEW").first() self.status_wfd = Status.query.filter_by(code="WFD").first() self.status_rts = Status.query.filter_by(code="RTS").first() self.status_wip = Status.query.filter_by(code="WIP").first() self.status_prev = Status.query.filter_by(code="PREV").first() self.status_hrev = Status.query.filter_by(code="HREV").first() self.status_drev = Status.query.filter_by(code="DREV").first() self.status_oh = Status.query.filter_by(code="OH").first() self.status_stop = Status.query.filter_by(code="STOP").first() self.status_cmpl = Status.query.filter_by(code="CMPL").first() from stalker import User self.test_user1 = User(name='Test User 1', login='******', email='*****@*****.**', password='******') self.test_user2 = User(name='Test User 2', login='******', email='*****@*****.**', password='******') self.test_user3 = User(name='Test User 1', login='******', email='*****@*****.**', password='******') from stalker import Repository self.test_repo = Repository(name='Test Repository') from stalker import Structure self.test_structure = Structure(name='test structure') # project status list from stalker import StatusList self.test_project_status_list = StatusList( name='Project Statuses', target_entity_type='Project', statuses=[ self.status_new, self.status_wip, self.status_oh, self.status_stop, self.status_cmpl ]) from stalker import Project self.test_project1 = Project(name='Test Project 1', code='TP1', repository=self.test_repo, structure=self.test_structure, status_list=self.test_project_status_list) # create three Tasks from stalker import Task self.test_task1 = Task(name='Test Task 1', project=self.test_project1) self.test_task2 = Task(name='Test Task 2', project=self.test_project1) self.test_task3 = Task(name='Test Task 3', project=self.test_project1) # add everything to db from stalker import db db.DBSession.add_all([ self.test_project1, self.test_project_status_list, self.test_repo, self.test_structure, self.test_task1, self.test_task2, self.test_task3, self.test_user1, self.test_user2 ]) db.DBSession.commit() self.kwargs = { 'task': self.test_task1, 'depends_to': self.test_task2, 'dependency_target': 'onend', 'gap_timing': 0, 'gap_unit': 'h', 'gap_model': 'length' }
def setUp(self): """set up the test """ super(ReviewTestDBCase, self).setUp() from stalker import User self.user1 = User( name='Test User 1', login='******', email='*****@*****.**', password='******' ) from stalker.db.session import DBSession DBSession.add(self.user1) self.user2 = User( name='Test User 2', login='******', email='*****@*****.**', password='******' ) DBSession.add(self.user2) self.user3 = User( name='Test User 2', login='******', email='*****@*****.**', password='******' ) DBSession.add(self.user3) # Review Statuses from stalker import Status with DBSession.no_autoflush: self.status_new = Status.query.filter_by(code='NEW').first() self.status_rrev = Status.query.filter_by(code='RREV').first() self.status_app = Status.query.filter_by(code='APP').first() # Task Statuses self.status_wfd = Status.query.filter_by(code='WFD').first() self.status_rts = Status.query.filter_by(code='RTS').first() self.status_wip = Status.query.filter_by(code='WIP').first() self.status_prev = Status.query.filter_by(code='PREV').first() self.status_hrev = Status.query.filter_by(code='HREV').first() self.status_drev = Status.query.filter_by(code='DREV').first() self.status_cmpl = Status.query.filter_by(code='CMPL').first() from stalker import Repository self.repo = Repository( name='Test Repository', linux_path='/mnt/T/', windows_path='T:/', osx_path='/Volumes/T/' ) DBSession.add(self.repo) from stalker import Structure self.structure = Structure( name='Test Project Structure' ) DBSession.add(self.structure) from stalker import Project self.project = Project( name='Test Project', code='TP', repository=self.repo ) DBSession.add(self.project) from stalker import Task self.task1 = Task( name='Test Task 1', project=self.project, resources=[self.user1], responsible=[self.user2] ) DBSession.add(self.task1) self.task2 = Task( name='Test Task 2', project=self.project, responsible=[self.user1] ) DBSession.add(self.task2) self.task3 = Task( name='Test Task 3', parent=self.task2, resources=[self.user1] ) DBSession.add(self.task3) self.task4 = Task( name='Test Task 4', project=self.project, resources=[self.user1], depends=[self.task3], responsible=[self.user2], schedule_timing=2, schedule_unit='h' ) DBSession.add(self.task4) self.task5 = Task( name='Test Task 5', project=self.project, resources=[self.user2], depends=[self.task3], responsible=[self.user2], schedule_timing=2, schedule_unit='h' ) DBSession.add(self.task5) self.task6 = Task( name='Test Task 6', project=self.project, resources=[self.user3], depends=[self.task3], responsible=[self.user2], schedule_timing=2, schedule_unit='h' ) DBSession.add(self.task6) self.kwargs = { 'task': self.task1, 'reviewer': self.user1 } # add everything to the db DBSession.commit()
def test_custom_template_argument_can_be_skipped(self): """testing if the custom_template argument can be skipped """ self.kwargs.pop("custom_template") new_structure = Structure(**self.kwargs) self.assertEqual(new_structure.custom_template, "")
def setUpClass(cls): """setup test """ # ----------------------------------------------------------------- # start of the setUp # create the environment variable and point it to a temp directory from stalker import db database_url = "sqlite:///:memory:" db.setup({'sqlalchemy.url': database_url}) db.init() cls.temp_repo_path = tempfile.mkdtemp() from stalker import User cls.user1 = User(name='User 1', login='******', email='*****@*****.**', password='******') from stalker import Repository cls.repo1 = Repository(name='Test Project Repository', linux_path=cls.temp_repo_path, windows_path=cls.temp_repo_path, osx_path=cls.temp_repo_path) from stalker import Status cls.status_new = Status.query.filter_by(code='NEW').first() cls.status_wip = Status.query.filter_by(code='WIP').first() cls.status_comp = Status.query.filter_by(code='CMPL').first() from stalker import FilenameTemplate cls.task_template = FilenameTemplate( name='Task Template', target_entity_type='Task', path='{{project.code}}/' '{%- for parent_task in parent_tasks -%}' '{{parent_task.nice_name}}/' '{%- endfor -%}', filename='{{version.nice_name}}' '_v{{"%03d"|format(version.version_number)}}', ) from stalker import Structure cls.structure = Structure(name='Project Struture', templates=[cls.task_template]) from stalker import StatusList cls.project_status_list = \ StatusList.query.filter_by(target_entity_type='Project').first() from stalker import ImageFormat cls.image_format = ImageFormat(name='HD 1080', width=1920, height=1080, pixel_aspect=1.0) # create a test project from stalker import Project cls.project = Project(name='Test Project', code='TP', repository=cls.repo1, status_list=cls.project_status_list, structure=cls.structure, image_format=cls.image_format) cls.task_status_list =\ StatusList.query.filter_by(target_entity_type='Task').first() from stalker import Type cls.character_type = Type(name='Character', code='CHAR', target_entity_type='Asset') from stalker import Task # create a test series of root task cls.task1 = Task(name='Test Task 1', project=cls.project) cls.task2 = Task(name='Test Task 2', project=cls.project) # commit everything from stalker.db.session import DBSession DBSession.add_all([ cls.repo1, cls.status_new, cls.status_wip, cls.status_comp, cls.project_status_list, cls.project, cls.task_status_list, cls.task1, cls.task2, cls.task_template ]) DBSession.commit() cls.version1 = cls.create_version(cls.task1, 'Main') cls.version2 = cls.create_version(cls.task1, 'Main') cls.version3 = cls.create_version(cls.task1, 'Main') # create other reprs # BBOX cls.version4 = cls.create_version(cls.task1, 'Main@BBox') cls.version5 = cls.create_version(cls.task1, 'Main@BBox') cls.version5.is_published = True DBSession.commit() # ASS cls.version6 = cls.create_version(cls.task1, 'Main@ASS') cls.version7 = cls.create_version(cls.task1, 'Main@ASS') cls.version7.is_published = True DBSession.commit() # GPU cls.version8 = cls.create_version(cls.task1, 'Main@GPU') cls.version9 = cls.create_version(cls.task1, 'Main@GPU') # Non default take name cls.version10 = cls.create_version(cls.task1, 'alt1') cls.version11 = cls.create_version(cls.task1, 'alt1') # Hires cls.version12 = cls.create_version(cls.task1, 'alt1@Hires') cls.version13 = cls.create_version(cls.task1, 'alt1@Hires') # Midres cls.version14 = cls.create_version(cls.task1, 'alt1@Midres') cls.version15 = cls.create_version(cls.task1, 'alt1@Midres') # Lores cls.version16 = cls.create_version(cls.task1, 'alt1@Lores') cls.version17 = cls.create_version(cls.task1, 'alt1@Lores') cls.version17.is_published = True # No Repr cls.version18 = cls.create_version(cls.task1, 'NoRepr') cls.version19 = cls.create_version(cls.task1, 'NoRepr') DBSession.commit() # create a buffer for extra created files, which are to be removed cls.remove_these_files_buffer = []
def setUpClass(cls): """setup once """ # remove the transaction manager db.DBSession.remove() cls.repo_path = tempfile.mkdtemp() defaults.local_storage_path = tempfile.mktemp() db.setup({ 'sqlalchemy.url': 'sqlite:///:memory:', 'sqlalchemy.echo': 'false' }) db.init() # create Power Users Group cls.power_users_group = Group(name='Power Users') db.DBSession.add(cls.power_users_group) db.DBSession.commit() # create a LocalSession first cls.admin = User.query.all()[0] cls.lsession = LocalSession() cls.lsession.store_user(cls.admin) cls.lsession.save() # create a repository cls.test_repo1 = Repository(name='Test Repository', windows_path='T:/TestRepo/', linux_path='/mnt/T/TestRepo/', osx_path='/Volumes/T/TestRepo/') cls.test_structure1 = Structure(name='Test Project Structure', templates=[], custom_template='') cls.status_new = Status.query.filter_by(code='NEW').first() cls.status_wip = Status.query.filter_by(code='WIP').first() cls.status_cmpl = Status.query.filter_by(code='CMPL').first() cls.project_status_list = StatusList( name='Project Statuses', statuses=[cls.status_new, cls.status_wip, cls.status_cmpl], target_entity_type=Project) # create a couple of projects cls.test_project1 = Project(name='Project 1', code='P1', repository=cls.test_repo1, structure=cls.test_structure1, status_list=cls.project_status_list) cls.test_project2 = Project(name='Project 2', code='P2', repository=cls.test_repo1, structure=cls.test_structure1, status_list=cls.project_status_list) cls.test_project3 = Project(name='Project 3', code='P3', repository=cls.test_repo1, structure=cls.test_structure1, status_list=cls.project_status_list) cls.projects = [ cls.test_project1, cls.test_project2, cls.test_project3 ] cls.test_user1 = User( name='Test User', # groups=[self.power_users_group], login='******', email='*****@*****.**', password='******') db.DBSession.add(cls.test_user1) db.DBSession.commit() cls.admin.projects.append(cls.test_project1) cls.admin.projects.append(cls.test_project2) cls.admin.projects.append(cls.test_project3) cls.test_user1.projects.append(cls.test_project1) cls.test_user1.projects.append(cls.test_project2) cls.test_user1.projects.append(cls.test_project3) # project 1 cls.test_task1 = Task( name='Test Task 1', project=cls.test_project1, resources=[cls.admin], ) cls.test_task2 = Task( name='Test Task 2', project=cls.test_project1, resources=[cls.admin], ) cls.test_task3 = Task( name='Test Task 2', project=cls.test_project1, resources=[cls.admin], ) # project 2 cls.test_task4 = Task( name='Test Task 4', project=cls.test_project2, resources=[cls.admin], ) cls.test_task5 = Task( name='Test Task 5', project=cls.test_project2, resources=[cls.admin], ) cls.test_task6 = Task( name='Test Task 6', parent=cls.test_task5, resources=[cls.admin], ) cls.test_task7 = Task( name='Test Task 7', parent=cls.test_task5, resources=[], ) cls.test_task8 = Task( name='Test Task 8', parent=cls.test_task5, resources=[], ) cls.test_task9 = Task( name='Test Task 9', parent=cls.test_task5, resources=[], ) # +-> Project 1 # | | # | +-> Task1 # | | # | +-> Task2 # | | # | +-> Task3 # | # +-> Project 2 # | | # | +-> Task4 # | | # | +-> Task5 # | | # | +-> Task6 # | | # | +-> Task7 (no resource) # | | # | +-> Task8 (no resource) # | | # | +-> Task9 (no resource) # | # +-> Project 3 # record them all to the db db.DBSession.add_all([ cls.admin, cls.test_project1, cls.test_project2, cls.test_project3, cls.test_task1, cls.test_task2, cls.test_task3, cls.test_task4, cls.test_task5, cls.test_task6, cls.test_task7, cls.test_task8, cls.test_task9 ]) db.DBSession.commit() cls.all_tasks = [ cls.test_task1, cls.test_task2, cls.test_task3, cls.test_task4, cls.test_task5, cls.test_task6, cls.test_task7, cls.test_task8, cls.test_task9 ] # create versions cls.test_version1 = Version(cls.test_task1, created_by=cls.admin, created_with='Test', description='Test Description') db.DBSession.add(cls.test_version1) db.DBSession.commit() cls.test_version2 = Version(cls.test_task1, created_by=cls.admin, created_with='Test', description='Test Description') db.DBSession.add(cls.test_version2) db.DBSession.commit() cls.test_version3 = Version(cls.test_task1, created_by=cls.admin, created_with='Test', description='Test Description') cls.test_version3.is_published = True db.DBSession.add(cls.test_version3) db.DBSession.commit() cls.test_version4 = Version(cls.test_task1, take_name='Main@GPU', created_by=cls.admin, created_with='Test', description='Test Description') cls.test_version4.is_published = True db.DBSession.add(cls.test_version4) db.DBSession.commit() if not QtGui.QApplication.instance(): logger.debug('creating a new QApplication') cls.app = QtGui.QApplication(sys.argv) else: logger.debug('using the present QApplication: %s' % QtGui.qApp) # self.app = QtGui.qApp cls.app = QtGui.QApplication.instance() # cls.test_environment = TestEnvironment() cls.dialog = version_creator.MainDialog()
def test_readme_tutorial_code(setup_sqlite3): """Tests the tutorial code in README.rst """ from stalker import db db.setup() db.init() from stalker.db.session import DBSession assert str(DBSession.connection().engine.url) == 'sqlite://' from stalker import User me = User(name='Erkan Ozgur Yilmaz', login='******', email='*****@*****.**', password='******') # Save the user to database DBSession.save(me) from stalker import Repository repo = Repository(name='Commercial Projects Repository', code='CPR', windows_path='Z:/Projects', linux_path='/mnt/Z/Projects', osx_path='/Volumes/Z/Projects') from stalker import FilenameTemplate task_template = FilenameTemplate( name='Standard Task Filename Template', target_entity_type='Task', # This is for files saved for Tasks path='{{project.repository.path}}/{{project.code}}/' '{%- for parent_task in parent_tasks -%}' '{{parent_task.nice_name}}/' '{%- endfor -%}', # This is Jinja2 template code filename= '{{version.nice_name}}_v{{"%03d"|format(version.version_number)}}') from stalker import Structure standard_folder_structure = Structure( name='Standard Project Folder Structure', templates=[task_template], custom_template= '{{project.code}}/References' # If you need extra folders ) from stalker import Project new_project = Project( name='Test Project', code='TP', structure=standard_folder_structure, repositories=[repo ], # if you have more than one repository you can do it ) from stalker import ImageFormat hd1080 = ImageFormat(name='1080p', width=1920, height=1080) new_project.image_format = hd1080 # Save the project and all the other data it is connected to it DBSession.save(new_project) from stalker import Task, Asset, Shot, Type # define Character asset type char_type = Type(name='Character', code='CHAR', target_entity_type='Asset') character1 = Asset(name='Character 1', code='CHAR1', type=char_type, project=new_project) # Save the Asset DBSession.save(character1) model = Task(name='Model', parent=character1) rigging = Task( name='Rig', parent=character1, depends=[model ], # For project management, define that Rig can not start # before Model ends. ) # Save the new tasks DBSession.save([model, rigging]) # A shot and some tasks for it shot = Shot(name='SH001', code='SH001', project=new_project) # Save the Shot DBSession.save(shot) animation = Task( name='Animation', parent=shot, ) lighting = Task( name='Lighting', parent=shot, depends=[animation], # Lighting can not start before Animation ends, schedule_timing=1, schedule_unit='d', # The task expected to take 1 day to complete resources=[me]) DBSession.save([animation, lighting]) from stalker import Version new_version = Version(task=animation) new_version.update_paths() # to render the naming convention template new_version.extension = '.ma' # let's say that we have created under Maya assert new_version.absolute_full_path == \ "%sTP/SH001/Animation/SH001_Animation_Main_v001.ma" % \ repo.path assert new_version.version_number == 1 new_version2 = Version(task=animation) new_version2.update_paths() # to render the naming convention template new_version2.extension = '.ma' # let's say that we have created under Maya assert new_version2.version_number == 2
def setUp(self): """setup the tests """ # ----------------------------------------------------------------- # start of the setUp # create the environment variable and point it to a temp directory db.setup() db.init() self.temp_repo_path = tempfile.mkdtemp() self.user1 = User(name='User 1', login='******', email='*****@*****.**', password='******') db.DBSession.add(self.user1) db.DBSession.commit() # login as self.user1 from stalker import LocalSession local_session = LocalSession() local_session.store_user(self.user1) local_session.save() self.repo1 = Repository(name='Test Project Repository', linux_path=self.temp_repo_path, windows_path=self.temp_repo_path, osx_path=self.temp_repo_path) self.status_new = Status.query.filter_by(code='NEW').first() self.status_wip = Status.query.filter_by(code='WIP').first() self.status_comp = Status.query.filter_by(code='CMPL').first() self.task_template = FilenameTemplate( name='Task Template', target_entity_type='Task', path='{{project.code}}/' '{%- for parent_task in parent_tasks -%}' '{{parent_task.nice_name}}/' '{%- endfor -%}', filename='{{version.nice_name}}' '_v{{"%03d"|format(version.version_number)}}', ) self.asset_template = FilenameTemplate( name='Asset Template', target_entity_type='Asset', path='{{project.code}}/' '{%- for parent_task in parent_tasks -%}' '{{parent_task.nice_name}}/' '{%- endfor -%}', filename='{{version.nice_name}}' '_v{{"%03d"|format(version.version_number)}}', ) self.shot_template = FilenameTemplate( name='Shot Template', target_entity_type='Shot', path='{{project.code}}/' '{%- for parent_task in parent_tasks -%}' '{{parent_task.nice_name}}/' '{%- endfor -%}', filename='{{version.nice_name}}' '_v{{"%03d"|format(version.version_number)}}', ) self.sequence_template = FilenameTemplate( name='Sequence Template', target_entity_type='Sequence', path='{{project.code}}/' '{%- for parent_task in parent_tasks -%}' '{{parent_task.nice_name}}/' '{%- endfor -%}', filename='{{version.nice_name}}' '_v{{"%03d"|format(version.version_number)}}', ) self.structure = Structure(name='Project Struture', templates=[ self.task_template, self.asset_template, self.shot_template, self.sequence_template ]) self.project_status_list = StatusList( name='Project Statuses', target_entity_type='Project', statuses=[self.status_new, self.status_wip, self.status_comp]) self.image_format = ImageFormat(name='HD 1080', width=1920, height=1080, pixel_aspect=1.0) # create a test project self.project = Project(name='Test Project', code='TP', repository=self.repo1, status_list=self.project_status_list, structure=self.structure, image_format=self.image_format) self.task_status_list =\ StatusList.query.filter_by(target_entity_type='Task').first() self.asset_status_list =\ StatusList.query.filter_by(target_entity_type='Asset').first() self.shot_status_list =\ StatusList.query.filter_by(target_entity_type='Shot').first() self.sequence_status_list =\ StatusList.query.filter_by(target_entity_type='Sequence').first() self.character_type = Type(name='Character', code='CHAR', target_entity_type='Asset') # create a test series of root task self.task1 = Task(name='Test Task 1', project=self.project) self.task2 = Task(name='Test Task 2', project=self.project) self.task3 = Task(name='Test Task 3', project=self.project) # then a couple of child tasks self.task4 = Task(name='Test Task 4', parent=self.task1) self.task5 = Task(name='Test Task 5', parent=self.task1) self.task6 = Task(name='Test Task 6', parent=self.task1) # create a root asset self.asset1 = Asset(name='Asset 1', code='asset1', type=self.character_type, project=self.project) # create a child asset self.asset2 = Asset(name='Asset 2', code='asset2', type=self.character_type, parent=self.task4) # create a root Sequence self.sequence1 = Sequence(name='Sequence1', code='SEQ1', project=self.project) # create a child Sequence self.sequence2 = Sequence(name='Sequence2', code='SEQ2', parent=self.task2) # create a root Shot self.shot1 = Shot(name='SH001', code='SH001', project=self.project) # create a child Shot (child of a Sequence) self.shot2 = Shot(name='SH002', code='SH002', parent=self.sequence1) # create a child Shot (child of a child Sequence) self.shot3 = Shot(name='SH003', code='SH003', parent=self.sequence2) # commit everything db.DBSession.add_all([ self.repo1, self.status_new, self.status_wip, self.status_comp, self.project_status_list, self.project, self.task_status_list, self.asset_status_list, self.shot_status_list, self.sequence_status_list, self.task1, self.task2, self.task3, self.task4, self.task5, self.task6, self.asset1, self.asset2, self.shot1, self.shot2, self.shot3, self.sequence1, self.sequence2, self.task_template, self.asset_template, self.shot_template, self.sequence_template ]) db.DBSession.commit() # now create versions def create_version(task, take_name): """Creates a new version :param task: the task :param take_name: the take_name name :return: the version """ # just renew the scene #pymel.core.newFile(force=True) v = Version(task=task, take_name=take_name) v.update_paths() db.DBSession.add(v) db.DBSession.commit() #self.maya_env.save_as(v) return v # asset2 self.version1 = create_version(self.asset2, 'Main') self.version2 = create_version(self.asset2, 'Main') self.version3 = create_version(self.asset2, 'Main') self.version3.description = 'Test Description' self.version4 = create_version(self.asset2, 'Take1') self.version5 = create_version(self.asset2, 'Take1') self.version6 = create_version(self.asset2, 'Take1') # task5 self.version7 = create_version(self.task5, 'Main') self.version8 = create_version(self.task5, 'Main') self.version9 = create_version(self.task5, 'Main') self.version10 = create_version(self.task5, 'Take1') self.version11 = create_version(self.task5, 'Take1') self.version12 = create_version(self.task5, 'Take1') # task6 self.version13 = create_version(self.task6, 'Main') self.version14 = create_version(self.task6, 'Main') self.version15 = create_version(self.task6, 'Main') self.version16 = create_version(self.task6, 'Take1') self.version17 = create_version(self.task6, 'Take1') self.version18 = create_version(self.task6, 'Take1') # shot3 self.version19 = create_version(self.shot3, 'Main') self.version20 = create_version(self.shot3, 'Main') self.version21 = create_version(self.shot3, 'Main') self.version22 = create_version(self.shot3, 'Take1') self.version23 = create_version(self.shot3, 'Take1') self.version24 = create_version(self.shot3, 'Take1') # task3 self.version25 = create_version(self.task3, 'Main') self.version26 = create_version(self.task3, 'Main') self.version27 = create_version(self.task3, 'Main') self.version28 = create_version(self.task3, 'Take1') self.version29 = create_version(self.task3, 'Take1') self.version30 = create_version(self.task3, 'Take1') # asset1 self.version31 = create_version(self.asset1, 'Main') self.version32 = create_version(self.asset1, 'Main') self.version33 = create_version(self.asset1, 'Main') self.version34 = create_version(self.asset1, 'Take1') self.version35 = create_version(self.asset1, 'Take1') self.version36 = create_version(self.asset1, 'Take1') # shot2 self.version37 = create_version(self.shot2, 'Main') self.version38 = create_version(self.shot2, 'Main') self.version39 = create_version(self.shot2, 'Main') self.version40 = create_version(self.shot2, 'Take1') self.version41 = create_version(self.shot2, 'Take1') self.version42 = create_version(self.shot2, 'Take1') # shot1 self.version43 = create_version(self.shot1, 'Main') self.version44 = create_version(self.shot1, 'Main') self.version45 = create_version(self.shot1, 'Main') self.version46 = create_version(self.shot1, 'Take1') self.version47 = create_version(self.shot1, 'Take1') self.version48 = create_version(self.shot1, 'Take1') # +- task1 # | | # | +- task4 # | | | # | | +- asset2 # | | +- Main # | | | +- version1 # | | | +- version2 (P) # | | | +- version3 (P) # | | +- Take1 # | | +- version4 (P) # | | +- version5 # | | +- version6 (P) # | | # | +- task5 # | | +- Main # | | | +- version7 # | | | +- version8 # | | | +- version9 # | | +- Take1 # | | +- version10 # | | +- version11 # | | +- version12 (P) # | | # | +- task6 # | +- Main # | | +- version13 # | | +- version14 # | | +- version15 # | +- Take1 # | +- version16 (P) # | +- version17 # | +- version18 (P) # | # +- task2 # | | # | +- sequence2 # | | # | +- shot3 # | +- Main # | | +- version19 # | | +- version20 # | | +- version21 # | +- Take1 # | +- version22 # | +- version23 # | +- version24 # | # +- task3 # | +- Main # | | +- version25 # | | +- version26 # | | +- version27 # | +- Take1 # | +- version28 # | +- version29 # | +- version30 # | # +- asset1 # | +- Main # | | +- version31 # | | +- version32 # | | +- version33 # | +- Take1 # | +- version34 # | +- version35 # | +- version36 # | # +- sequence1 # | | # | +- shot2 # | +- Main # | | +- version37 # | | +- version38 # | | +- version39 # | +- Take1 # | +- version40 # | +- version41 # | +- version42 # | # +- shot1 # +- Main # | +- version43 # | +- version44 # | +- version45 # +- Take1 # +- version46 # +- version47 # +- version48 # Start Condition: # # version15 # version12 # version5 # version2 -> has new published version (version3) # version5 -> Referenced a second time # version2 -> has new published version (version3) # version12 -> Referenced a second time # version5 # version2 -> has new published version (version3) # version5 # version2 -> has new published version (version3) # version45 -> no change # version48 -> no change # # Expected Final Result # version15A -> Derived from version15 # version12A -> Derived from version12 # version5A -> Derived from version5 # version3 -> has new published version (version3) # version5A -> Derived from version5 # version3 -> has new published version (version3) # version12A -> Derived from version12 - The second reference # version5A -> Derived from version5 # version3 -> has new published version (version3) # version5A -> Derived from version5 # version3 -> has new published version (version3) # version45 -> no change # version48 -> no change # create a deep relation self.version2.is_published = True self.version3.is_published = True # new scene # version5 references version2 self.version5.inputs.append(self.version2) self.version5.is_published = True # version12 references version5 self.version12.inputs.append(self.version5) self.version12.is_published = True # version45 references version48 self.version45.is_published = True self.version48.is_published = True self.version45.inputs.append(self.version48) # version15 references version12 and version48 self.version15.inputs.append(self.version12) self.version15.inputs.append(self.version45) # reference_resolution self.reference_resolution = { 'root': [self.version12, self.version45], 'leave': [self.version48, self.version45], 'update': [self.version2], 'create': [self.version5, self.version12] } # create a buffer for extra created files, which are to be removed self.remove_these_files_buffer = [] self.test_environment = TestEnvironment(name='Test Environment') self.test_environment._version = self.version15 if not QtGui.QApplication.instance(): logger.debug('creating a new QApplication') self.app = QtGui.QApplication(sys.argv) else: logger.debug('using the present QApplication: %s' % QtGui.qApp) # self.app = QtGui.qApp self.app = QtGui.QApplication.instance() self.dialog = version_updater.MainDialog( environment=self.test_environment, reference_resolution=self.reference_resolution)
def test_generic_data_attribute_can_hold_a_wide_variety_of_object_types(self): """testing if the generic_data attribute can hold any kind of object as a list """ from stalker import db db.setup() new_simple_entity = SimpleEntity(**self.kwargs) test_user = User( name='email', login='******', email='*****@*****.**', password='******', ) from stalker import Department test_department = Department( name='department1' ) from stalker import Repository test_repo = Repository( name='Test Repository' ) from stalker import Structure test_struct = Structure( name='Test Project Structure' ) from stalker import Status, StatusList test_project_status_list = StatusList( name='Project Status List', target_entity_type='Project', statuses=[ Status(name='Active', code='ACT') ] ) from stalker import Project test_proj = Project( name='Test Project 1', code='tp1', repository=test_repo, structure=test_struct, status_list=test_project_status_list ) new_simple_entity.generic_data.extend( [test_proj, test_project_status_list, test_struct, test_repo, test_department, test_user] ) DBSession.add(new_simple_entity) DBSession.commit() # now check if it is added to the database correctly del new_simple_entity new_simple_entity_db = SimpleEntity.query \ .filter_by(name=self.kwargs['name']) \ .first() self.assertTrue(test_proj in new_simple_entity_db.generic_data) self.assertTrue( test_project_status_list in new_simple_entity_db.generic_data) self.assertTrue(test_struct in new_simple_entity_db.generic_data) self.assertTrue(test_repo in new_simple_entity_db.generic_data) self.assertTrue(test_department in new_simple_entity_db.generic_data) self.assertTrue(test_user in new_simple_entity_db.generic_data) DBSession.remove()
print(commercial_repo.path) # under Windows outputs: # M:/commercials # # in Linux and variants: # /mnt/M/commercials # # and in OSX: # /Volumes/M/commercials from stalker import Structure commercial_project_structure = Structure( name="Commercial Projects Structure" ) # now assign this structure to our project new_project.structure = commercial_project_structure from stalker import FilenameTemplate task_template = FilenameTemplate( name='Task Template for Commercials', target_entity_type='Task', path='$REPO{{project.repository.id}}/{{project.code}}/{%- for p in parent_tasks -%}{{p.nice_name}}/{%- endfor -%}', filename='{{version.nice_name}}_v{{"%03d"|format(version.version_number)}}' ) # and append it to our project structure