def test_update_with_studio_is_working_properly(self): """testing if the default values are updated with the Studio instance if there is a database connection and there is a Studio in there """ import datetime from stalker import db, defaults from stalker.db.session import DBSession from stalker.models.studio import Studio db.setup() db.init() # check the defaults are still using them self self.assertEqual( defaults.timing_resolution, datetime.timedelta(hours=1) ) studio = Studio( name='Test Studio', timing_resolution=datetime.timedelta(minutes=15) ) DBSession.add(studio) DBSession.commit() # now check it again self.assertEqual( defaults.timing_resolution, studio.timing_resolution )
def setUp(self): """set up the test """ import transaction from pyramid import paster, testing from webtest import TestApp from stalker import db from stalker.db.session import DBSession testing.setUp() import os import stalker_pyramid app = paster.get_app( os.path.join( os.path.dirname( stalker_pyramid.__path__[0], ), 'testing.ini' ).replace('\\', '/') ) self.test_app = TestApp(app) # patch DBSession commit, to let the db.init() work # with its calls to DBSession.commit() _orig_commit = DBSession.commit DBSession.commit = transaction.commit db.setup(app.registry.settings) db.init() # restore DBSession.commit DBSession.commit = _orig_commit from stalker import User self.admin = User.query.filter(User.name == 'admin').first()
def create_db(): """creates a test database """ import os os.environ.pop('STALKER_PATH') from stalker import db db.setup({'sqlalchemy.url': 'sqlite://'}) db.init()
def create_db(): """creates a test database """ from stalker import db print("setting up test database") db.setup({'sqlalchemy.url': 'sqlite://'}) print("initializing test database") db.init()
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 setUpClass(cls): """setup once """ db.setup() db.init() 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.test_project_status_list = StatusList( name='Project Statuses', target_entity_type='Project', statuses=[cls.status_new, cls.status_wip, cls.status_cmpl]) cls.test_repo = Repository(name='Test Repository') cls.test_project = Project(name='Test Project', code='TP', repository=cls.test_repo, status_list=cls.test_project_status_list) cls.test_task1 = Task(name='Test Task 1', project=cls.test_project) cls.test_task2 = Task(name='Test Task 2', project=cls.test_project) cls.test_task3 = Task(name='Test Task 3', project=cls.test_project) cls.test_version1 = Version(task=cls.test_task1) db.DBSession.add(cls.test_version1) db.DBSession.commit() cls.test_version2 = Version(task=cls.test_task1) db.DBSession.add(cls.test_version2) db.DBSession.commit() cls.test_version3 = Version(task=cls.test_task1) db.DBSession.add(cls.test_version3) db.DBSession.commit() cls.test_version4 = Version(task=cls.test_task2) db.DBSession.add(cls.test_version4) db.DBSession.commit() cls.test_link1 = Link(original_filename='test_render1.jpg') cls.test_link2 = Link(original_filename='test_render2.jpg') cls.test_link3 = Link(original_filename='test_render3.jpg') cls.test_link4 = Link(original_filename='test_render4.jpg') cls.test_version1.outputs = [ cls.test_link1, cls.test_link2, cls.test_link3 ] cls.test_version4.outputs = [cls.test_link4] db.DBSession.add_all([ cls.test_task1, cls.test_task2, cls.test_task3, cls.test_version1, cls.test_version2, cls.test_version3, cls.test_version4, cls.test_link1, cls.test_link2, cls.test_link3, cls.test_link4 ]) db.DBSession.commit()
def setUp(self): """setup test """ import datetime from stalker import defaults defaults.timing_resolution = datetime.timedelta(hours=1) # init database from stalker import db db.setup(self.config) db.init()
def main(argv=sys.argv): if len(argv) != 2: usage(argv) config_uri = argv[1] setup_logging(config_uri) settings = get_appsettings(config_uri) db.setup(settings) db.init() # create statuses create_statuses_and_status_lists() create_ticket_types()
def setUpClass(cls): """setup once """ # create a test database db.setup() db.init() # create test repositories cls.repo1 = Repository( name='Test Repo 1', linux_path='/test/repo/1/linux/path', windows_path='T:/test/repo/1/windows/path', osx_path='/test/repo/1/osx/path', ) cls.repo2 = Repository( name='Test Repo 2', linux_path='/test/repo/2/linux/path', windows_path='T:/test/repo/2/windows/path', osx_path='/test/repo/2/osx/path', ) cls.repo3 = Repository( name='Test Repo 3', linux_path='/test/repo/3/linux/path', windows_path='T:/test/repo/3/windows/path', osx_path='/test/repo/3/osx/path', ) cls.repo4 = Repository( name='Test Repo 4', linux_path='/test/repo/4/linux/path', windows_path='T:/test/repo/4/windows/path', osx_path='/test/repo/4/osx/path', ) cls.repo5 = Repository( name='Test Repo 5', linux_path='/test/repo/5/linux/path', windows_path='T:/test/repo/5/windows/path', osx_path='/test/repo/5/osx/path', ) cls.all_repos = [cls.repo1, cls.repo2, cls.repo3, cls.repo4, cls.repo5] db.DBSession.add_all(cls.all_repos) db.DBSession.commit()
def main(argv=sys.argv): if len(argv) != 2: usage(argv) from pyramid.paster import get_appsettings, setup_logging from stalker import db config_uri = argv[1] setup_logging(config_uri) settings = get_appsettings(config_uri) db.setup(settings) db.init() # create statuses create_statuses_and_status_lists() create_ticket_types()
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( target_entity_type="Project", name="Project Statuses", statuses=[self.status_new, self.status_wip, self.status_cmpl], ) 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) self.version = Version(task=self.task) self.kwargs = {"name": "Photoshop", "extensions": ["psd"], "structure": ["Outputs"]} self.external_env = ExternalEnv(**self.kwargs)
def setUp(self): """setup test """ import os from stalker.config import Config try: os.environ.pop(Config.env_key) except KeyError: # already removed pass # regenerate the defaults import stalker stalker.defaults = Config() import datetime stalker.defaults.timing_resolution = datetime.timedelta(hours=1) # init database from stalker import db # remove anything beforehand db.setup(self.config) db.init()
def setUp(self): """sets up the test """ db.setup() db.init() self.test_repo_path = tempfile.mkdtemp() # create test data self.test_repo = Repository( name='Test Repository', linux_path=self.test_repo_path, windows_path=self.test_repo_path, osx_path=self.test_repo_path ) self.test_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.test_structure = Structure( name='Test Project Structure', templates=[self.test_task_template] ) 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.test_project_status_list = StatusList( name='Project Statuses', statuses=[self.status_new, self.status_wip, self.status_cmpl], target_entity_type='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 ) db.DBSession.add(self.test_project1) db.DBSession.commit() # now create tasks # root tasks self.test_task1 = Task( name='Task1', project=self.test_project1 ) self.test_task2 = Task( name='Task2', project=self.test_project1 ) self.test_task3 = Task( name='Task3', project=self.test_project1 ) # child of Task1 self.test_task4 = Task( name='Task4', parent=self.test_task1 ) self.test_task5 = Task( name='Task5', parent=self.test_task1 ) self.test_task6 = Task( name='Task6', parent=self.test_task1 ) # child of Task2 self.test_task7 = Task( name='Task7', parent=self.test_task2 ) self.test_task8 = Task( name='Task8', parent=self.test_task2 ) self.test_task9 = Task( name='Task9', parent=self.test_task2 ) # child of Task10 self.test_task10 = Task( name='Task10', parent=self.test_task3 ) self.test_task11 = Task( name='Task11', parent=self.test_task3 ) self.test_task12 = Task( name='Task12', parent=self.test_task3 ) db.DBSession.add_all([ self.test_task1, self.test_task2, self.test_task3, self.test_task4, self.test_task5, self.test_task6, self.test_task7, self.test_task8, self.test_task9, self.test_task10, self.test_task11, self.test_task12 ]) # now create versions for each of leaf tasks # Task4 # Main self.test_version1 = self.create_version(self.test_task4, take_name='Main') self.test_version2 = self.create_version(self.test_task4, take_name='Main') self.test_version3 = self.create_version(self.test_task4, take_name='Main') # Take1 self.test_version4 = self.create_version(self.test_task4, take_name='Take1') self.test_version5 = self.create_version(self.test_task4, take_name='Take1') self.test_version6 = self.create_version(self.test_task4, take_name='Take1') # Take2 self.test_version7 = self.create_version(self.test_task4, take_name='Take2') self.test_version8 = self.create_version(self.test_task4, take_name='Take2') self.test_version9 = self.create_version(self.test_task4, take_name='Take2') # Task5 # Main self.test_version10 = self.create_version(self.test_task5, take_name='Main') self.test_version11 = self.create_version(self.test_task5, take_name='Main') self.test_version12 = self.create_version(self.test_task5, take_name='Main') # Take1 self.test_version13 = self.create_version(self.test_task5, take_name='Take1') self.test_version14 = self.create_version(self.test_task5, take_name='Take1') self.test_version15 = self.create_version(self.test_task5, take_name='Take1') # Take2 self.test_version16 = self.create_version(self.test_task5, take_name='Take2') self.test_version17 = self.create_version(self.test_task5, take_name='Take2') self.test_version18 = self.create_version(self.test_task5, take_name='Take2') # Task6 # Main self.test_version19 = self.create_version(self.test_task6, take_name='Main') self.test_version20 = self.create_version(self.test_task6, take_name='Main') self.test_version21 = self.create_version(self.test_task6, take_name='Main') # Take1 self.test_version22 = self.create_version(self.test_task6, take_name='Take1') self.test_version23 = self.create_version(self.test_task6, take_name='Take1') self.test_version24 = self.create_version(self.test_task6, take_name='Take1') # Take2 self.test_version25 = self.create_version(self.test_task6, take_name='Take2') self.test_version26 = self.create_version(self.test_task6, take_name='Take2') self.test_version27 = self.create_version(self.test_task6, take_name='Take2') # Task7 # Main self.test_version28 = self.create_version(self.test_task7, take_name='Main') self.test_version29 = self.create_version(self.test_task7, take_name='Main') self.test_version30 = self.create_version(self.test_task7, take_name='Main') # Take1 self.test_version31 = self.create_version(self.test_task7, take_name='Take1') self.test_version32 = self.create_version(self.test_task7, take_name='Take1') self.test_version33 = self.create_version(self.test_task7, take_name='Take1') # Take2 self.test_version34 = self.create_version(self.test_task7, take_name='Take2') self.test_version35 = self.create_version(self.test_task7, take_name='Take2') self.test_version36 = self.create_version(self.test_task7, take_name='Take2') # Task8 - will have no versions # Task9 - it is a destination task with versions # Main self.test_version37 = self.create_version(self.test_task9, take_name='Main') self.test_version38 = self.create_version(self.test_task9, take_name='Main') self.test_version39 = self.create_version(self.test_task9, take_name='Main') # Take1 - an existing take self.test_version40 = self.create_version(self.test_task9, take_name='Take1') self.test_version41 = self.create_version(self.test_task9, take_name='Take1') self.test_version42 = self.create_version(self.test_task9, take_name='Take1') # Take3 - a non existing take self.test_version43 = self.create_version(self.test_task9, take_name='Take1') self.test_version44 = self.create_version(self.test_task9, take_name='Take1') self.test_version45 = self.create_version(self.test_task9, take_name='Take1') if not QtGui.QApplication.instance(): self.app = QtGui.QApplication(sys.argv) else: # self.app = QtGui.qApp self.app = QtGui.QApplication.instance() self.dialog = VersionMover()
def setUp(self): """set up the test """ # we need a database db.setup(self.config) db.init() # replace datetime now function # create departments self.test_dep1 = Department(name="Dep1") self.test_dep2 = Department(name="Dep2") # create resources self.test_user1 = User( login="******", name="User1", email="*****@*****.**", password="******", departments=[self.test_dep1] ) DBSession.add(self.test_user1) self.test_user2 = User( login="******", name="User2", email="*****@*****.**", password="******", departments=[self.test_dep1] ) DBSession.add(self.test_user2) self.test_user3 = User( login="******", name="User3", email="*****@*****.**", password="******", departments=[self.test_dep2] ) DBSession.add(self.test_user3) self.test_user4 = User( login="******", name="User4", email="*****@*****.**", password="******", departments=[self.test_dep2] ) DBSession.add(self.test_user4) # user with two departments self.test_user5 = User( login="******", name="User5", email="*****@*****.**", password="******", departments=[self.test_dep1, self.test_dep2], ) DBSession.add(self.test_user5) # user with no departments self.test_user6 = User(login="******", name="User6", email="*****@*****.**", password="******") DBSession.add(self.test_user6) # repository self.test_repo = Repository( name="Test Repository", linux_path="/mnt/T/", windows_path="T:/", osx_path="/Volumes/T/" ) DBSession.add(self.test_repo) # statuses self.test_status1 = Status(name="Status 1", code="STS1") self.test_status2 = Status(name="Status 2", code="STS2") self.test_status3 = Status(name="Status 3", code="STS3") self.test_status4 = Status(name="Status 4", code="STS4") self.test_status5 = Status(name="Status 5", code="STS5") DBSession.add_all( [self.test_status1, self.test_status2, self.test_status3, self.test_status4, self.test_status5] ) # status lists self.test_proj_status_list = StatusList( name="Project Status List", statuses=[self.test_status1, self.test_status2, self.test_status3], target_entity_type="Project", ) DBSession.add(self.test_proj_status_list) # create one project self.test_proj1 = Project( name="Test Project 1", code="TP1", repository=self.test_repo, status_list=self.test_proj_status_list, start=datetime.datetime(2013, 4, 4), end=datetime.datetime(2013, 5, 4), ) DBSession.add(self.test_proj1) self.test_proj1.now = datetime.datetime(2013, 4, 4) # create task status list with DBSession.no_autoflush: self.test_task_status_list = StatusList.query.filter_by(target_entity_type="Task").first() # create two tasks with the same resources self.test_task1 = Task( name="Task1", project=self.test_proj1, resources=[self.test_user1, self.test_user2], alternative_resources=[self.test_user3, self.test_user4, self.test_user5], schedule_model=0, schedule_timing=50, schedule_unit="h", status_list=self.test_task_status_list, ) DBSession.add(self.test_task1) self.test_task2 = Task( name="Task2", project=self.test_proj1, resources=[self.test_user1, self.test_user2], alternative_resources=[self.test_user3, self.test_user4, self.test_user5], depends=[self.test_task1], schedule_model=0, schedule_timing=60, schedule_unit="h", status_list=self.test_task_status_list, ) DBSession.add(self.test_task2) DBSession.commit()
def setUp(self): """setup the test """ # setup a test database self.TEST_DATABASE_URI = "sqlite:///:memory:" db.setup() db.init() # need to have some test object for # a department self.test_department1 = Department(name="Test Department 1") self.test_department2 = Department(name="Test Department 2") self.test_department3 = Department(name="Test Department 3") DBSession.add_all([self.test_department1, self.test_department2, self.test_department3]) # a couple of groups self.test_group1 = Group(name="Test Group 1") self.test_group2 = Group(name="Test Group 2") self.test_group3 = Group(name="Test Group 3") DBSession.add_all([self.test_group1, self.test_group2, self.test_group3]) # a couple of statuses self.test_status1 = Status(name="Completed", code="CMPLT") self.test_status2 = Status(name="Work In Progress", code="WIP") self.test_status3 = Status(name="Waiting To Start", code="WTS") self.test_status4 = Status(name="Pending Review", code="PRev") DBSession.add_all([self.test_status1, self.test_status2, self.test_status3, self.test_status4]) # a project status list self.project_status_list = StatusList( name="Project Status List", statuses=[self.test_status1, self.test_status2, self.test_status3, self.test_status4], target_entity_type=Project, ) # a repository type self.test_repository_type = Type(name="Test", code="test", target_entity_type=Repository) # a repository self.test_repository = Repository(name="Test Repository", type=self.test_repository_type) # a project type self.commercial_project_type = Type(name="Commercial Project", code="comm", target_entity_type=Project) # a couple of projects self.test_project1 = Project( name="Test Project 1", code="tp1", status_list=self.project_status_list, type=self.commercial_project_type, repository=self.test_repository, ) self.test_project2 = Project( name="Test Project 2", code="tp2", status_list=self.project_status_list, type=self.commercial_project_type, repository=self.test_repository, ) self.test_project3 = Project( name="Test Project 3", code="tp3", status_list=self.project_status_list, type=self.commercial_project_type, repository=self.test_repository, ) DBSession.add_all([self.test_project1, self.test_project2, self.test_project3]) # a task status list self.task_status_list = StatusList.query.filter_by(target_entity_type="Task").first() # a couple of tasks self.test_task1 = Task(name="Test Task 1", status_list=self.task_status_list, project=self.test_project1) self.test_task2 = Task(name="Test Task 2", status_list=self.task_status_list, project=self.test_project1) self.test_task3 = Task(name="Test Task 3", status_list=self.task_status_list, project=self.test_project2) self.test_task4 = Task(name="Test Task 4", status_list=self.task_status_list, project=self.test_project3) DBSession.add_all([self.test_task1, self.test_task2, self.test_task3, self.test_task4]) # for task1 self.test_version1 = Version(task=self.test_task1, full_path="some/path") DBSession.add(self.test_version1) self.test_version2 = Version(task=self.test_task1, full_path="some/path") DBSession.add(self.test_version2) self.test_version3 = Version(task=self.test_task1, full_path="some/path") DBSession.add(self.test_version3) # for task2 self.test_version4 = Version(task=self.test_task2, full_path="some/path") DBSession.add(self.test_version4) self.test_version5 = Version(task=self.test_task2, full_path="some/path") DBSession.add(self.test_version5) self.test_version6 = Version(task=self.test_task2, full_path="some/path") DBSession.add(self.test_version6) # for task3 self.test_version7 = Version(task=self.test_task3, full_path="some/path") DBSession.add(self.test_version7) self.test_version8 = Version(task=self.test_task3, full_path="some/path") DBSession.add(self.test_version8) self.test_version9 = Version(task=self.test_task3, full_path="some/path") DBSession.add(self.test_version9) # for task4 self.test_version10 = Version(task=self.test_task4, full_path="some/path") DBSession.add(self.test_version10) self.test_version11 = Version(task=self.test_task4, full_path="some/path") DBSession.add(self.test_version11) self.test_version12 = Version(task=self.test_task4, full_path="some/path") DBSession.add(self.test_version12) # ********************************************************************* # Tickets # ********************************************************************* # no need to create status list for tickets cause we have a database # set up an running so it will be automatically linked # tickets for version1 self.test_ticket1 = Ticket(project=self.test_project1, links=[self.test_version1]) DBSession.add(self.test_ticket1) # set it to closed self.test_ticket1.resolve() # create a new ticket and leave it open self.test_ticket2 = Ticket(project=self.test_project1, links=[self.test_version1]) DBSession.add(self.test_ticket2) # create a new ticket and close and then reopen it self.test_ticket3 = Ticket(project=self.test_project1, links=[self.test_version1]) DBSession.add(self.test_ticket3) self.test_ticket3.resolve() self.test_ticket3.reopen() # ********************************************************************* # tickets for version2 # create a new ticket and leave it open self.test_ticket4 = Ticket(project=self.test_project1, links=[self.test_version2]) DBSession.add(self.test_ticket4) # create a new Ticket and close it self.test_ticket5 = Ticket(project=self.test_project1, links=[self.test_version2]) DBSession.add(self.test_ticket5) self.test_ticket5.resolve() # create a new Ticket and close it self.test_ticket6 = Ticket(project=self.test_project1, links=[self.test_version3]) DBSession.add(self.test_ticket6) self.test_ticket6.resolve() # ********************************************************************* # tickets for version3 # create a new ticket and close it self.test_ticket7 = Ticket(project=self.test_project1, links=[self.test_version3]) DBSession.add(self.test_ticket7) self.test_ticket7.resolve() # create a new ticket and close it self.test_ticket8 = Ticket(project=self.test_project1, links=[self.test_version3]) DBSession.add(self.test_ticket8) self.test_ticket8.resolve() # ********************************************************************* # tickets for version4 # create a new ticket and close it self.test_ticket9 = Ticket(project=self.test_project1, links=[self.test_version4]) DBSession.add(self.test_ticket9) self.test_ticket9.resolve() # no tickets for any other version # ********************************************************************* # a status list for sequence self.sequence_status_list = StatusList.query.filter_by(target_entity_type="Sequence").first() # a couple of sequences self.test_sequence1 = Sequence( name="Test Seq 1", code="ts1", project=self.test_project1, status_list=self.sequence_status_list ) self.test_sequence2 = Sequence( name="Test Seq 2", code="ts2", project=self.test_project1, status_list=self.sequence_status_list ) self.test_sequence3 = Sequence( name="Test Seq 3", code="ts3", project=self.test_project1, status_list=self.sequence_status_list ) self.test_sequence4 = Sequence( name="Test Seq 4", code="ts4", project=self.test_project1, status_list=self.sequence_status_list ) DBSession.add_all([self.test_sequence1, self.test_sequence2, self.test_sequence3, self.test_sequence4]) # a test admin # self.test_admin = User( # name='Admin', # login='******', # email='*****@*****.**', # password='******' # ) self.test_admin = User.query.filter_by(name=defaults.admin_name).first() self.assertIsNotNone(self.test_admin) # create the default values for parameters self.kwargs = { "name": "Erkan Ozgur Yilmaz", "login": "******", "description": "this is a test user", "password": "******", "email": "*****@*****.**", "departments": [self.test_department1], "groups": [self.test_group1, self.test_group2], "created_by": self.test_admin, "updated_by": self.test_admin, } # create a proper user object self.test_user = User(**self.kwargs) DBSession.add(self.test_user) DBSession.commit() # just change the kwargs for other tests self.kwargs["name"] = "some other name" self.kwargs["email"] = "*****@*****.**"
def setUpClass(cls): """set up once """ db.setup() db.init()
def setUp(self): """setup the test """ db.setup() db.init() # statuses 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() # status lists self.test_project_status_list = StatusList( name="Project Status List", statuses=[self.status_new, self.status_wip, self.status_cmpl], target_entity_type=Project, ) self.test_sequence_status_list = \ StatusList.query.filter_by(target_entity_type='Sequence').first() self.test_shot_status_list = \ StatusList.query.filter_by(target_entity_type='Shot').first() self.test_asset_status_list = \ StatusList.query.filter_by(target_entity_type='Asset').first() # types self.test_commercial_project_type = Type( name="Commercial Project", code='comm', target_entity_type=Project, ) self.test_character_asset_type = Type( name="Character", code='char', target_entity_type=Asset, ) self.test_repository_type = Type(name="Test Repository Type", code='test', target_entity_type=Repository) # repository self.test_repository = Repository( name="Test Repository", type=self.test_repository_type, ) # image format self.test_image_format1 = ImageFormat(name='Test Image Format 1', width=1920, height=1080, pixel_aspect=1.0) self.test_image_format2 = ImageFormat(name='Test Image Format 2', width=1280, height=720, pixel_aspect=1.0) # project and sequences self.test_project1 = Project(name='Test Project1', code='tp1', type=self.test_commercial_project_type, status_list=self.test_project_status_list, repository=self.test_repository, image_format=self.test_image_format1) self.test_project2 = Project(name='Test Project2', code='tp2', type=self.test_commercial_project_type, status_list=self.test_project_status_list, repository=self.test_repository, image_format=self.test_image_format1) self.test_sequence1 = Sequence( name="Test Seq1", code='ts1', project=self.test_project1, status_list=self.test_sequence_status_list, ) self.test_sequence2 = Sequence( name="Test Seq2", code='ts2', project=self.test_project1, status_list=self.test_sequence_status_list, ) self.test_sequence3 = Sequence( name="Test Seq3", code='ts3', project=self.test_project1, status_list=self.test_sequence_status_list, ) self.test_scene1 = Scene( name='Test Sce1', code='tsc1', project=self.test_project1, ) self.test_scene2 = Scene( name='Test Sce2', code='tsc2', project=self.test_project1, ) self.test_scene3 = Scene(name='Test Sce3', code='tsc3', project=self.test_project1) self.test_asset1 = Asset( name="Test Asset1", code='ta1', project=self.test_project1, status_list=self.test_asset_status_list, type=self.test_character_asset_type, ) self.test_asset2 = Asset( name="Test Asset2", code='ta2', project=self.test_project1, status_list=self.test_asset_status_list, type=self.test_character_asset_type, ) self.test_asset3 = Asset( name="Test Asset3", code='ta3', project=self.test_project1, status_list=self.test_asset_status_list, type=self.test_character_asset_type, ) self.kwargs = dict( name='SH123', code='SH123', description='This is a test Shot', project=self.test_project1, sequences=[self.test_sequence1, self.test_sequence2], scenes=[self.test_scene1, self.test_scene2], cut_in=112, cut_out=149, source_in=120, source_out=140, record_in=85485, status=0, status_list=self.test_shot_status_list, image_format=self.test_image_format2) # create a mock shot object self.test_shot = Shot(**self.kwargs) db.DBSession.add(self.test_project1) db.DBSession.commit()
def setUpClass(cls): """setup test """ # ----------------------------------------------------------------- # start of the setUp # create the environment variable and point it to a temp directory database_url = "sqlite:///:memory:" db.setup({'sqlalchemy.url': database_url}) db.init() cls.temp_repo_path = tempfile.mkdtemp() cls.user1 = User( name='User 1', login='******', email='*****@*****.**', password='******' ) 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 ) 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() 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)}}', ) cls.structure = Structure( name='Project Struture', templates=[cls.task_template] ) cls.project_status_list = StatusList( name='Project Statuses', target_entity_type='Project', statuses=[cls.status_new, cls.status_wip, cls.status_comp] ) cls.image_format = ImageFormat( name='HD 1080', width=1920, height=1080, pixel_aspect=1.0 ) # create a test 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() cls.character_type = Type( name='Character', code='CHAR', target_entity_type='Asset' ) # 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 db.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 ]) db.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 db.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 db.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') db.DBSession.commit() # create a buffer for extra created files, which are to be removed cls.remove_these_files_buffer = []
The first one prefers to use a flat one, in which all the files are in the same folder. The second project uses a more traditional folder structure where every Task/Asset/Shot/Sequence has its own folder and the Task hierarchy is directly reflected to folder hierarchy. """ from stalker import (db, Project, Repository, Structure, FilenameTemplate, Task, Status, StatusList, Version, Sequence, Shot) # initialize an in memory sqlite3 database db.setup() # fill in default data db.init() # create a new repository repo = Repository( name='Test Repository', linux_path='/mnt/T/stalker_tests/', osx_path='/Volumes/T/stalker_tests/', 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}}'
def setUp(self): """setup the test """ db.setup() db.init() # users self.test_user1 = User(name="User1", login="******", password="******", email="*****@*****.**") self.test_user2 = User(name="User2", login="******", password="******", email="*****@*****.**") # statuses self.status_wip = Status.query.filter_by(code="WIP").first() self.status_cmpl = Status.query.filter_by(code="CMPL").first() # status lists self.project_status_list = StatusList( name="Project Status List", target_entity_type=Project, statuses=[self.status_cmpl, self.status_wip] ) 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() # types self.commercial_project_type = Type(name="Commercial Project", code="commproj", target_entity_type=Project) self.asset_type1 = Type(name="Character", code="char", target_entity_type=Asset) self.asset_type2 = Type(name="Environment", code="env", target_entity_type=Asset) self.repository_type = Type(name="Test Repository Type", code="testrepo", target_entity_type=Repository) # repository self.repository = Repository(name="Test Repository", type=self.repository_type) # project self.project1 = Project( name="Test Project1", code="tp1", type=self.commercial_project_type, status_list=self.project_status_list, repositories=[self.repository], ) # sequence self.seq1 = Sequence( name="Test Sequence", code="tseq", project=self.project1, status_list=self.sequence_status_list, responsible=[self.test_user1], ) # shots self.shot1 = Shot( code="TestSH001", status_list=self.shot_status_list, project=self.project1, sequences=[self.seq1], responsible=[self.test_user1], ) self.shot2 = Shot( code="TestSH002", status_list=self.shot_status_list, project=self.project1, sequences=[self.seq1], responsible=[self.test_user1], ) self.shot3 = Shot( code="TestSH003", status_list=self.shot_status_list, project=self.project1, sequences=[self.seq1], responsible=[self.test_user1], ) self.shot4 = Shot( code="TestSH004", status_list=self.shot_status_list, project=self.project1, sequences=[self.seq1], responsible=[self.test_user1], ) self.kwargs = { "name": "Test Asset", "code": "ta", "description": "This is a test Asset object", "project": self.project1, "type": self.asset_type1, "status": 0, "status_list": self.asset_status_list, "responsible": [self.test_user1], } self.asset1 = Asset(**self.kwargs) # tasks self.task1 = Task(name="Task1", parent=self.asset1, status_list=self.task_status_list) self.task2 = Task(name="Task2", parent=self.asset1, status_list=self.task_status_list) self.task3 = Task(name="Task3", parent=self.asset1, status_list=self.task_status_list)
def setUp(self): """run once """ from stalker import defaults import datetime defaults.timing_resolution = datetime.timedelta(hours=1) # create a new session from stalker import db db.setup({'sqlalchemy.url': 'sqlite://', 'sqlalchemy.echo': False}) db.init() from stalker import Status 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() self.status_new = Status.query.filter_by(code='NEW').first() self.status_app = Status.query.filter_by(code='APP').first() from stalker import StatusList self.budget_status_list = StatusList( name='Budget Statuses', target_entity_type='Budget', statuses=[self.status_new, self.status_prev, self.status_app]) db.DBSession.add(self.budget_status_list) self.task_status_list = StatusList.query\ .filter_by(target_entity_type='Task').first() from stalker import Project self.test_project_status_list = StatusList( name="Project Statuses", statuses=[self.status_wip, self.status_prev, self.status_cmpl], target_entity_type=Project, ) from stalker import Type self.test_movie_project_type = Type( name="Movie Project", code='movie', target_entity_type=Project, ) from stalker import Repository self.test_repository_type = Type( name="Test Repository Type", code='test', target_entity_type=Repository, ) self.test_repository = Repository( name="Test Repository", type=self.test_repository_type, ) from stalker import User self.test_user1 = User(name="User1", login="******", email="*****@*****.**", password="******") self.test_user2 = User(name="User2", login="******", email="*****@*****.**", password="******") self.test_user3 = User(name="User3", login="******", email="*****@*****.**", password="******") self.test_user4 = User(name="User4", login="******", email="*****@*****.**", password="******") self.test_user5 = User(name="User5", login="******", email="*****@*****.**", password="******") from stalker import Client self.test_client = Client(name='Test Client', ) self.test_project = Project(name="Test Project1", code='tp1', type=self.test_movie_project_type, status_list=self.test_project_status_list, repository=self.test_repository, clients=[self.test_client]) from stalker import Budget self.test_budget = Budget( project=self.test_project, name='Test Budget 1', ) from stalker import Invoice self.test_invoice = Invoice(budget=self.test_budget, client=self.test_client, amount=1500, unit='TRY')
def setUp(self): """sets up the test """ db.setup() db.init() self.test_repo_path = tempfile.mkdtemp() # create test data self.test_repo = Repository(name='Test Repository', linux_path=self.test_repo_path, windows_path=self.test_repo_path, osx_path=self.test_repo_path) self.test_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.test_structure = Structure(name='Test Project Structure', templates=[self.test_task_template]) 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.test_project_status_list = \ StatusList.query.filter(target_entity_type='Project').first() 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) DBSession.add(self.test_project1) DBSession.commit() # now create tasks # root tasks self.test_task1 = Task(name='Task1', project=self.test_project1) self.test_task2 = Task(name='Task2', project=self.test_project1) self.test_task3 = Task(name='Task3', project=self.test_project1) # child of Task1 self.test_task4 = Task(name='Task4', parent=self.test_task1) self.test_task5 = Task(name='Task5', parent=self.test_task1) self.test_task6 = Task(name='Task6', parent=self.test_task1) # child of Task2 self.test_task7 = Task(name='Task7', parent=self.test_task2) self.test_task8 = Task(name='Task8', parent=self.test_task2) self.test_task9 = Task(name='Task9', parent=self.test_task2) # child of Task10 self.test_task10 = Task(name='Task10', parent=self.test_task3) self.test_task11 = Task(name='Task11', parent=self.test_task3) self.test_task12 = Task(name='Task12', parent=self.test_task3) DBSession.add_all([ self.test_task1, self.test_task2, self.test_task3, self.test_task4, self.test_task5, self.test_task6, self.test_task7, self.test_task8, self.test_task9, self.test_task10, self.test_task11, self.test_task12 ]) # now create versions for each of leaf tasks # Task4 # Main self.test_version1 = self.create_version(self.test_task4, take_name='Main') self.test_version2 = self.create_version(self.test_task4, take_name='Main') self.test_version3 = self.create_version(self.test_task4, take_name='Main') # Take1 self.test_version4 = self.create_version(self.test_task4, take_name='Take1') self.test_version5 = self.create_version(self.test_task4, take_name='Take1') self.test_version6 = self.create_version(self.test_task4, take_name='Take1') # Take2 self.test_version7 = self.create_version(self.test_task4, take_name='Take2') self.test_version8 = self.create_version(self.test_task4, take_name='Take2') self.test_version9 = self.create_version(self.test_task4, take_name='Take2') # Task5 # Main self.test_version10 = self.create_version(self.test_task5, take_name='Main') self.test_version11 = self.create_version(self.test_task5, take_name='Main') self.test_version12 = self.create_version(self.test_task5, take_name='Main') # Take1 self.test_version13 = self.create_version(self.test_task5, take_name='Take1') self.test_version14 = self.create_version(self.test_task5, take_name='Take1') self.test_version15 = self.create_version(self.test_task5, take_name='Take1') # Take2 self.test_version16 = self.create_version(self.test_task5, take_name='Take2') self.test_version17 = self.create_version(self.test_task5, take_name='Take2') self.test_version18 = self.create_version(self.test_task5, take_name='Take2') # Task6 # Main self.test_version19 = self.create_version(self.test_task6, take_name='Main') self.test_version20 = self.create_version(self.test_task6, take_name='Main') self.test_version21 = self.create_version(self.test_task6, take_name='Main') # Take1 self.test_version22 = self.create_version(self.test_task6, take_name='Take1') self.test_version23 = self.create_version(self.test_task6, take_name='Take1') self.test_version24 = self.create_version(self.test_task6, take_name='Take1') # Take2 self.test_version25 = self.create_version(self.test_task6, take_name='Take2') self.test_version26 = self.create_version(self.test_task6, take_name='Take2') self.test_version27 = self.create_version(self.test_task6, take_name='Take2') # Task7 # Main self.test_version28 = self.create_version(self.test_task7, take_name='Main') self.test_version29 = self.create_version(self.test_task7, take_name='Main') self.test_version30 = self.create_version(self.test_task7, take_name='Main') # Take1 self.test_version31 = self.create_version(self.test_task7, take_name='Take1') self.test_version32 = self.create_version(self.test_task7, take_name='Take1') self.test_version33 = self.create_version(self.test_task7, take_name='Take1') # Take2 self.test_version34 = self.create_version(self.test_task7, take_name='Take2') self.test_version35 = self.create_version(self.test_task7, take_name='Take2') self.test_version36 = self.create_version(self.test_task7, take_name='Take2') # Task8 - will have no versions # Task9 - it is a destination task with versions # Main self.test_version37 = self.create_version(self.test_task9, take_name='Main') self.test_version38 = self.create_version(self.test_task9, take_name='Main') self.test_version39 = self.create_version(self.test_task9, take_name='Main') # Take1 - an existing take self.test_version40 = self.create_version(self.test_task9, take_name='Take1') self.test_version41 = self.create_version(self.test_task9, take_name='Take1') self.test_version42 = self.create_version(self.test_task9, take_name='Take1') # Take3 - a non existing take self.test_version43 = self.create_version(self.test_task9, take_name='Take1') self.test_version44 = self.create_version(self.test_task9, take_name='Take1') self.test_version45 = self.create_version(self.test_task9, take_name='Take1') if not QtGui.QApplication.instance(): self.app = QtGui.QApplication(sys.argv) else: # self.app = QtGui.qApp self.app = QtGui.QApplication.instance() self.dialog = VersionMover()
def setUp(self): """create test data """ database_url = 'sqlite:///:memory:' db.setup({'sqlalchemy.url': database_url}) db.init() self.temp_repo_path = tempfile.mkdtemp() self.user1 = User(name='User 1', login='******', email='*****@*****.**', password='******') 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.query.filter_by(target_entity_type='Project').first() 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) # create task hierarchy # # ASSETS # self.assets = Task(name='Assets', project=self.project, responsible=[self.user1]) # # SEQUENCES # self.sequences = Task(name='Sequences', project=self.project, responsible=[self.user1]) self.seq001 = Sequence(name='Seq001', code='Seq001', parent=self.sequences) self.scene_task = Task(name='001_IST', parent=self.seq001) self.scene_previs_type = Type(name='Scene Previs', code='Scene Previs', target_entity_type='Task') self.scene_previs = Task(name='Scene Previs', parent=self.scene_task, type=self.scene_previs_type) self.shots = Task(name='Shots', parent=self.scene_task) self.shot1 = Shot(name='Seq001_001_IST_0010', code='Seq001_001_IST_0010', parent=self.shots) # create shot tasks self.previs = Task(name='Previs', parent=self.shot1) self.camera = Task(name='Camera', parent=self.shot1) self.animation = Task(name='Animation', parent=self.shot1) self.scene_assembly = Task(name='SceneAssembly', parent=self.shot1) self.lighting = Task(name='Lighting', parent=self.shot1) self.comp = Task(name='Comp', parent=self.shot1) # create maya files self.maya_env = Maya() pm.newFile(force=True) sm = pm.PyNode('sequenceManager1') seq1 = sm.create_sequence('001_IST') # create 3 shots shot1 = seq1.create_shot('shot1') shot2 = seq1.create_shot('shot2') shot3 = seq1.create_shot('shot3') # set shot ranges shot1.startFrame.set(1) shot1.endFrame.set(100) shot2.startFrame.set(101) shot2.endFrame.set(200) shot2.sequenceStartFrame.set(101) shot3.startFrame.set(201) shot3.endFrame.set(300) shot3.sequenceStartFrame.set(201) # save the file under scene previs v = Version(task=self.scene_previs) self.maya_env.save_as(v) pm.newFile(force=1) print(v.absolute_full_path)
def setUp(self): """setup the test """ db.setup() db.init() # statuses 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() # status lists self.test_project_status_list = StatusList( name="Project Status List", statuses=[ self.status_new, self.status_wip, self.status_cmpl ], target_entity_type=Project, ) self.test_sequence_status_list = \ StatusList.query.filter_by(target_entity_type='Sequence').first() self.test_shot_status_list = \ StatusList.query.filter_by(target_entity_type='Shot').first() self.test_asset_status_list = \ StatusList.query.filter_by(target_entity_type='Asset').first() # types self.test_commercial_project_type = Type( name="Commercial Project", code='comm', target_entity_type=Project, ) self.test_character_asset_type = Type( name="Character", code='char', target_entity_type=Asset, ) self.test_repository_type = Type( name="Test Repository Type", code='test', target_entity_type=Repository ) # repository self.test_repository = Repository( name="Test Repository", type=self.test_repository_type, ) # image format self.test_image_format1 = ImageFormat( name='Test Image Format 1', width=1920, height=1080, pixel_aspect=1.0 ) self.test_image_format2 = ImageFormat( name='Test Image Format 2', width=1280, height=720, pixel_aspect=1.0 ) # project and sequences self.test_project1 = Project( name='Test Project1', code='tp1', type=self.test_commercial_project_type, status_list=self.test_project_status_list, repository=self.test_repository, image_format=self.test_image_format1 ) self.test_project2 = Project( name='Test Project2', code='tp2', type=self.test_commercial_project_type, status_list=self.test_project_status_list, repository=self.test_repository, image_format=self.test_image_format1 ) self.test_sequence1 = Sequence( name="Test Seq1", code='ts1', project=self.test_project1, status_list=self.test_sequence_status_list, ) self.test_sequence2 = Sequence( name="Test Seq2", code='ts2', project=self.test_project1, status_list=self.test_sequence_status_list, ) self.test_sequence3 = Sequence( name="Test Seq3", code='ts3', project=self.test_project1, status_list=self.test_sequence_status_list, ) self.test_scene1 = Scene( name='Test Sce1', code='tsc1', project=self.test_project1, ) self.test_scene2 = Scene( name='Test Sce2', code='tsc2', project=self.test_project1, ) self.test_scene3 = Scene( name='Test Sce3', code='tsc3', project=self.test_project1 ) self.test_asset1 = Asset( name="Test Asset1", code='ta1', project=self.test_project1, status_list=self.test_asset_status_list, type=self.test_character_asset_type, ) self.test_asset2 = Asset( name="Test Asset2", code='ta2', project=self.test_project1, status_list=self.test_asset_status_list, type=self.test_character_asset_type, ) self.test_asset3 = Asset( name="Test Asset3", code='ta3', project=self.test_project1, status_list=self.test_asset_status_list, type=self.test_character_asset_type, ) self.test_cut_in_default = 1 self.test_cut_duration_default = 1 self.test_cut_out_default = 1 self.kwargs = dict( name='SH123', code='SH123', description='This is a test Shot', project=self.test_project1, sequences=[self.test_sequence1, self.test_sequence2], scenes=[self.test_scene1, self.test_scene2], cut_in=112, cut_out=149, cut_duration=123, status=0, status_list=self.test_shot_status_list, image_format=self.test_image_format2 ) # create a mock shot object self.test_shot = Shot(**self.kwargs)
def setUp(self): """setup the test """ db.setup() db.init() # statuses self.status_wip = Status.query.filter_by(code='WIP').first() self.status_cmpl = Status.query.filter_by(code='CMPL').first() # status lists self.project_status_list = StatusList( name="Project Status List", target_entity_type=Project, statuses=[ self.status_cmpl, self.status_wip ] ) 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() # types self.commercial_project_type = Type( name="Commercial Project", code='commproj', target_entity_type=Project, ) self.asset_type1 = Type( name="Character", code='char', target_entity_type=Asset ) self.asset_type2 = Type( name="Environment", code='env', target_entity_type=Asset ) self.repository_type = Type( name="Test Repository Type", code='testrepo', target_entity_type=Repository, ) # repository self.repository = Repository( name="Test Repository", type=self.repository_type, ) # project self.project1 = Project( name="Test Project1", code='tp1', type=self.commercial_project_type, status_list=self.project_status_list, repository=self.repository, ) # sequence self.seq1 = Sequence( name="Test Sequence", code='tseq', project=self.project1, status_list=self.sequence_status_list, ) # shots self.shot1 = Shot( code="TestSH001", status_list=self.shot_status_list, project=self.project1, sequences=[self.seq1], ) self.shot2 = Shot( code="TestSH002", status_list=self.shot_status_list, project=self.project1, sequences=[self.seq1], ) self.shot3 = Shot( code="TestSH003", status_list=self.shot_status_list, project=self.project1, sequences=[self.seq1], ) self.shot4 = Shot( code="TestSH004", status_list=self.shot_status_list, project=self.project1, sequences=[self.seq1], ) self.kwargs = { "name": "Test Asset", 'code': 'ta', "description": "This is a test Asset object", "project": self.project1, "type": self.asset_type1, "status": 0, "status_list": self.asset_status_list, } self.asset1 = Asset(**self.kwargs) # tasks self.task1 = Task( name="Task1", parent=self.asset1, status_list=self.task_status_list ) self.task2 = Task( name="Task2", parent=self.asset1, status_list=self.task_status_list ) self.task3 = Task( name="Task3", parent=self.asset1, status_list=self.task_status_list )
def setUp(self): """set up the test """ # we need a database db.setup(self.config) db.init() # replace datetime now function # create departments self.test_dep1 = Department(name='Dep1') self.test_dep2 = Department(name='Dep2') # create resources self.test_user1 = User( login='******', name='User1', email='*****@*****.**', password='******', departments=[self.test_dep1] ) DBSession.add(self.test_user1) self.test_user2 = User( login='******', name='User2', email='*****@*****.**', password='******', departments=[self.test_dep1] ) DBSession.add(self.test_user2) self.test_user3 = User( login='******', name='User3', email='*****@*****.**', password='******', departments=[self.test_dep2] ) DBSession.add(self.test_user3) self.test_user4 = User( login='******', name='User4', email='*****@*****.**', password='******', departments=[self.test_dep2] ) DBSession.add(self.test_user4) # user with two departments self.test_user5 = User( login='******', name='User5', email='*****@*****.**', password='******', departments=[self.test_dep1, self.test_dep2] ) DBSession.add(self.test_user5) # user with no departments self.test_user6 = User( login='******', name='User6', email='*****@*****.**', password='******' ) DBSession.add(self.test_user6) # repository self.test_repo = Repository( name='Test Repository', linux_path='/mnt/T/', windows_path='T:/', osx_path='/Volumes/T/' ) DBSession.add(self.test_repo) # statuses self.test_status1 = Status(name='Status 1', code='STS1') self.test_status2 = Status(name='Status 2', code='STS2') self.test_status3 = Status(name='Status 3', code='STS3') self.test_status4 = Status(name='Status 4', code='STS4') self.test_status5 = Status(name='Status 5', code='STS5') DBSession.add_all([self.test_status1, self.test_status2, self.test_status3, self.test_status4, self.test_status5]) # status lists self.test_proj_status_list = StatusList( name='Project Status List', statuses=[self.test_status1, self.test_status2, self.test_status3], target_entity_type='Project' ) DBSession.add(self.test_proj_status_list) # create one project self.test_proj1 = Project( name='Test Project 1', code='TP1', repository=self.test_repo, status_list=self.test_proj_status_list, start=datetime.datetime(2013, 4, 4), end=datetime.datetime(2013, 5, 4) ) DBSession.add(self.test_proj1) self.test_proj1.now = datetime.datetime(2013, 4, 4) # create task status list with DBSession.no_autoflush: self.test_task_status_list = StatusList.query\ .filter_by(target_entity_type='Task').first() # create two tasks with the same resources self.test_task1 = Task( name='Task1', project=self.test_proj1, resources=[self.test_user1, self.test_user2], alternative_resources=[ self.test_user3, self.test_user4, self.test_user5 ], schedule_model=0, schedule_timing=50, schedule_unit='h', status_list=self.test_task_status_list ) DBSession.add(self.test_task1) self.test_task2 = Task( name='Task2', project=self.test_proj1, resources=[self.test_user1, self.test_user2], alternative_resources=[ self.test_user3, self.test_user4, self.test_user5 ], depends=[self.test_task1], schedule_model=0, schedule_timing=60, schedule_unit='h', status_list=self.test_task_status_list ) DBSession.add(self.test_task2) DBSession.commit()
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 setUpClass(cls): """setup once """ db.setup() db.init() 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.test_project_status_list = StatusList( name='Project Statuses', target_entity_type='Project', statuses=[cls.status_new, cls.status_wip, cls.status_cmpl] ) cls.test_repo = Repository(name='Test Repository') cls.test_project = Project( name='Test Project', code='TP', repository=cls.test_repo, status_list=cls.test_project_status_list ) cls.test_task1 = Task( name='Test Task 1', project=cls.test_project ) cls.test_task2 = Task( name='Test Task 2', project=cls.test_project ) cls.test_task3 = Task( name='Test Task 3', project=cls.test_project ) cls.test_version1 = Version(task=cls.test_task1) db.DBSession.add(cls.test_version1) db.DBSession.commit() cls.test_version2 = Version(task=cls.test_task1) db.DBSession.add(cls.test_version2) db.DBSession.commit() cls.test_version3 = Version(task=cls.test_task1) db.DBSession.add(cls.test_version3) db.DBSession.commit() cls.test_version4 = Version(task=cls.test_task2) db.DBSession.add(cls.test_version4) db.DBSession.commit() cls.test_link1 = Link(original_filename='test_render1.jpg') cls.test_link2 = Link(original_filename='test_render2.jpg') cls.test_link3 = Link(original_filename='test_render3.jpg') cls.test_link4 = Link(original_filename='test_render4.jpg') cls.test_version1.outputs = [ cls.test_link1, cls.test_link2, cls.test_link3 ] cls.test_version4.outputs = [ cls.test_link4 ] db.DBSession.add_all([ cls.test_task1, cls.test_task2, cls.test_task3, cls.test_version1, cls.test_version2, cls.test_version3, cls.test_version4, cls.test_link1, cls.test_link2, cls.test_link3, cls.test_link4 ]) db.DBSession.commit()
def setUp(self): """set up the test """ self.db_path = tempfile.mktemp(suffix='sqlite3') db.setup({'sqlalchemy.url': 'sqlite:///%s' % self.db_path}) db.init() # statuses 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() # status lists self.test_project_status_list = StatusList( name="Project Status List", statuses=[ self.status_new, self.status_wip, self.status_cmpl ], target_entity_type=Project, ) self.test_shot_status_list = \ StatusList.query.filter_by(target_entity_type='Shot').first() # types self.test_commercial_project_type = Type( name="Commercial Project", code='comm', target_entity_type=Project, ) self.test_repository_type = Type( name="Test Repository Type", code='test', target_entity_type=Repository ) # repository self.test_repository = Repository( name="Test Repository", type=self.test_repository_type, ) # image format self.test_image_format1 = ImageFormat( name='Test Image Format 1', width=1920, height=1080, pixel_aspect=1.0 ) self.test_image_format2 = ImageFormat( name='Test Image Format 2', width=1280, height=720, pixel_aspect=1.0 ) # project and sequences self.test_project1 = Project( name='Test Project1', code='tp1', type=self.test_commercial_project_type, status_list=self.test_project_status_list, repository=self.test_repository, image_format=self.test_image_format1 ) self.test_cut_in_default = 1 self.test_cut_duration_default = 1 self.test_cut_out_default = 1 self.kwargs = dict( name='SH123', code='SH123', description='This is a test Shot', project=self.test_project1, cut_in=112, cut_out=149, cut_duration=123, status=0 ) # create a mock shot object self.test_shot = Shot(**self.kwargs) db.DBSession.add(self.test_shot) db.DBSession.commit()
def setUp(self): """set up the test """ db.setup() db.init() # get statuses 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() 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='******' ) self.test_repo = Repository( name='Test Repository' ) self.test_structure = Structure( name='test structure' ) # project status list 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 ] ) self.test_project1 = Project( name='Test Project 1', code='TP1', lead=self.test_user1, repository=self.test_repo, structure=self.test_structure, status_list=self.test_project_status_list ) # create three Tasks 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 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 ]) 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' }
# update the config config = {'sqlalchemy.url': database_url, 'sqlalchemy.poolclass': NullPool} try: os.environ.pop(Config.env_key) except KeyError: # already removed pass # regenerate the defaults stalker.defaults = Config() stalker.defaults.timing_resolution = datetime.timedelta(minutes=10) # init database db.setup(config) db.init() status_wfd = Status.query.filter_by(code="WFD").first() status_rts = Status.query.filter_by(code="RTS").first() status_wip = Status.query.filter_by(code="WIP").first() status_prev = Status.query.filter_by(code="PREV").first() status_hrev = Status.query.filter_by(code="HREV").first() status_drev = Status.query.filter_by(code="DREV").first() status_oh = Status.query.filter_by(code="OH").first() status_stop = Status.query.filter_by(code="STOP").first() status_cmpl = Status.query.filter_by(code="CMPL").first() task_status_list = StatusList.query \ .filter_by(target_entity_type='Task').first() test_movie_project_type = Type(
def setUp(self): """set the test up """ from stalker import (db, defaults, Status, User, StatusList, Repository, Project, Type, Asset, Task) defaults.timing_resolution = datetime.timedelta(hours=1) # # clean up test database db.setup(self.config) db.init() # create a couple of task self.status_new = Status.query.filter(Status.code == 'NEW').first() self.status_wip = Status.query.filter(Status.code == 'WIP').first() self.status_cmpl = \ Status.query.filter(Status.code == 'CMPL').first() self.test_user1 = User( name="User1", login="******", email="*****@*****.**", password="******", ) self.test_user2 = User( name="User2", login="******", email="*****@*****.**", password="******", ) self.test_user3 = User( name="User3", login="******", email="*****@*****.**", password="******", ) self.project_status_list = StatusList( name="Project Status List", statuses=[self.status_new, self.status_wip, self.status_cmpl], target_entity_type="Project", ) self.repo = Repository( name='Test Repo', linux_path='/mnt/M/JOBs', windows_path='M:/JOBs', osx_path='/Users/Shared/Servers/M', ) self.project1 = Project( name='Tests Project', code='tp', status_list=self.project_status_list, repository=self.repo, ) self.char_asset_type = Type( name='Character Asset', code='char', target_entity_type="Asset" ) self.asset1 = Asset( name='Char1', code='char1', type=self.char_asset_type, project=self.project1, responsible=[self.test_user1] ) self.task1 = Task( name="Test Task", watchers=[self.test_user3], parent=self.asset1, schedule_timing=5, schedule_unit='h', bid_timing=52, bid_unit='h' ) self.child_task1 = Task( name='Child Task 1', resources=[self.test_user1, self.test_user2], parent=self.task1, ) self.child_task2 = Task( name='Child Task 2', resources=[self.test_user1, self.test_user2], parent=self.task1, ) self.task2 = Task( name='Another Task', project=self.project1, resources=[self.test_user1], responsible=[self.test_user2] ) self.entity_group1 = EntityGroup( name='My Tasks', entities=[ self.task1, self.child_task2, self.task2 ] ) db.DBSession.add_all([ self.task1, self.child_task1, self.child_task2, self.task2, self.test_user1, self.test_user2, self.project1, self.status_cmpl, self.status_new, self.status_wip, self.asset1 ]) db.DBSession.commit()
def setUp(self): """create test data """ database_url = 'sqlite:///:memory:' db.setup({'sqlalchemy.url': database_url}) db.init() self.temp_repo_path = tempfile.mkdtemp() self.user1 = User( name='User 1', login='******', email='*****@*****.**', password='******' ) 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 ) # create task hierarchy # # ASSETS # self.assets = Task( name='Assets', project=self.project, responsible=[self.user1] ) # # SEQUENCES # self.sequences = Task( name='Sequences', project=self.project, responsible=[self.user1] ) self.seq001 = Sequence( name='Seq001', code='Seq001', parent=self.sequences ) self.scene_task = Task( name='001_IST', parent=self.seq001 ) self.scene_previs_type = Type( name='Scene Previs', code='Scene Previs', target_entity_type='Task' ) self.scene_previs = Task( name='Scene Previs', parent=self.scene_task, type=self.scene_previs_type ) self.shots = Task( name='Shots', parent=self.scene_task ) self.shot1 = Shot( name='Seq001_001_IST_0010', code='Seq001_001_IST_0010', parent=self.shots ) # create shot tasks self.previs = Task( name='Previs', parent=self.shot1 ) self.camera = Task( name='Camera', parent=self.shot1 ) self.animation = Task( name='Animation', parent=self.shot1 ) self.scene_assembly = Task( name='SceneAssembly', parent=self.shot1 ) self.lighting = Task( name='Lighting', parent=self.shot1 ) self.comp = Task( name='Comp', parent=self.shot1 ) # create maya files self.maya_env = Maya() pm.newFile(force=True) sm = pm.PyNode('sequenceManager1') seq1 = sm.create_sequence('001_IST') # create 3 shots shot1 = seq1.create_shot('shot1') shot2 = seq1.create_shot('shot2') shot3 = seq1.create_shot('shot3') # set shot ranges shot1.startFrame.set(1) shot1.endFrame.set(100) shot2.startFrame.set(101) shot2.endFrame.set(200) shot2.sequenceStartFrame.set(101) shot3.startFrame.set(201) shot3.endFrame.set(300) shot3.sequenceStartFrame.set(201) # save the file under scene previs v = Version(task=self.scene_previs) self.maya_env.save_as(v) pm.newFile(force=1) print(v.absolute_full_path)
def setUp(self): """set up the test """ self.db_path = tempfile.mktemp(suffix='.sqlite3') db.setup({'sqlalchemy.url': 'sqlite:///%s' % self.db_path}) db.init() # statuses 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() # status lists self.test_project_status_list = StatusList( name="Project Status List", statuses=[self.status_new, self.status_wip, self.status_cmpl], target_entity_type=Project, ) self.test_shot_status_list = \ StatusList.query.filter_by(target_entity_type='Shot').first() # types self.test_commercial_project_type = Type( name="Commercial Project", code='comm', target_entity_type=Project, ) self.test_repository_type = Type(name="Test Repository Type", code='test', target_entity_type=Repository) # repository self.test_repository = Repository( name="Test Repository", type=self.test_repository_type, ) # image format self.test_image_format1 = ImageFormat(name='Test Image Format 1', width=1920, height=1080, pixel_aspect=1.0) self.test_image_format2 = ImageFormat(name='Test Image Format 2', width=1280, height=720, pixel_aspect=1.0) # project and sequences self.test_project1 = Project(name='Test Project1', code='tp1', type=self.test_commercial_project_type, status_list=self.test_project_status_list, repository=self.test_repository, image_format=self.test_image_format1) self.test_cut_in_default = 1 self.test_cut_duration_default = 1 self.test_cut_out_default = 1 self.kwargs = dict(name='SH123', code='SH123', description='This is a test Shot', project=self.test_project1, cut_in=112, cut_out=149, cut_duration=123, status=0) # create a mock shot object self.test_shot = Shot(**self.kwargs) db.DBSession.add(self.test_shot) db.DBSession.commit()
def create_db(): """creates a test database """ from stalker import db db.setup({'sqlalchemy.url': 'sqlite://'}) db.init()
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 setUp(self): """set up the test """ db.setup() db.init() # get statuses 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() 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='******') self.test_repo = Repository(name='Test Repository') self.test_structure = Structure(name='test structure') # project status list 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 ]) 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 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 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 ]) 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): """lets setup the tests """ db.setup() # uses in memory sqlite db db.init() self.test_admin = User.query.filter_by(login="******").first() # create a couple of test users self.test_user1 = User( name="User1", login="******", email="*****@*****.**", password="******", ) db.DBSession.add(self.test_user1) self.test_user2 = User( name="User2", login="******", email="*****@*****.**", password="******", ) db.DBSession.add(self.test_user2) self.test_user3 = User( name="User3", login="******", email="*****@*****.**", password="******", ) db.DBSession.add(self.test_user3) self.test_user4 = User( name="User4", login="******", email="*****@*****.**", password="******", ) db.DBSession.add(self.test_user4) self.test_user5 = User( name="User5", login="******", email="*****@*****.**", password="******", ) db.DBSession.add(self.test_user5) self.users_list = [ self.test_user1, self.test_user2, self.test_user3, self.test_user4 ] self.date_created = self.date_updated = datetime.datetime.now() self.kwargs = { "name": "Test Department", "description": "This is a department for testing purposes", "created_by": self.test_admin, "updated_by": self.test_admin, "date_created": self.date_created, "date_updated": self.date_updated, "users": self.users_list } # create a default department object self.test_department = Department(**self.kwargs) db.DBSession.add(self.test_department) db.DBSession.commit()
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 setUpClass(cls): """setup once """ # remove the transaction manager db.DBSession.remove() cls.repo_path = tempfile.mkdtemp() from anima import defaults 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): """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()
def setUp(self): """set the test up """ from stalker import (db, defaults, Status, User, StatusList, Repository, Project, Type, Asset, Task) defaults.timing_resolution = datetime.timedelta(hours=1) # # clean up test database db.setup(self.config) db.init() # create a couple of task self.status_new = Status.query.filter(Status.code == 'NEW').first() self.status_wip = Status.query.filter(Status.code == 'WIP').first() self.status_cmpl = \ Status.query.filter(Status.code == 'CMPL').first() self.test_user1 = User( name="User1", login="******", email="*****@*****.**", password="******", ) self.test_user2 = User( name="User2", login="******", email="*****@*****.**", password="******", ) self.test_user3 = User( name="User3", login="******", email="*****@*****.**", password="******", ) self.project_status_list = StatusList( name="Project Status List", statuses=[self.status_new, self.status_wip, self.status_cmpl], target_entity_type="Project", ) self.repo = Repository( name='Test Repo', linux_path='/mnt/M/JOBs', windows_path='M:/JOBs', osx_path='/Users/Shared/Servers/M', ) self.project1 = Project( name='Tests Project', code='tp', status_list=self.project_status_list, repository=self.repo, ) self.char_asset_type = Type(name='Character Asset', code='char', target_entity_type="Asset") self.asset1 = Asset(name='Char1', code='char1', type=self.char_asset_type, project=self.project1, responsible=[self.test_user1]) self.task1 = Task(name="Test Task", watchers=[self.test_user3], parent=self.asset1, schedule_timing=5, schedule_unit='h', bid_timing=52, bid_unit='h') self.child_task1 = Task( name='Child Task 1', resources=[self.test_user1, self.test_user2], parent=self.task1, ) self.child_task2 = Task( name='Child Task 2', resources=[self.test_user1, self.test_user2], parent=self.task1, ) self.task2 = Task(name='Another Task', project=self.project1, resources=[self.test_user1], responsible=[self.test_user2]) self.entity_group1 = EntityGroup( name='My Tasks', entities=[self.task1, self.child_task2, self.task2]) db.DBSession.add_all([ self.task1, self.child_task1, self.child_task2, self.task2, self.test_user1, self.test_user2, self.project1, self.status_cmpl, self.status_new, self.status_wip, self.asset1 ]) db.DBSession.commit()
def setUp(self): """run once """ defaults.timing_resolution = datetime.timedelta(hours=1) # create a new session db.setup({ 'sqlalchemy.url': 'sqlite://', 'sqlalchemy.echo': False }) db.init() 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() self.task_status_list = StatusList.query\ .filter_by(target_entity_type='Task').first() self.test_project_status_list = StatusList( name="Project Statuses", statuses=[self.status_wip, self.status_prev, self.status_cmpl], target_entity_type=Project, ) self.test_movie_project_type = Type( name="Movie Project", code='movie', target_entity_type=Project, ) self.test_repository_type = Type( name="Test Repository Type", code='test', target_entity_type=Repository, ) self.test_repository = Repository( name="Test Repository", type=self.test_repository_type, linux_path=tempfile.mkdtemp(), windows_path=tempfile.mkdtemp(), osx_path=tempfile.mkdtemp() ) self.test_user1 = User( name="User1", login="******", email="*****@*****.**", password="******" ) self.test_user2 = User( name="User2", login="******", email="*****@*****.**", password="******" ) self.test_user3 = User( name="User3", login="******", email="*****@*****.**", password="******" ) self.test_user4 = User( name="User4", login="******", email="*****@*****.**", password="******" ) self.test_user5 = User( name="User5", login="******", email="*****@*****.**", password="******" ) self.test_project = Project( name="Test Project1", code='tp1', type=self.test_movie_project_type, status_list=self.test_project_status_list, repository=self.test_repository ) self.kwargs = { 'project': self.test_project, 'name': 'Test Budget 1' } self.test_budget = Budget(**self.kwargs) self.test_good = Good( name='Some Good', cost=100, msrp=120, unit='$' )
def setUp(self): """run once """ defaults.timing_resolution = datetime.timedelta(hours=1) # create a new session db.setup({ 'sqlalchemy.url': 'sqlite://', 'sqlalchemy.echo': False }) db.init() 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() self.status_new = Status.query.filter_by(code='NEW').first() self.status_app = Status.query.filter_by(code='APP').first() self.budget_status_list = StatusList( name='Budget Statuses', target_entity_type='Budget', statuses=[self.status_new, self.status_prev, self.status_app] ) db.DBSession.add(self.budget_status_list) self.task_status_list = StatusList.query\ .filter_by(target_entity_type='Task').first() self.test_project_status_list = StatusList( name="Project Statuses", statuses=[self.status_wip, self.status_prev, self.status_cmpl], target_entity_type=Project, ) self.test_movie_project_type = Type( name="Movie Project", code='movie', target_entity_type=Project, ) self.test_repository_type = Type( name="Test Repository Type", code='test', target_entity_type=Repository, ) self.test_repository = Repository( name="Test Repository", type=self.test_repository_type, linux_path=tempfile.mkdtemp(), windows_path=tempfile.mkdtemp(), osx_path=tempfile.mkdtemp() ) self.test_user1 = User( name="User1", login="******", email="*****@*****.**", password="******" ) self.test_user2 = User( name="User2", login="******", email="*****@*****.**", password="******" ) self.test_user3 = User( name="User3", login="******", email="*****@*****.**", password="******" ) self.test_user4 = User( name="User4", login="******", email="*****@*****.**", password="******" ) self.test_user5 = User( name="User5", login="******", email="*****@*****.**", password="******" ) self.test_project = Project( name="Test Project1", code='tp1', type=self.test_movie_project_type, status_list=self.test_project_status_list, repository=self.test_repository ) self.kwargs = { 'project': self.test_project, 'name': 'Test Budget 1' } self.test_budget = Budget(**self.kwargs) self.test_good = Good( name='Some Good', cost=100, msrp=120, unit='$' )
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 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', lead=self.user1, 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] ) DBSession.add(self.task1) self.task2 = Task( name='Test Task 2', project=self.project ) DBSession.add(self.task2) self.task3 = Task( name='Test Task 3', parent=self.task2, resources=[self.user1] ) DBSession.add(self.task3) self.kwargs = { 'task': self.task1, 'reviewer': self.user1 } #self.review = Review(**self.kwargs) #DBSession.add(self.review) # add everything to the db DBSession.commit()
def setUp(self): """setup the test """ db.setup() db.init() # users self.test_user1 = User( name='User1', login='******', password='******', email='*****@*****.**' ) self.test_user2 = User( name='User2', login='******', password='******', email='*****@*****.**' ) # statuses self.status_wip = Status.query.filter_by(code='WIP').first() self.status_cmpl = Status.query.filter_by(code='CMPL').first() # status lists self.project_status_list = StatusList( name="Project Status List", target_entity_type=Project, statuses=[ self.status_cmpl, self.status_wip ] ) 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() # types self.commercial_project_type = Type( name="Commercial Project", code='commproj', target_entity_type=Project, ) self.asset_type1 = Type( name="Character", code='char', target_entity_type=Asset ) self.asset_type2 = Type( name="Environment", code='env', target_entity_type=Asset ) self.repository_type = Type( name="Test Repository Type", code='testrepo', target_entity_type=Repository, ) # repository self.repository = Repository( name="Test Repository", type=self.repository_type, ) # project self.project1 = Project( name="Test Project1", code='tp1', type=self.commercial_project_type, status_list=self.project_status_list, repositories=[self.repository], ) # sequence self.seq1 = Sequence( name="Test Sequence", code='tseq', project=self.project1, status_list=self.sequence_status_list, responsible=[self.test_user1] ) # shots self.shot1 = Shot( code="TestSH001", status_list=self.shot_status_list, project=self.project1, sequences=[self.seq1], responsible=[self.test_user1] ) self.shot2 = Shot( code="TestSH002", status_list=self.shot_status_list, project=self.project1, sequences=[self.seq1], responsible=[self.test_user1] ) self.shot3 = Shot( code="TestSH003", status_list=self.shot_status_list, project=self.project1, sequences=[self.seq1], responsible=[self.test_user1] ) self.shot4 = Shot( code="TestSH004", status_list=self.shot_status_list, project=self.project1, sequences=[self.seq1], responsible=[self.test_user1] ) self.kwargs = { "name": "Test Asset", 'code': 'ta', "description": "This is a test Asset object", "project": self.project1, "type": self.asset_type1, "status": 0, "status_list": self.asset_status_list, 'responsible': [self.test_user1] } self.asset1 = Asset(**self.kwargs) # tasks self.task1 = Task( name="Task1", parent=self.asset1, status_list=self.task_status_list ) self.task2 = Task( name="Task2", parent=self.asset1, status_list=self.task_status_list ) self.task3 = Task( name="Task3", parent=self.asset1, status_list=self.task_status_list )
def setUp(self): """set up the test """ # create an in memory database from stalker import db db.setup() db.init() 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() # create a resource self.test_resource1 = User( name="User1", login="******", email="*****@*****.**", password="******", ) self.test_resource2 = User( name="User2", login="******", email="*****@*****.**", password="******" ) self.test_repo = Repository(name="test repository") # create a Project self.test_status1 = Status(name="Status1", code="STS1") self.test_status2 = Status(name="Status2", code="STS2") self.test_status3 = Status(name="Status3", code="STS3") self.test_project_status_list = StatusList( name="Project Statuses", statuses=[self.test_status1], target_entity_type=Project ) self.test_task_status_list = StatusList.query\ .filter_by(target_entity_type='Task').first() self.test_project = Project( name="test project", code='tp', repository=self.test_repo, status_list=self.test_project_status_list ) # create a Task self.test_task = Task( name="test task", project=self.test_project, status_list=self.test_task_status_list, schedule_timing=10, schedule_unit='d', resources=[self.test_resource1] ) self.kwargs = { "name": "test time_log", "task": self.test_task, "resource": self.test_resource1, "start": datetime.datetime(2013, 3, 22, 1, 0), "duration": datetime.timedelta(10) }
def setUp(self): """setup the test """ self.config = testing.setUp() db.setup({'sqlalchemy.url': 'sqlite:///:memory:'}) db.init() DBSession.remove() # test users self.user1 = User( name='Test User 1', login='******', email='*****@*****.**', password='******' ) DBSession.add(self.user1) # create a couple of tasks self.status_new = Status(name='New', code='NEW') self.status_rts = Status(name='Ready To Start', code='RTS') self.status_wip = Status(name='Work In Progress', code='WIP') self.status_prev = Status(name='Pending Review', code='PREV') self.status_hrev = Status(name='Has Revisions', code='HREV') self.status_cmpl = Status(name='Complete', code='CMPL') self.project_status_list = StatusList( name='Project Statuses', target_entity_type='Project', statuses=[self.status_new, self.status_wip, self.status_cmpl] ) DBSession.add(self.project_status_list) self.task_status_list = StatusList( name='Task Statuses', target_entity_type='Task', statuses=[self.status_new, self.status_rts, self.status_wip, self.status_prev, self.status_hrev, self.status_cmpl] ) DBSession.add(self.task_status_list) # repo self.repo = Repository( name='Test Repository' ) DBSession.add(self.repo) # proj1 self.proj1 = Project( name='Test Project', code='TProj1', status_list=self.project_status_list, repository=self.repo, lead=self.user1 ) DBSession.add(self.proj1) # tasks self.task1 = Task( name='Test Task 1', project=self.proj1, status_list=self.task_status_list, status=self.status_new, resources=[self.user1], schedule_timing=5, schedule_unit='d', schedule_model='effort' ) DBSession.add(self.task1) transaction.commit()