Exemplo n.º 1
0
    def test_updating_a_repository_will_update_repo_path(self):
        """testing if the environment variable will be updated when the
        repository path is updated
        """
        from stalker import db, defaults
        db.setup({'sqlalchemy.url': 'sqlite:///:memory:'})

        repo = Repository(name='Test Repo',
                          linux_path='/mnt/T',
                          osx_path='/Volumes/T',
                          windows_path='T:/')
        db.DBSession.add(repo)
        db.DBSession.commit()

        import os
        self.assertTrue(defaults.repo_env_var_template %
                        {'id': repo.id} in os.environ)

        # now update the repository
        test_value = '/mnt/S/'
        repo.path = test_value

        # expect the environment variable is also updated
        self.assertEqual(
            os.environ[defaults.repo_env_var_template % {
                'id': repo.id
            }], test_value)
Exemplo n.º 2
0
    def setUp(self):
        """setup the test
        """
        super(RepositoryTester, self).setUp()
        self.patcher = PlatformPatcher()

        # create a couple of test tags
        from stalker import Tag
        self.test_tag1 = Tag(name="test tag 1")
        self.test_tag2 = Tag(name="test tag 2")

        self.kwargs = {
            "name": "a repository",
            "description": "this is for testing purposes",
            "tags": [self.test_tag1, self.test_tag2],
            "linux_path": "/mnt/M/Projects",
            "osx_path": "/Volumes/M/Projects",
            "windows_path": "M:/Projects"
        }

        from stalker import Repository
        from stalker.db.session import DBSession
        self.test_repo = Repository(**self.kwargs)
        DBSession.add(self.test_repo)
        DBSession.commit()
Exemplo n.º 3
0
    def setUp(self):
        """create test data
        """
        super(RepositoryViewsFunctionalTestCase, self).setUp()

        from stalker import db, Repository
        self.test_repo1 = Repository(name='Test Repo 1',
                                     windows_path='T:/Projects/',
                                     linux_path='/mnt/T/Projects/',
                                     osx_path='/Volumes/T/Project/',
                                     created_by=self.admin)
        db.DBSession.add(self.test_repo1)

        self.test_repo2 = Repository(name='Test Repo 2',
                                     windows_path='T:/Projects/',
                                     linux_path='/mnt/T/Projects/',
                                     osx_path='/Volumes/T/Project/',
                                     created_by=self.admin)
        db.DBSession.add(self.test_repo2)

        self.test_repo3 = Repository(name='Test Repo 3',
                                     windows_path='T:/Projects/',
                                     linux_path='/mnt/T/Projects/',
                                     osx_path='/Volumes/T/Project/',
                                     created_by=self.admin)
        db.DBSession.add(self.test_repo3)

        db.DBSession.commit()
Exemplo n.º 4
0
    def test_updating_linux_path_only_update_repo_path_if_on_linux(self):
        """testing if updating the linux path will only update the path if the
        system is linux
        """
        self.patcher.patch('Darwin')

        from stalker import db, defaults
        db.setup({'sqlalchemy.url': 'sqlite:///:memory:'})

        repo = Repository(name='Test Repo',
                          linux_path='/mnt/T',
                          osx_path='/Volumes/T',
                          windows_path='T:/')
        db.DBSession.add(repo)
        db.DBSession.commit()

        import os
        self.assertTrue(defaults.repo_env_var_template %
                        {'id': repo.id} in os.environ)

        # now update the repository
        test_value = '/mnt/S/'
        repo.linux_path = test_value

        # expect the environment variable not updated
        self.assertNotEqual(
            os.environ[defaults.repo_env_var_template % {
                'id': repo.id
            }], test_value)
        self.assertEqual(
            os.environ[defaults.repo_env_var_template % {
                'id': repo.id
            }], repo.osx_path)

        # make it linux
        self.patcher.patch('Linux')

        # now update the repository
        test_value = '/mnt/S/'
        repo.linux_path = test_value

        # expect the environment variable not updated
        self.assertEqual(
            os.environ[defaults.repo_env_var_template % {
                'id': repo.id
            }], test_value)
        self.assertEqual(
            os.environ[defaults.repo_env_var_template % {
                'id': repo.id
            }], repo.linux_path)
Exemplo n.º 5
0
def upload_thumbnail(task, thumbnail_full_path):
    """Uploads the given thumbnail for the given entity

    :param task: An instance of :class:`~stalker.models.entity.SimpleEntity`
      or a derivative.

    :param str thumbnail_full_path: A string which is showing the path
      of the thumbnail image
    """
    extension = os.path.splitext(thumbnail_full_path)[-1]

    # move the file to the task thumbnail folder
    # and mimic StalkerPyramids output format
    thumbnail_original_file_name = 'thumbnail%s' % extension
    thumbnail_final_full_path = os.path.join(
        task.absolute_path, 'Thumbnail', thumbnail_original_file_name
    )

    try:
        os.makedirs(os.path.dirname(thumbnail_final_full_path))
    except OSError:
        pass

    # # convert the thumbnail to jpg if it is a format that is not supported by
    # # browsers
    # ext_not_supported_by_browsers = ['.bmp', '.tga', '.tif', '.tiff', '.exr']
    # if extension in ext_not_supported_by_browsers:
    #     # use MediaManager to convert them
    #     from anima.utils import MediaManager
    #     mm = MediaManager()
    #     thumbnail_full_path = mm.generate_image_thumbnail(thumbnail_full_path)

    shutil.copy(thumbnail_full_path, thumbnail_final_full_path)

    from stalker import Link, Version, Repository

    thumbnail_os_independent_path = \
        Repository.to_os_independent_path(thumbnail_final_full_path)
    l_thumb = Link.query\
        .filter(Link.full_path == thumbnail_os_independent_path).first()

    if not l_thumb:
        l_thumb = Link(
            full_path=thumbnail_os_independent_path,
            original_filename=thumbnail_original_file_name
        )

    task.thumbnail = l_thumb

    # get a version of this Task
    from stalker.db.session import DBSession
    v = Version.query.filter(Version.task == task).first()
    if v:
        for naming_parent in v.naming_parents:
            if not naming_parent.thumbnail:
                naming_parent.thumbnail = l_thumb
                DBSession.add(naming_parent)

    DBSession.add(l_thumb)
    DBSession.commit()
Exemplo n.º 6
0
    def accept(self):
        """overridden accept method
        """
        if not self.name_lineEdit.is_valid:
            QtWidgets.QMessageBox.critical(
                self,
                'Error',
                'Please fix <b>name</b> field!'
            )
            return
        name = self.name_lineEdit.text()

        windows_path = self.windows_path_lineEdit.text()
        linux_path = self.linux_path_lineEdit.text()
        osx_path = self.osx_path_lineEdit.text()

        from stalker import Repository
        from stalker.db.session import DBSession
        logged_in_user = self.get_logged_in_user()
        if self.mode == 'Create':
            # Create a new Repository
            try:
                repo = Repository(
                    name=name,
                    windows_path=windows_path,
                    linux_path=linux_path,
                    osx_path=osx_path
                )
                self.repository = repo
                DBSession.add(repo)
                DBSession.commit()
            except Exception as e:
                DBSession.rollback()
                QtWidgets.QMessageBox.critical(
                    self,
                    'Error',
                    str(e)
                )
                return

        elif self.mode == 'Update':
            # Update the repository
            try:
                self.repository.name = name
                self.repository.windows_path = windows_path
                self.repository.linux_path = linux_path
                self.repository.osx_path = osx_path
                self.repository.updated_by = logged_in_user
                DBSession.add(self.repository)
                DBSession.commit()
            except Exception as e:
                DBSession.rollback()
                QtWidgets.QMessageBox.critical(
                    self,
                    'Error',
                    str(e)
                )
                return

        super(MainDialog, self).accept()
Exemplo n.º 7
0
    def setUp(self):
        """setup the test
        """
        super(SequenceTester, self).setUp()

        # create a test project, user and a couple of shots
        from stalker import Type
        self.project_type = Type(
            name="Test Project Type",
            code='test',
            target_entity_type='Project',
        )
        from stalker.db.session import DBSession
        DBSession.add(self.project_type)

        # create a repository
        self.repository_type = Type(
            name="Test Type",
            code='test',
            target_entity_type='Repository'
        )
        DBSession.add(self.repository_type)

        from stalker import Repository
        self.test_repository = Repository(
            name="Test Repository",
            type=self.repository_type,
        )
        DBSession.add(self.test_repository)

        # create projects
        from stalker import Project
        self.test_project = Project(
            name="Test Project 1",
            code='tp1',
            type=self.project_type,
            repository=self.test_repository,
        )
        DBSession.add(self.test_project)

        self.test_project2 = Project(
            name="Test Project 2",
            code='tp2',
            type=self.project_type,
            repository=self.test_repository,
        )
        DBSession.add(self.test_project2)

        # the parameters
        self.kwargs = {
            "name": "Test Sequence",
            'code': 'tseq',
            "description": "A test sequence",
            "project": self.test_project,
        }

        # the test sequence
        from stalker import Sequence
        self.test_sequence = Sequence(**self.kwargs)
        DBSession.commit()
Exemplo n.º 8
0
    def get_version_from_full_path(cls, full_path):
        """Finds the Version instance from the given full_path value.

        Finds and returns a :class:`~stalker.models.version.Version` instance
        from the given full_path value.

        Returns None if it can't find any matching.

        :param full_path: The full_path of the desired
            :class:`~stalker.models.version.Version` instance.

        :return: :class:`~stalker.models.version.Version`
        """
        logger.debug('full_path: %s' % full_path)
        # convert '\\' to '/'
        full_path = os.path.normpath(
            os.path.expandvars(full_path)
        ).replace('\\', '/')

        # trim repo path
        from stalker import Repository, Version
        os_independent_path = Repository.to_os_independent_path(full_path)

        # try to get a version with that info
        logger.debug('getting a version with path: %s' % full_path)

        version = Version.query\
            .filter(Version.full_path == os_independent_path).first()
        logger.debug('version: %s' % version)
        return version
Exemplo n.º 9
0
    def setUp(self):
        """set the test up
        """
        from stalker import Status, StatusList, Repository
        self.test_repo = Repository(name='Test Repo')
        self.status_new = Status(name='New', code='NEW')
        self.status_wip = Status(name='Work In Progress', code='WIP')
        self.status_cmpl = Status(name='Completed', code='CMPL')

        self.project_statuses = StatusList(
            name='Project Status List',
            statuses=[self.status_new, self.status_wip, self.status_cmpl],
            target_entity_type='Project')

        from stalker import User
        self.test_user1 = User(name='Test User 1',
                               login='******',
                               email='*****@*****.**',
                               password='******')

        from stalker import Project
        self.test_project = Project(name='Test Project 1',
                                    code='TP1',
                                    repositories=[self.test_repo],
                                    status_list=self.project_statuses)

        from stalker import Role
        self.test_role = Role(name='Test User')
Exemplo n.º 10
0
    def bind_to_original(cls):
        """binds the current scene references to original references from the
        repository
        """
        # get all reference paths
        import os
        from anima.env import mayaEnv
        from stalker import Repository, Version, Task
        m = mayaEnv.Maya()
        current_version = m.get_current_version()

        # get the current project
        project = None
        if current_version:
            project = current_version.task.project

        # no project then do nothing
        if project:
            for ref in pm.listReferences():
                unresolved_path = ref.unresolvedPath()
                filename = os.path.basename(unresolved_path)
                # find the corresponding version
                v = Version.query\
                    .join(Version.task, Task.versions)\
                    .filter(Task.project == project)\
                    .filter(Version.full_path.endswith(filename)).first()
                if v:
                    ref.replaceWith(
                        Repository.to_os_independent_path(
                            v.absolute_full_path
                        )
                    )
Exemplo n.º 11
0
    def get_version_from_full_path(cls, full_path):
        """Finds the Version instance from the given full_path value.

        Finds and returns a :class:`~stalker.models.version.Version` instance
        from the given full_path value.

        Returns None if it can't find any matching.

        :param full_path: The full_path of the desired
            :class:`~stalker.models.version.Version` instance.

        :return: :class:`~stalker.models.version.Version`
        """
        logger.debug('full_path: %s' % full_path)
        # convert '\\' to '/'
        full_path = os.path.normpath(
            os.path.expandvars(full_path)
        ).replace('\\', '/')

        # trim repo path
        from stalker import Repository, Version
        os_independent_path = Repository.to_os_independent_path(full_path)

        # try to get a version with that info
        logger.debug('getting a version with path: %s' % full_path)

        version = Version.query\
            .filter(Version.full_path == os_independent_path).first()
        logger.debug('version: %s' % version)
        return version
Exemplo n.º 12
0
    def setUp(self):
        """set the test up
        """
        super(ProjectUserTestDBCase, self).setUp()

        from stalker import Repository
        self.test_repo = Repository(name='Test Repo')

        from stalker.db.session import DBSession
        DBSession.add(self.test_repo)
        DBSession.commit()

        from stalker import User
        self.test_user1 = User(name='Test User 1',
                               login='******',
                               email='*****@*****.**',
                               password='******')
        DBSession.add(self.test_user1)

        from stalker import Project
        self.test_project = Project(
            name='Test Project 1',
            code='TP1',
            repositories=[self.test_repo],
        )
        DBSession.add(self.test_project)

        from stalker import Role
        self.test_role = Role(name='Test User')
        DBSession.add(self.test_role)
        DBSession.commit()
Exemplo n.º 13
0
    def setUp(self):
        """set the test up
        """
        super(ProjectClientTestDBCase, self).setUp()

        from stalker import Status, Repository
        self.test_repo = Repository(name='Test Repo')
        self.status_new = Status(name='New', code='NEW')
        self.status_wip = Status(name='Work In Progress', code='WIP')
        self.status_cmpl = Status(name='Completed', code='CMPL')

        from stalker import User
        self.test_user1 = User(name='Test User 1',
                               login='******',
                               email='*****@*****.**',
                               password='******')

        from stalker import Client
        self.test_client = Client(name='Test Client')

        from stalker import Project
        self.test_project = Project(
            name='Test Project 1',
            code='TP1',
            repositories=[self.test_repo],
        )

        from stalker import Role
        self.test_role = Role(name='Test Client')
Exemplo n.º 14
0
    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()
Exemplo n.º 15
0
    def setUp(self):
        """setting up the test
        """
        super(PageTester, self).setUp()

        # create a repository
        from stalker import Type
        self.repository_type = Type(name="Test Repository Type",
                                    code='test_repo',
                                    target_entity_type='Repository')

        from stalker import Repository
        self.test_repository = Repository(
            name="Test Repository",
            code="TR",
            type=self.repository_type,
        )

        # statuses
        from stalker import Status
        self.status1 = Status(name="Status1", code="STS1")
        self.status2 = Status(name="Status2", code="STS2")
        self.status3 = Status(name="Status3", code="STS3")

        # project status list
        from stalker import StatusList
        self.project_status_list = StatusList(name="Project Status List",
                                              statuses=[
                                                  self.status1,
                                                  self.status2,
                                                  self.status3,
                                              ],
                                              target_entity_type='Project')

        # project type
        self.test_project_type = Type(
            name="Test Project Type",
            code='testproj',
            target_entity_type='Project',
        )

        # create projects
        from stalker import Project
        self.test_project1 = Project(
            name="Test Project 1",
            code='tp1',
            type=self.test_project_type,
            status_list=self.project_status_list,
            repository=self.test_repository,
        )

        self.kwargs = {
            'title': 'Test Page Title',
            'content': 'Test content',
            'project': self.test_project1
        }

        self.test_page = Page(**self.kwargs)
Exemplo n.º 16
0
    def setUp(self):
        """setup the test
        """

        # create a repository
        self.repository_type = Type(name="Test Repository Type",
                                    code='testproj',
                                    target_entity_type=Repository)

        self.test_repository = Repository(
            name="Test Repository",
            type=self.repository_type,
        )

        # statuses
        self.status1 = Status(name="Status1", code="STS1")
        self.status2 = Status(name="Status2", code="STS2")
        self.status3 = Status(name="Status3", code="STS3")

        # project status list
        self.project_status_list = StatusList(name="Project Status List",
                                              statuses=[
                                                  self.status1,
                                                  self.status2,
                                                  self.status3,
                                              ],
                                              target_entity_type=Project)

        # project type
        self.test_project_type = Type(
            name="Test Project Type",
            code='testproj',
            target_entity_type=Project,
        )

        # create projects
        self.test_project1 = Project(
            name="Test Project 1",
            code='tp1',
            type=self.test_project_type,
            status_list=self.project_status_list,
            repository=self.test_repository,
        )

        self.test_project2 = Project(
            name="Test Project 2",
            code='tp2',
            type=self.test_project_type,
            status_list=self.project_status_list,
            repository=self.test_repository,
        )

        self.kwargs = {
            "name": "Test Class",
            "project": self.test_project1,
        }

        self.test_foo_obj = ProjMixClass(**self.kwargs)
Exemplo n.º 17
0
    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)
Exemplo n.º 18
0
    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()
Exemplo n.º 19
0
    def setUp(self):
        """setup the test
        """
        # 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
        )

        self.kwargs = {
            "task": self.test_task,
            "resource": self.test_resource1,
            "start": datetime.datetime(2013, 3, 22, 1, 0),
            "duration": datetime.timedelta(10)
        }

        # create a TimeLog
        # and test it
        self.test_time_log = TimeLog(**self.kwargs)
Exemplo n.º 20
0
def upload_thumbnail(task, thumbnail_full_path):
    """Uploads the given thumbnail for the given entity

    :param task: An instance of :class:`~stalker.models.entity.SimpleEntity`
      or a derivative.

    :param str thumbnail_full_path: A string which is showing the path
      of the thumbnail image
    """
    extension = os.path.splitext(thumbnail_full_path)[-1]

    # move the file to the task thumbnail folder
    # and mimic StalkerPyramids output format
    thumbnail_original_file_name = 'thumbnail%s' % extension
    thumbnail_final_full_path = os.path.join(task.absolute_path, 'Thumbnail',
                                             thumbnail_original_file_name)

    try:
        os.makedirs(os.path.dirname(thumbnail_final_full_path))
    except OSError:
        pass

    # # convert the thumbnail to jpg if it is a format that is not supported by
    # # browsers
    # ext_not_supported_by_browsers = ['.bmp', '.tga', '.tif', '.tiff', '.exr']
    # if extension in ext_not_supported_by_browsers:
    #     # use MediaManager to convert them
    #     from anima.utils import MediaManager
    #     mm = MediaManager()
    #     thumbnail_full_path = mm.generate_image_thumbnail(thumbnail_full_path)

    import shutil
    shutil.copy(thumbnail_full_path, thumbnail_final_full_path)

    from stalker import Link, Version, Repository

    thumbnail_os_independent_path = \
        Repository.to_os_independent_path(thumbnail_final_full_path)
    l_thumb = Link.query\
        .filter(Link.full_path == thumbnail_os_independent_path).first()

    if not l_thumb:
        l_thumb = Link(full_path=thumbnail_os_independent_path,
                       original_filename=thumbnail_original_file_name)

    task.thumbnail = l_thumb

    # get a version of this Task
    from stalker.db.session import DBSession
    v = Version.query.filter(Version.task == task).first()
    if v:
        for naming_parent in v.naming_parents:
            if not naming_parent.thumbnail:
                naming_parent.thumbnail = l_thumb
                DBSession.add(naming_parent)

    DBSession.add(l_thumb)
    DBSession.commit()
Exemplo n.º 21
0
 def test_windows_path_argument_accepts_only_strings(self):
     """testing if windows_path argument accepts only string values
     """
     from stalker import Repository
     test_values = [123123, 123.1231, [], {}]
     for test_value in test_values:
         self.kwargs["windows_path"] = test_value
         with pytest.raises(TypeError):
             Repository(**self.kwargs)
Exemplo n.º 22
0
    def test_inequality(self):
        """testing the inequality of two repositories
        """
        repo1 = Repository(**self.kwargs)
        repo2 = Repository(**self.kwargs)

        self.kwargs.update({
            "name": "a repository",
            "description": "this is the commercial repository",
            "linux_path": "/mnt/commercialServer/Projects",
            "osx_path": "/Volumes/commercialServer/Projects",
            "windows_path": "Z:\\Projects"
        })

        repo3 = Repository(**self.kwargs)

        self.assertFalse(repo1 != repo2)
        self.assertTrue(repo1 != repo3)
Exemplo n.º 23
0
    def find_repo(cls, path):
        """returns the repository from the given path

        :param str path: path in a repository
        :return: stalker.models.repository.Repository
        """
        # first find the repository
        from stalker import Repository
        return Repository.find_repo(path)
Exemplo n.º 24
0
    def test_updating_linux_path_only_update_repo_path_if_on_linux(self):
        """testing if updating the linux path will only update the path if the
        system is linux
        """
        self.patcher.patch('Darwin')

        from stalker import defaults, Repository
        repo = Repository(name='Test Repo',
                          linux_path='/mnt/T',
                          osx_path='/Volumes/T',
                          windows_path='T:/')
        from stalker.db.session import DBSession
        DBSession.add(repo)
        DBSession.commit()

        import os
        assert defaults.repo_env_var_template % {'id': repo.id} in os.environ

        # now update the repository
        test_value = '/mnt/S/'
        repo.linux_path = test_value

        # expect the environment variable not updated
        assert \
            os.environ[defaults.repo_env_var_template % {'id': repo.id}] != \
            test_value
        assert \
            os.environ[defaults.repo_env_var_template % {'id': repo.id}] == \
            repo.osx_path

        # make it linux
        self.patcher.patch('Linux')

        # now update the repository
        test_value = '/mnt/S/'
        repo.linux_path = test_value

        # expect the environment variable not updated
        assert \
            os.environ[defaults.repo_env_var_template % {'id': repo.id}] == \
            test_value
        assert \
            os.environ[defaults.repo_env_var_template % {'id': repo.id}] == \
            repo.linux_path
Exemplo n.º 25
0
    def test_osx_path_argument_accepts_only_strings(self):
        """testing if osx_path argument accepts only string values
        """
        from stalker import Repository
        self.kwargs["osx_path"] = 123123
        with pytest.raises(TypeError) as cm:
            Repository(**self.kwargs)

        assert str(cm.value) == \
            'Repository.osx_path should be an instance of string not int'
Exemplo n.º 26
0
    def test_osx_path_argument_backward_slashes_are_converted_to_forward_slashes(
            self):
        """testing if the backward slashes are converted to forward slashes
        in the osx_path argument
        """
        self.kwargs["osx_path"] = r"\Volumes\M\Projects"
        new_repo = Repository(**self.kwargs)

        self.assertFalse("\\" in new_repo.linux_path)
        self.assertEqual(new_repo.osx_path, "/Volumes/M/Projects/")
Exemplo n.º 27
0
    def test_windows_path_argument_backward_slashes_are_converted_to_forward_slashes(
            self):
        """testing if the backward slashes are converted to forward slashes
        in the windows_path argument
        """
        self.kwargs["windows_path"] = r"M:\Projects"
        new_repo = Repository(**self.kwargs)

        self.assertFalse("\\" in new_repo.linux_path)
        self.assertEqual(new_repo.windows_path, "M:/Projects/")
Exemplo n.º 28
0
    def setUp(self):
        """setup the test
        """
        self.patcher = PlatformPatcher()

        # create a couple of test tags
        self.test_tag1 = Tag(name="test tag 1")
        self.test_tag2 = Tag(name="test tag 2")

        self.kwargs = {
            "name": "a repository",
            "description": "this is for testing purposes",
            "tags": [self.test_tag1, self.test_tag2],
            "linux_path": "/mnt/M/Projects",
            "osx_path": "/Volumes/M/Projects",
            "windows_path": "M:/Projects"
        }

        self.test_repo = Repository(**self.kwargs)
Exemplo n.º 29
0
    def test_equality(self):
        """testing the equality of two repositories
        """
        from stalker import Repository
        repo1 = Repository(**self.kwargs)
        repo2 = Repository(**self.kwargs)

        self.kwargs.update({
            "name": "a repository",
            "description": "this is the commercial repository",
            "linux_path": "/mnt/commercialServer/Projects",
            "osx_path": "/Volumes/commercialServer/Projects",
            "windows_path": "Z:\\Projects"
        })

        repo3 = Repository(**self.kwargs)

        assert repo1 == repo2
        assert not repo1 == repo3
Exemplo n.º 30
0
    def test_osx_path_argument_backward_slashes_are_converted_to_forward_slashes(
            self):
        """testing if the backward slashes are converted to forward slashes
        in the osx_path argument
        """
        from stalker import Repository
        self.kwargs["osx_path"] = r"\Volumes\M\Projects"
        new_repo = Repository(**self.kwargs)

        assert "\\" not in new_repo.linux_path
        assert new_repo.osx_path == "/Volumes/M/Projects/"
Exemplo n.º 31
0
    def test_windows_path_argument_backward_slashes_are_converted_to_forward_slashes(
            self):
        """testing if the backward slashes are converted to forward slashes
        in the windows_path argument
        """
        from stalker import Repository
        self.kwargs["windows_path"] = r"M:\Projects"
        new_repo = Repository(**self.kwargs)

        assert "\\" not in new_repo.linux_path
        assert new_repo.windows_path == "M:/Projects/"
Exemplo n.º 32
0
    def test_find_repo_is_working_properly(self):
        """testing if the find_repo class method is working properly
        """
        from stalker.db.session import DBSession
        DBSession.add(self.test_repo)
        DBSession.commit()

        # add some other repositories
        from stalker import Repository
        new_repo1 = Repository(name='New Repository',
                               linux_path='/mnt/T/Projects',
                               osx_path='/Volumes/T/Projects',
                               windows_path='T:/Projects')
        DBSession.add(new_repo1)
        DBSession.commit()

        test_path = '%s/some/path/to/a/file.ma' % self.test_repo.path
        assert Repository.find_repo(test_path) == self.test_repo

        test_path = '%s/some/path/to/a/file.ma' % new_repo1.windows_path
        assert Repository.find_repo(test_path) == new_repo1
Exemplo n.º 33
0
    def to_repr(self, repr_name):
        """Replaces the current reference with the representation with the
        given repr_name.

        :param str repr_name: The desired repr name
        :return:
        """
        rep_v = self.find_repr(repr_name)
        from stalker import Repository
        if rep_v is not None and rep_v != self.version:
            self.replaceWith(
                Repository.to_os_independent_path(rep_v.absolute_full_path)
            )
Exemplo n.º 34
0
def upload_thumbnail(task, thumbnail_full_path):
    """Uploads the given thumbnail for the given entity

    :param task: An instance of :class:`~stalker.models.entity.SimpleEntity`
      or a derivative.

    :param str thumbnail_full_path: A string which is showing the path
      of the thumbnail image
    """
    extension = os.path.splitext(thumbnail_full_path)[-1]

    # move the file to the task thumbnail folder
    # and mimic StalkerPyramids output format
    thumbnail_original_file_name = 'thumbnail%s' % extension
    thumbnail_final_full_path = os.path.join(
        task.absolute_path, 'Thumbnail', thumbnail_original_file_name
    )

    try:
        os.makedirs(os.path.dirname(thumbnail_final_full_path))
    except OSError:
        pass

    shutil.copy(thumbnail_full_path, thumbnail_final_full_path)

    from stalker import db, Link, Version, Repository

    thumbnail_os_independent_path = \
        Repository.to_os_independent_path(thumbnail_final_full_path)
    l_thumb = Link.query\
        .filter(Link.full_path == thumbnail_os_independent_path).first()

    if not l_thumb:
        l_thumb = Link(
            full_path=thumbnail_os_independent_path,
            original_filename=thumbnail_original_file_name
        )

    task.thumbnail = l_thumb

    # get a version of this Task
    v = Version.query.filter(Version.task == task).first()
    if v:
        for naming_parent in v.naming_parents:
            if not naming_parent.thumbnail:
                naming_parent.thumbnail = l_thumb
                db.DBSession.add(naming_parent)

    db.DBSession.add(l_thumb)
    db.DBSession.commit()
Exemplo n.º 35
0
    def setUp(self):
        """setup the test
        """
        # create a couple of test tags
        self.test_tag1 = Tag(name="test tag 1")
        self.test_tag2 = Tag(name="test tag 2")

        self.kwargs = {
            "name": "a repository",
            "description": "this is for testing purposes",
            "tags": [self.test_tag1, self.test_tag2],
            "linux_path": "/mnt/M/Projects",
            "osx_path": "/Volumes/M/Projects",
            "windows_path": "M:/Projects"
        }

        self.test_repo = Repository(**self.kwargs)
Exemplo n.º 36
0
    def test_to_os_independent_path_is_working_properly(self):
        """testing if stalker.Repository.to_os_independent_path() is working
        as we are expecting it to work
        """
        # repo4
        linux_path = '/test/repo/4/linux/path/PRJ1/Assets/test.ma'
        windows_path = 'T:/test/repo/4/windows/path/PRJ1/Assets/test.ma'
        osx_path = '/test/repo/4/osx/path/PRJ1/Assets/test.ma'

        os_independent_path = '$REPO%s/PRJ1/Assets/test.ma' % self.repo4.id

        self.assertEqual(
            Repository.to_os_independent_path(linux_path),
            os_independent_path
        )

        self.assertEqual(
            Repository.to_os_independent_path(windows_path),
            os_independent_path
        )

        self.assertEqual(
            Repository.to_os_independent_path(osx_path),
            os_independent_path
        )

        # repo5
        linux_path = '/test/repo/5/linux/path/PRJ1/Assets/test.ma'
        windows_path = 'T:/test/repo/5/windows/path/PRJ1/Assets/test.ma'
        osx_path = '/test/repo/5/osx/path/PRJ1/Assets/test.ma'

        os_independent_path = '$REPO%s/PRJ1/Assets/test.ma' % self.repo5.id

        self.assertEqual(
            Repository.to_os_independent_path(linux_path),
            os_independent_path
        )

        self.assertEqual(
            Repository.to_os_independent_path(windows_path),
            os_independent_path
        )

        self.assertEqual(
            Repository.to_os_independent_path(osx_path),
            os_independent_path
        )
Exemplo n.º 37
0
    def get_versions_from_path(self, path):
        """Finds Version instances from the given path value.

        Finds and returns the :class:`~stalker.models.version.Version`
        instances from the given path value.

        Returns an empty list if it can't find any matching.

        This method is different than
        :meth:`~stalker.env.EnvironmentBase.get_version_from_full_path`
        because it returns a list of
        :class:`~stalker.models.version.Version` instances which are
        residing in that path. The list is ordered by the ``id``\ s of the
        instances.

        :param path: A path which has possible
            :class:`~stalker.models.version.Version` instances.

        :return: A list of :class:`~stalker.models.version.Version` instances.
        """
        if not path:
            return []

        # convert '\\' to '/'
        path = os.path.normpath(path).replace('\\', '/')
        from stalker import Repository
        os_independent_path = Repository.to_os_independent_path(path)
        logger.debug('os_independent_path: %s' % os_independent_path)

        from stalker import Version
        from stalker.db.session import DBSession

        # try to get all versions with that info
        with DBSession.no_autoflush:
            versions = Version.query.\
                filter(Version.full_path.startswith(os_independent_path)).all()

        return versions
Exemplo n.º 38
0
project_statuses = StatusList(
    name="Project Status List",
    statuses=[
        status_new,
        status_wip,
        status_cmpl
    ],
    target_entity_type=Project  # you can also use "Project" which is a str
)

from stalker import Repository

# and the repository itself
commercial_repo = Repository(
    name="Commercial Repository"
)

new_project = Project(
    name="Fancy Commercial",
    code='FC',
    status_list=project_statuses,
    repositories=[commercial_repo],
)

import datetime
from stalker import ImageFormat

new_project.description = \
"""The commercial is about this fancy product. The
client want us to have a shiny look with their
Exemplo n.º 39
0
    def generate_ass(self):
        """generates the ASS representation of the current scene

        For Model Tasks the ASS is generated over the LookDev Task because it
        is not possible to assign a material to an object inside an ASS file.
        """
        # before doing anything, check if this is a look dev task
        # and export the objects from the referenced files with their current
        # shadings, then replace all of the references to ASS repr and than
        # add Stand-in nodes and parent them under the referenced models

        # load necessary plugins
        pm.loadPlugin('mtoa')

        # disable "show plugin shapes"
        active_panel = auxiliary.Playblaster.get_active_panel()
        show_plugin_shapes = pm.modelEditor(active_panel, q=1, pluginShapes=1)
        pm.modelEditor(active_panel, e=1, pluginShapes=False)

        # validate the version first
        self.version = self._validate_version(self.version)

        self.open_version(self.version)

        task = self.version.task

        # export_command = 'arnoldExportAss -f "%(path)s" -s -mask 24 ' \
        #                  '-lightLinks 0 -compressed -boundingBox ' \
        #                  '-shadowLinks 0 -cam perspShape;'

        export_command = 'arnoldExportAss -f "%(path)s" -s -mask 60' \
                         '-lightLinks 1 -compressed -boundingBox ' \
                         '-shadowLinks 1 -cam perspShape;'

        # calculate output path
        output_path = \
            os.path.join(self.version.absolute_path, 'Outputs/ass/')\
            .replace('\\', '/')

        # check if all references have an ASS repr first
        refs_with_no_ass_repr = []
        for ref in pm.listReferences():
            if ref.version and not ref.has_repr('ASS'):
                refs_with_no_ass_repr.append(ref)

        if len(refs_with_no_ass_repr):
            raise RuntimeError(
                'Please generate the ASS Representation of the references '
                'first!!!\n%s' %
                '\n'.join(map(lambda x: str(x.path), refs_with_no_ass_repr))
            )

        if self.is_look_dev_task(task):
            # in look dev files, we export the ASS files directly from the Base
            # version and parent the resulting Stand-In node to the parent of
            # the child node

            # load only Model references
            for ref in pm.listReferences():
                v = ref.version
                load_ref = False
                if v:
                    ref_task = v.task
                    if self.is_model_task(ref_task):
                        load_ref = True

                if load_ref:
                    ref.load()
                    ref.importContents()

            # Make all texture paths relative
            # replace all "$REPO#" from all texture paths first
            #
            # This is needed to properly render textures with any OS
            types_and_attrs = {
                'aiImage': 'filename',
                'file': 'fileTextureName',
                'imagePlane': 'imageName'
            }

            for node_type in types_and_attrs.keys():
                attr_name = types_and_attrs[node_type]
                for node in pm.ls(type=node_type):
                    orig_path = node.getAttr(attr_name).replace("\\", "/")
                    path = re.sub(
                        r'(\$REPO[0-9/]+)',
                        '',
                        orig_path
                    )
                    tx_path = self.make_tx(path)
                    inputs = node.attr(attr_name).inputs(p=1)
                    if len(inputs):
                        # set the input attribute
                        for input_node_attr in inputs:
                            input_node_attr.set(tx_path)
                    else:
                        node.setAttr(attr_name, tx_path)

            # randomize all render node names
            # This is needed to prevent clashing of materials in a bigger scene
            for node in pm.ls(type=RENDER_RELATED_NODE_TYPES):
                if node.referenceFile() is None and \
                   node.name() not in READ_ONLY_NODE_NAMES:
                    node.rename('%s_%s' % (node.name(), uuid.uuid4().hex))

            nodes_to_ass_files = {}

            # export all root ass files as they are
            for root_node in auxiliary.get_root_nodes():
                for child_node in root_node.getChildren():
                    # check if it is a transform node
                    if not isinstance(child_node, pm.nt.Transform):
                        continue

                    if not auxiliary.has_shape(child_node):
                        continue

                    # randomize child node name
                    # TODO: This is not working as intended, node names are like |NS:node1|NS:node2
                    #       resulting a child_node_name as "node2"
                    child_node_name = child_node\
                        .fullPath()\
                        .replace('|', '_')\
                        .split(':')[-1]

                    child_node_full_path = child_node.fullPath()

                    pm.select(child_node)
                    child_node.rename('%s_%s' % (child_node.name(), uuid.uuid4().hex))

                    output_filename =\
                        '%s_%s.ass' % (
                            self.version.nice_name,
                            child_node_name
                        )

                    output_full_path = \
                        os.path.join(output_path, output_filename)

                    # run the mel command
                    pm.mel.eval(
                        export_command % {
                            'path': output_full_path.replace('\\', '/')
                        }
                    )
                    nodes_to_ass_files[child_node_full_path] = \
                        '%s.gz' % output_full_path
                    # print('%s -> %s' % (
                    #     child_node_full_path,
                    #     output_full_path)
                    # )

            # reload the scene
            pm.newFile(force=True)
            self.open_version(self.version)

            # convert all references to ASS
            # we are doing it a little bit early here, but we need to
            for ref in pm.listReferences():
                ref.to_repr('ASS')

            all_stand_ins = pm.ls(type='aiStandIn')
            for ass_node in all_stand_ins:
                ass_tra = ass_node.getParent()
                full_path = ass_tra.fullPath()
                if full_path in nodes_to_ass_files:
                    ass_file_path = \
                        Repository.to_os_independent_path(
                            nodes_to_ass_files[full_path]
                        )
                    ass_node.setAttr('dso', ass_file_path)

        elif self.is_vegetation_task(task):
            # in vegetation files, we export the ASS files directly from the
            # Base version, also we use the geometry under "pfxPolygons"
            # and parent the resulting Stand-In nodes to the
            # pfxPolygons
            # load all references
            for ref in pm.listReferences():
                ref.load()

            # Make all texture paths relative
            # replace all "$REPO#" from all texture paths first
            #
            # This is needed to properly render textures with any OS
            types_and_attrs = {
                'aiImage': 'filename',
                'file': 'fileTextureName',
                'imagePlane': 'imageName'
            }

            for node_type in types_and_attrs.keys():
                attr_name = types_and_attrs[node_type]
                for node in pm.ls(type=node_type):
                    orig_path = node.getAttr(attr_name).replace("\\", "/")
                    path = re.sub(
                        r'(\$REPO[0-9/]+)',
                        '',
                        orig_path
                    )
                    tx_path = self.make_tx(path)
                    inputs = node.attr(attr_name).inputs(p=1)
                    if len(inputs):
                        # set the input attribute
                        for input_node_attr in inputs:
                            input_node_attr.set(tx_path)
                    else:
                        node.setAttr(attr_name, tx_path)

            # randomize all render node names
            # This is needed to prevent clashing of materials in a bigger scene
            for node in pm.ls(type=RENDER_RELATED_NODE_TYPES):
                if node.referenceFile() is None and \
                   node.name() not in READ_ONLY_NODE_NAMES:
                    node.rename('%s_%s' % (node.name(), uuid.uuid4().hex))

            # find the _pfxPolygons node
            pfx_polygons_node = pm.PyNode('kks___vegetation_pfxPolygons')

            for node in pfx_polygons_node.getChildren():
                for child_node in node.getChildren():
                    #print('processing %s' % child_node.name())
                    child_node_name = child_node.name().split('___')[-1]

                    pm.select(child_node)
                    output_filename =\
                        '%s_%s.ass' % (
                            self.version.nice_name,
                            child_node_name.replace(':', '_').replace('|', '_')
                        )

                    output_full_path = \
                        os.path.join(output_path, output_filename)

                    # run the mel command
                    pm.mel.eval(
                        export_command % {
                            'path': output_full_path.replace('\\', '/')
                        }
                    )

                    # generate an aiStandIn node and set the path
                    ass_node = auxiliary.create_arnold_stand_in(
                        path='%s.gz' % output_full_path
                    )
                    ass_tra = ass_node.getParent()

                    # parent the ass node under the current node
                    # under pfx_polygons_node
                    pm.parent(ass_tra, node)

                    # set pivots
                    rp = pm.xform(child_node, q=1, ws=1, rp=1)
                    sp = pm.xform(child_node, q=1, ws=1, sp=1)
                    # rpt = child_node.getRotatePivotTranslation()

                    pm.xform(ass_node, ws=1, rp=rp)
                    pm.xform(ass_node, ws=1, sp=sp)
                    # ass_node.setRotatePivotTranslation(rpt)

                    # delete the child_node
                    pm.delete(child_node)

                    # give it the same name with the original
                    ass_tra.rename('%s' % child_node_name)

            # clean up other nodes
            pm.delete('kks___vegetation_pfxStrokes')
            pm.delete('kks___vegetation_paintableGeos')

        elif self.is_model_task(task):
            # convert all children of the root node
            # to an empty aiStandIn node
            # and save it as it is
            root_nodes = self.get_local_root_nodes()

            for root_node in root_nodes:
                for child_node in root_node.getChildren():
                    child_node_name = child_node.name()

                    rp = pm.xform(child_node, q=1, ws=1, rp=1)
                    sp = pm.xform(child_node, q=1, ws=1, sp=1)

                    pm.delete(child_node)

                    ass_node = auxiliary.create_arnold_stand_in(path='')
                    ass_tra = ass_node.getParent()
                    pm.parent(ass_tra, root_node)
                    ass_tra.rename(child_node_name)

                    # set pivots
                    pm.xform(ass_tra, ws=1, rp=rp)
                    pm.xform(ass_tra, ws=1, sp=sp)

                    # because there will be possible material assignments
                    # in look dev disable overrideShaders
                    ass_node.setAttr('overrideShaders', False)

                    # we definitely do not use light linking in our studio,
                    # which seems to create more problems then it solves.
                    ass_node.setAttr('overrideLightLinking', False)

        # convert all references to ASS
        for ref in pm.listReferences():
            ref.to_repr('ASS')
            ref.load()

        # fix an arnold bug
        for node_name in ['initialShadingGroup', 'initialParticleSE']:
            node = pm.PyNode(node_name)
            node.setAttr("ai_surface_shader", (0, 0, 0), type="float3")
            node.setAttr("ai_volume_shader", (0, 0, 0), type="float3")

        # if this is an Exterior/Interior -> Layout -> Hires task flatten it
        is_exterior_or_interior_task = self.is_exterior_or_interior_task(task)
        if is_exterior_or_interior_task:
            # and import all of the references
            all_refs = pm.listReferences()
            while len(all_refs) != 0:
                for ref in all_refs:
                    if not ref.isLoaded():
                        ref.load()
                    ref.importContents()
                all_refs = pm.listReferences()

            # assign lambert1 to all GPU nodes
            pm.sets('initialShadingGroup', e=1, fe=auxiliary.get_root_nodes())

            # now remove them from the group
            pm.sets('initialShadingGroup', e=1, rm=pm.ls())

            # and to make sure that no override is enabled
            [node.setAttr('overrideLightLinking', False)
             for node in pm.ls(type='aiStandIn')]

            # clean up
            self.clean_up()

        # check if all aiStandIn nodes are included in
        # ArnoldStandInDefaultLightSet set
        try:
            arnold_stand_in_default_light_set = \
                pm.PyNode('ArnoldStandInDefaultLightSet')
        except pm.MayaNodeError:
            # just create it
            arnold_stand_in_default_light_set = \
                pm.createNode(
                    'objectSet',
                    name='ArnoldStandInDefaultLightSet'
                )

        pm.select(None)
        pm.sets(
            arnold_stand_in_default_light_set,
            fe=pm.ls(type='aiStandIn')
        )

        # save the scene as {{original_take}}___ASS
        # use maya
        take_name = '%s%s%s' % (
            self.base_take_name, Representation.repr_separator, 'ASS'
        )
        v = self.get_latest_repr_version(take_name)
        self.maya_env.save_as(v)

        # export the root nodes under the same file
        if is_exterior_or_interior_task:
            pm.select(auxiliary.get_root_nodes())
            pm.exportSelected(
                v.absolute_full_path,
                type='mayaAscii',
                force=True
            )

        # new scene
        pm.newFile(force=True)

        # reset show plugin shapes option
        active_panel = auxiliary.Playblaster.get_active_panel()
        pm.modelEditor(active_panel, e=1, pluginShapes=show_plugin_shapes)
Exemplo n.º 40
0
class RepositoryTester(unittest2.TestCase):
    """tests the Repository class
    """

    def setUp(self):
        """setup the test
        """
        # create a couple of test tags
        self.test_tag1 = Tag(name="test tag 1")
        self.test_tag2 = Tag(name="test tag 2")

        self.kwargs = {
            "name": "a repository",
            "description": "this is for testing purposes",
            "tags": [self.test_tag1, self.test_tag2],
            "linux_path": "/mnt/M/Projects",
            "osx_path": "/Volumes/M/Projects",
            "windows_path": "M:/Projects"
        }

        self.test_repo = Repository(**self.kwargs)

    def test___auto_name__class_attribute_is_set_to_False(self):
        """testing if the __auto_name__ class attribute is set to False for
        Repository class
        """
        self.assertFalse(Repository.__auto_name__)

    def test_linux_path_argument_accepts_only_strings(self):
        """testing if linux_path argument accepts only string or unicode
        values
        """
        test_values = [123123, 123.1231, [], {}]
        for test_value in test_values:
            self.kwargs["linux_path"] = test_value
            self.assertRaises(TypeError, Repository, **self.kwargs)

    def test_linux_path_attribute_accepts_only_strings(self):
        """testing if linux_path attribute accepts only string or unicode
        values
        """
        test_values = [123123, 123.1231, [], {}]
        for test_value in test_values:
            self.assertRaises(
                TypeError,
                setattr,
                self.test_repo,
                "linux_path",
                test_value
            )

    def test_linux_path_attribute_is_working_properly(self):
        """testing if linux_path attribute is working properly
        """
        test_value = "~/newRepoPath/Projects/"
        self.test_repo.linux_path = test_value
        self.assertEqual(self.test_repo.linux_path, test_value)

    def test_linux_path_attribute_finishes_with_a_slash(self):
        """testing if the linux_path attribute will be finished with a slash
        even it is not supplied by default
        """
        test_value = '/mnt/T'
        expected_value = '/mnt/T/'
        self.test_repo.linux_path = test_value
        self.assertEqual(self.test_repo.linux_path, expected_value)

    def test_windows_path_argument_accepts_only_strings(self):
        """testing if windows_path argument accepts only string or unicode
        values
        """
        test_values = [123123, 123.1231, [], {}]
        for test_value in test_values:
            self.kwargs["windows_path"] = test_value
            self.assertRaises(TypeError, Repository, **self.kwargs)

    def test_windows_path_attribute_accepts_only_strings(self):
        """testing if windows_path attribute accepts only string or unicode
        values
        """
        test_values = [123123, 123.1231, [], {}]
        for test_value in test_values:
            self.assertRaises(
                TypeError,
                setattr,
                self.test_repo,
                "windows_path",
                test_value
            )

    def test_windows_path_attribute_is_working_properly(self):
        """testing if windows_path attribute is working properly
        """
        test_value = "~/newRepoPath/Projects/"
        self.test_repo.windows_path = test_value
        self.assertEqual(self.test_repo.windows_path, test_value)

    def test_windows_path_attribute_finishes_with_a_slash(self):
        """testing if the windows_path attribute will be finished with a slash
        even it is not supplied by default
        """
        test_value = 'T:'
        expected_value = 'T:/'
        self.test_repo.windows_path = test_value
        self.assertEqual(self.test_repo.windows_path, expected_value)

    def test_osx_path_argument_accepts_only_strings(self):
        """testing if osx_path argument accepts only string or unicode
        values
        """
        test_values = [123123, 123.1231, [], {}]
        for test_value in test_values:
            self.kwargs["osx_path"] = test_value
            self.assertRaises(TypeError, Repository, **self.kwargs)

    def test_osx_path_attribute_accepts_only_strings(self):
        """testing if osx_path attribute accepts only string or unicode
        values
        """
        test_values = [123123, 123.1231, [], {}]
        for test_value in test_values:
            self.assertRaises(
                TypeError,
                setattr,
                self.test_repo,
                "osx_path",
                test_value
            )

    def test_osx_path_attribute_is_working_properly(self):
        """testing if osx_path attribute is working properly
        """
        test_value = "~/newRepoPath/Projects/"
        self.test_repo.osx_path = test_value
        self.assertEqual(self.test_repo.osx_path, test_value)

    def test_osx_path_attribute_finishes_with_a_slash(self):
        """testing if the osx_path attribute will be finished with a slash
        even it is not supplied by default
        """
        test_value = '/Volumes/T'
        expected_value = '/Volumes/T/'
        self.test_repo.osx_path = test_value
        self.assertEqual(self.test_repo.osx_path, expected_value)

    def test_path_returns_properly_for_windows(self):
        """testing if path returns the correct value for the os
        """
        m1 = mocker.Mocker()
        o = m1.replace(platform.system)
        o()
        m1.result("Windows")
        m1.replay()
        self.assertEqual(self.test_repo.path, self.test_repo.windows_path)
        m1.restore()

    def test_path_returns_properly_for_linux(self):
        """testing if path returns the correct value for the os
        """
        m1 = mocker.Mocker()
        o = m1.replace(platform.system)
        o()
        m1.result("Linux")
        m1.replay()
        self.assertEqual(self.test_repo.path, self.test_repo.linux_path)
        m1.restore()

    def test_path_returns_properly_for_osx(self):
        """testing if path returns the correct value for the os
        """
        m1 = mocker.Mocker()
        o = m1.replace(platform.system)
        o()
        m1.result("Darwin")
        m1.replay()
        self.assertEqual(self.test_repo.path, self.test_repo.osx_path)
        m1.restore()

    def test_equality(self):
        """testing the equality of two repositories
        """
        repo1 = Repository(**self.kwargs)
        repo2 = Repository(**self.kwargs)

        self.kwargs.update({
            "name": "a repository",
            "description": "this is the commercial repository",
            "linux_path": "/mnt/commercialServer/Projects",
            "osx_path": "/Volumes/commercialServer/Projects",
            "windows_path": "Z:\\Projects"
        })

        repo3 = Repository(**self.kwargs)

        self.assertTrue(repo1 == repo2)
        self.assertFalse(repo1 == repo3)

    def test_inequality(self):
        """testing the inequality of two repositories
        """
        repo1 = Repository(**self.kwargs)
        repo2 = Repository(**self.kwargs)

        self.kwargs.update({
            "name": "a repository",
            "description": "this is the commercial repository",
            "linux_path": "/mnt/commercialServer/Projects",
            "osx_path": "/Volumes/commercialServer/Projects",
            "windows_path": "Z:\\Projects"
        })

        repo3 = Repository(**self.kwargs)

        self.assertFalse(repo1 != repo2)
        self.assertTrue(repo1 != repo3)

    def test_plural_class_name(self):
        """testing the plural name of Repository class
        """
        self.assertTrue(self.test_repo.plural_class_name, "Repositories")

    def test_linux_path_argument_backward_slashes_are_converted_to_forward_slashes(self):
        """testing if the backward slashes are converted to forward slashes
        in the linux_path argument
        """
        self.kwargs["linux_path"] = r"\mnt\M\Projects"
        new_repo = Repository(**self.kwargs)

        self.assertNotIn("\\", new_repo.linux_path)
        self.assertEqual(new_repo.linux_path, "/mnt/M/Projects/")

    def test_linux_path_attribute_backward_slashes_are_converted_to_forward_slashes(self):
        """testing if the backward slashes are converted to forward slashes
        in the linux_path attribute
        """
        self.test_repo.linux_path = r"\mnt\M\Projects"
        self.assertNotIn("\\", self.test_repo.linux_path)
        self.assertEqual(self.test_repo.linux_path, "/mnt/M/Projects/")

    def test_osx_path_argument_backward_slashes_are_converted_to_forward_slashes(self):
        """testing if the backward slashes are converted to forward slashes
        in the osx_path argument
        """
        self.kwargs["osx_path"] = r"\Volumes\M\Projects"
        new_repo = Repository(**self.kwargs)

        self.assertNotIn("\\", new_repo.linux_path)
        self.assertEqual(new_repo.osx_path, "/Volumes/M/Projects/")

    def test_osx_path_attribute_backward_slashes_are_converted_to_forward_slashes(self):
        """testing if the backward slashes are converted to forward slashes
        in the osx_path attribute
        """
        self.test_repo.osx_path = r"\Volumes\M\Projects"
        self.assertNotIn("\\", self.test_repo.osx_path)
        self.assertEqual(self.test_repo.osx_path, "/Volumes/M/Projects/")

    def test_windows_path_argument_backward_slashes_are_converted_to_forward_slashes(self):
        """testing if the backward slashes are converted to forward slashes
        in the windows_path argument
        """
        self.kwargs["windows_path"] = r"M:\Projects"
        new_repo = Repository(**self.kwargs)

        self.assertNotIn("\\", new_repo.linux_path)
        self.assertEqual(new_repo.windows_path, "M:/Projects/")

    def test_windows_path_attribute_backward_slashes_are_converted_to_forward_slashes(self):
        """testing if the backward slashes are converted to forward slashes
        in the windows_path attribute
        """
        self.test_repo.windows_path = r"M:\Projects"
        self.assertNotIn("\\", self.test_repo.windows_path)
        self.assertEqual(self.test_repo.windows_path, "M:/Projects/")

    def test_to_linux_path_returns_the_linux_version_of_the_given_windows_path(self):
        """testing if the to_linux_path returns the linux version of the given
        windows path
        """
        self.test_repo.windows_path = 'T:/Stalker_Projects'
        self.test_repo.linux_path = '/mnt/T/Stalker_Projects'
        test_windows_path = 'T:/Stalker_Projects/Sero/Task1/Task2/' \
                            'Some_file.ma'
        test_linux_path = '/mnt/T/Stalker_Projects/Sero/Task1/Task2/' \
                          'Some_file.ma'
        self.assertEqual(
            self.test_repo.to_linux_path(test_windows_path),
            test_linux_path
        )

    def test_to_linux_path_returns_the_linux_version_of_the_given_linux_path(self):
        """testing if the to_linux_path returns the linux version of the given
        linux path
        """
        self.test_repo.linux_path = '/mnt/T/Stalker_Projects'
        test_linux_path = '/mnt/T/Stalker_Projects/Sero/Task1/Task2/' \
                          'Some_file.ma'
        self.assertEqual(
            self.test_repo.to_linux_path(test_linux_path),
            test_linux_path
        )

    def test_to_linux_path_returns_the_linux_version_of_the_given_osx_path(self):
        """testing if the to_linux_path returns the linux version of the given
        osx path
        """
        self.test_repo.linux_path = '/mnt/T/Stalker_Projects'
        self.test_repo.osx_path = '/Volumes/T/Stalker_Projects'
        test_osx_path = '/Volumes/T/Stalker_Projects/Sero/Task1/Task2/' \
                        'Some_file.ma'
        test_linux_path = '/mnt/T/Stalker_Projects/Sero/Task1/Task2/' \
                          'Some_file.ma'
        self.assertEqual(
            self.test_repo.to_linux_path(test_osx_path),
            test_linux_path
        )

    def test_to_linux_path_returns_the_linux_version_of_the_given_reverse_windows_path(self):
        """testing if the to_linux_path returns the linux version of the given
        reverse windows path
        """
        self.test_repo.windows_path = 'T:/Stalker_Projects'
        self.test_repo.linux_path = '/mnt/T/Stalker_Projects'
        test_linux_path = '/mnt/T/Stalker_Projects/Sero/Task1/Task2/' \
                          'Some_file.ma'
        test_windows_path_reverse = 'T:\\Stalker_Projects\\Sero\\Task1\\' \
                                    'Task2\\Some_file.ma'
        self.assertEqual(
            self.test_repo.to_linux_path(test_windows_path_reverse),
            test_linux_path
        )

    def test_to_linux_path_returns_the_linux_version_of_the_given_reverse_linux_path(self):
        """testing if the to_linux_path returns the linux version of the given
        reverse linux path
        """
        self.test_repo.linux_path = '/mnt/T/Stalker_Projects'
        test_linux_path = '/mnt/T/Stalker_Projects/Sero/Task1/Task2/' \
                          'Some_file.ma'
        test_linux_path_reverse = '\\mnt\\T\\Stalker_Projects\\Sero\\Task1\\' \
                                  'Task2\\Some_file.ma'
        self.assertEqual(
            self.test_repo.to_linux_path(test_linux_path_reverse),
            test_linux_path
        )

    def test_to_linux_path_returns_the_linux_version_of_the_given_reverse_osx_path(self):
        """testing if the to_linux_path returns the linux version of the given
        reverse osx path
        """
        self.test_repo.linux_path = '/mnt/T/Stalker_Projects'
        self.test_repo.osx_path = '/Volumes/T/Stalker_Projects'
        test_linux_path = '/mnt/T/Stalker_Projects/Sero/Task1/Task2/' \
                          'Some_file.ma'
        test_osx_path_reverse = '\\Volumes\\T\\Stalker_Projects\\Sero\\' \
                                'Task1\\Task2\\Some_file.ma'
        self.assertEqual(
            self.test_repo.to_linux_path(test_osx_path_reverse),
            test_linux_path
        )

    def test_to_linux_path_raises_TypeError_if_path_is_None(self):
        """testing if to_linux_path raises TypeError if path is None
        """
        self.assertRaises(TypeError, self.test_repo.to_linux_path, None)

    def test_to_linux_path_raises_TypeError_if_path_is_not_a_string(self):
        """testing if to_linux_path raises TypeError if path is None
        """
        self.assertRaises(TypeError, self.test_repo.to_linux_path, 123)

    def test_to_windows_path_returns_the_windows_version_of_the_given_windows_path(self):
        """testing if the to_windows_path returns the windows version of the
        given windows path
        """
        self.test_repo.windows_path = 'T:/Stalker_Projects'
        test_windows_path = 'T:/Stalker_Projects/Sero/Task1/Task2/Some_file.ma'
        self.assertEqual(
            self.test_repo.to_windows_path(test_windows_path),
            test_windows_path
        )

    def test_to_windows_path_returns_the_windows_version_of_the_given_linux_path(self):
        """testing if the to_windows_path returns the windows version of the
        given linux path
        """
        self.test_repo.linux_path = '/mnt/T/Stalker_Projects'
        self.test_repo.windows_path = 'T:/Stalker_Projects'
        test_linux_path = '/mnt/T/Stalker_Projects/Sero/Task1/Task2/' \
                          'Some_file.ma'
        test_windows_path = 'T:/Stalker_Projects/Sero/Task1/Task2/Some_file.ma'
        self.assertEqual(
            self.test_repo.to_windows_path(test_linux_path),
            test_windows_path
        )

    def test_to_windows_path_returns_the_windows_version_of_the_given_osx_path(self):
        """testing if the to_windows_path returns the windows version of the
        given osx path
        """
        self.test_repo.windows_path = 'T:/Stalker_Projects'
        self.test_repo.osx_path = '/Volumes/T/Stalker_Projects'
        test_osx_path = '/Volumes/T/Stalker_Projects/Sero/Task1/Task2/' \
                        'Some_file.ma'
        test_windows_path = 'T:/Stalker_Projects/Sero/Task1/Task2/Some_file.ma'
        self.assertEqual(
            self.test_repo.to_windows_path(test_osx_path),
            test_windows_path
        )

    def test_to_windows_path_returns_the_windows_version_of_the_given_reverse_windows_path(self):
        """testing if the to_windows_path returns the windows version of the
        given reverse windows path
        """
        self.test_repo.windows_path = 'T:/Stalker_Projects'
        test_windows_path = 'T:/Stalker_Projects/Sero/Task1/Task2/Some_file.ma'
        test_windows_path_reverse = 'T:\\Stalker_Projects\\Sero\\Task1\\' \
                                    'Task2\\Some_file.ma'
        self.assertEqual(
            self.test_repo.to_windows_path(test_windows_path_reverse),
            test_windows_path
        )

    def test_to_windows_path_returns_the_windows_version_of_the_given_reverse_linux_path(self):
        """testing if the to_windows_path returns the windows version of the
        given reverse linux path
        """
        self.test_repo.linux_path = '/mnt/T/Stalker_Projects'
        self.test_repo.windows_path = 'T:/Stalker_Projects'
        test_windows_path = 'T:/Stalker_Projects/Sero/Task1/Task2/Some_file.ma'
        test_linux_path_reverse = '\\mnt\\T\\Stalker_Projects\\Sero\\Task1\\' \
                                  'Task2\\Some_file.ma'
        self.assertEqual(
            self.test_repo.to_windows_path(test_linux_path_reverse),
            test_windows_path
        )

    def test_to_windows_path_returns_the_windows_version_of_the_given_reverse_osx_path(self):
        """testing if the to_windows_path returns the windows version of the
        given reverse osx path
        """
        self.test_repo.windows_path = 'T:/Stalker_Projects'
        self.test_repo.osx_path = '/Volumes/T/Stalker_Projects'
        test_windows_path = 'T:/Stalker_Projects/Sero/Task1/Task2/Some_file.ma'
        test_osx_path_reverse = '\\Volumes\\T\\Stalker_Projects\\Sero\\' \
                                'Task1\\Task2\\Some_file.ma'
        self.assertEqual(
            self.test_repo.to_windows_path(test_osx_path_reverse),
            test_windows_path
        )

    def test_to_windows_path_raises_TypeError_if_path_is_None(self):
        """testing if to_windows_path raises TypeError if path is None
        """
        self.assertRaises(TypeError, self.test_repo.to_windows_path, None)

    def test_to_windows_path_raises_TypeError_if_path_is_not_a_string(self):
        """testing if to_windows_path raises TypeError if path is None
        """
        self.assertRaises(TypeError, self.test_repo.to_windows_path, 123)

    def test_to_osx_path_returns_the_osx_version_of_the_given_windows_path(self):
        """testing if the to_osx_path returns the osx version of the given
        windows path
        """
        self.test_repo.windows_path = 'T:/Stalker_Projects'
        self.test_repo.osx_path = '/Volumes/T/Stalker_Projects'
        test_windows_path = 'T:/Stalker_Projects/Sero/Task1/Task2/Some_file.ma'
        test_osx_path = '/Volumes/T/Stalker_Projects/Sero/Task1/Task2/' \
                        'Some_file.ma'
        self.assertEqual(
            self.test_repo.to_osx_path(test_windows_path),
            test_osx_path
        )

    def test_to_osx_path_returns_the_osx_version_of_the_given_linux_path(self):
        """testing if the to_osx_path returns the osx version of the given
        linux path
        """
        self.test_repo.linux_path = '/mnt/T/Stalker_Projects'
        self.test_repo.osx_path = '/Volumes/T/Stalker_Projects'
        test_linux_path = '/mnt/T/Stalker_Projects/Sero/Task1/Task2/' \
                          'Some_file.ma'
        test_osx_path = '/Volumes/T/Stalker_Projects/Sero/Task1/Task2/' \
                        'Some_file.ma'
        self.assertEqual(
            self.test_repo.to_osx_path(test_linux_path),
            test_osx_path
        )

    def test_to_osx_path_returns_the_osx_version_of_the_given_osx_path(self):
        """testing if the to_osx_path returns the osx version of the given
        osx path
        """
        self.test_repo.osx_path = '/Volumes/T/Stalker_Projects'
        test_osx_path = '/Volumes/T/Stalker_Projects/Sero/Task1/Task2/' \
                        'Some_file.ma'
        self.assertEqual(
            self.test_repo.to_osx_path(test_osx_path),
            test_osx_path
        )

    def test_to_osx_path_returns_the_osx_version_of_the_given_reverse_windows_path(self):
        """testing if the to_osx_path returns the osx version of the given
        reverse windows path
        """
        self.test_repo.windows_path = 'T:/Stalker_Projects'
        self.test_repo.osx_path = '/Volumes/T/Stalker_Projects'
        test_osx_path = '/Volumes/T/Stalker_Projects/Sero/Task1/Task2/' \
                        'Some_file.ma'
        test_windows_path_reverse = 'T:\\Stalker_Projects\\Sero\\Task1\\' \
                                    'Task2\\Some_file.ma'
        self.assertEqual(
            self.test_repo.to_osx_path(test_windows_path_reverse),
            test_osx_path
        )

    def test_to_osx_path_returns_the_osx_version_of_the_given_reverse_linux_path(self):
        """testing if the to_osx_path returns the osx version of the given
        reverse linux path
        """
        self.test_repo.linux_path = '/mnt/T/Stalker_Projects'
        self.test_repo.osx_path = '/Volumes/T/Stalker_Projects'
        test_osx_path = '/Volumes/T/Stalker_Projects/Sero/Task1/Task2/' \
                        'Some_file.ma'
        test_linux_path_reverse = '\\mnt\\T\\Stalker_Projects\\Sero\\Task1\\' \
                                  'Task2\\Some_file.ma'
        self.assertEqual(
            self.test_repo.to_osx_path(test_linux_path_reverse),
            test_osx_path
        )

    def test_to_osx_path_returns_the_osx_version_of_the_given_reverse_osx_path(self):
        """testing if the to_osx_path returns the osx version of the given
        reverse osx path
        """
        self.test_repo.osx_path = '/Volumes/T/Stalker_Projects'
        test_osx_path = '/Volumes/T/Stalker_Projects/Sero/Task1/Task2/' \
                        'Some_file.ma'
        test_osx_path_reverse = '\\Volumes\\T\\Stalker_Projects\\Sero\\' \
                                'Task1\\Task2\\Some_file.ma'
        self.assertEqual(
            self.test_repo.to_osx_path(test_osx_path_reverse),
            test_osx_path
        )

    def test_to_osx_path_returns_the_osx_version_of_the_given_path(self):
        """testing if the to_osx_path returns the osx version of the
        given path
        """
        self.test_repo.windows_path = 'T:/Stalker_Projects'
        self.test_repo.linux_path = '/mnt/T/Stalker_Projects'
        self.test_repo.osx_path = '/Volumes/T/Stalker_Projects'

        test_windows_path = 'T:/Stalker_Projects/Sero/Task1/Task2/' \
                            'Some_file.ma'
        test_linux_path = '/mnt/T/Stalker_Projects/Sero/Task1/Task2/' \
                          'Some_file.ma'
        test_osx_path = '/Volumes/T/Stalker_Projects/Sero/Task1/Task2/' \
                        'Some_file.ma'

        test_windows_path_reverse = 'T:\\Stalker_Projects\\Sero\\Task1\\' \
                                    'Task2\\Some_file.ma'
        test_linux_path_reverse = '\\mnt\\T\\Stalker_Projects\\Sero\\Task1\\' \
                                  'Task2\\Some_file.ma'
        test_osx_path_reverse = '\\Volumes\\T\\Stalker_Projects\\Sero\\' \
                                'Task1\\Task2\\Some_file.ma'

        self.assertEqual(
            self.test_repo.to_osx_path(test_windows_path),
            test_osx_path
        )

        self.assertEqual(
            self.test_repo.to_osx_path(test_linux_path),
            test_osx_path
        )

        self.assertEqual(
            self.test_repo.to_osx_path(test_osx_path),
            test_osx_path
        )

        self.assertEqual(
            self.test_repo.to_osx_path(test_windows_path_reverse),
            test_osx_path
        )

        self.assertEqual(
            self.test_repo.to_osx_path(test_linux_path_reverse),
            test_osx_path
        )

        self.assertEqual(
            self.test_repo.to_osx_path(test_osx_path_reverse),
            test_osx_path
        )

    def test_to_osx_path_raises_TypeError_if_path_is_None(self):
        """testing if to_osx_path raises TypeError if path is None
        """
        self.assertRaises(TypeError, self.test_repo.to_osx_path, None)

    def test_to_osx_path_raises_TypeError_if_path_is_not_a_string(self):
        """testing if to_osx_path raises TypeError if path is None
        """
        self.assertRaises(TypeError, self.test_repo.to_osx_path, 123)

    def test_to_native_path_returns_the_native_version_of_the_given_linux_path(self):
        """testing if the to_native_path returns the native version of the
        given linux path
        """
        m1 = mocker.Mocker()
        o = m1.replace(platform.system)
        o()
        m1.result("Linux")
        m1.replay()

        self.test_repo.windows_path = 'T:/Stalker_Projects'
        self.test_repo.linux_path = '/mnt/T/Stalker_Projects'
        self.test_repo.osx_path = '/Volumes/T/Stalker_Projects'

        test_linux_path = '/mnt/T/Stalker_Projects/Sero/Task1/Task2/' \
                          'Some_file.ma'

        self.assertEqual(
            self.test_repo.to_native_path(test_linux_path),
            test_linux_path
        )
        m1.restore()

    def test_to_native_path_returns_the_native_version_of_the_given_windows_path(self):
        """testing if the to_native_path returns the native version of the
        given windows path
        """
        m1 = mocker.Mocker()
        o = m1.replace(platform.system)
        o()
        m1.result("Linux")
        m1.replay()

        self.test_repo.windows_path = 'T:/Stalker_Projects'
        self.test_repo.linux_path = '/mnt/T/Stalker_Projects'
        self.test_repo.osx_path = '/Volumes/T/Stalker_Projects'

        test_windows_path = 'T:/Stalker_Projects/Sero/Task1/Task2/Some_file.ma'

        self.assertEqual(
            self.test_repo.to_native_path(test_windows_path),
            '/mnt/T/Stalker_Projects/Sero/Task1/Task2/Some_file.ma'
        )
        m1.restore()

    def test_to_native_path_returns_the_native_version_of_the_given_osx_path(self):
        """testing if the to_native_path returns the native version of the
        given osx path
        """
        m1 = mocker.Mocker()
        o = m1.replace(platform.system)
        o()
        m1.result("Linux")
        m1.replay()

        self.test_repo.linux_path = '/mnt/T/Stalker_Projects'
        self.test_repo.osx_path = '/Volumes/T/Stalker_Projects'
        test_linux_path = '/mnt/T/Stalker_Projects/Sero/Task1/Task2/' \
                          'Some_file.ma'
        test_osx_path = '/Volumes/T/Stalker_Projects/Sero/Task1/Task2/' \
                        'Some_file.ma'
        self.assertEqual(
            self.test_repo.to_native_path(test_osx_path),
            test_linux_path
        )
        m1.restore()

    def test_to_native_path_returns_the_native_version_of_the_given_reverse_windows_path(self):
        """testing if the to_native_path returns the native version of the
        given reverse windows path
        """
        m1 = mocker.Mocker()
        o = m1.replace(platform.system)
        o()
        m1.result("Linux")
        m1.replay()

        self.test_repo.windows_path = 'T:/Stalker_Projects'
        self.test_repo.linux_path = '/mnt/T/Stalker_Projects'
        test_windows_path_reverse = 'T:\\Stalker_Projects\\Sero\\Task1\\' \
                                    'Task2\\Some_file.ma'
        test_linux_path = '/mnt/T/Stalker_Projects/Sero/Task1/Task2/' \
                          'Some_file.ma'
        self.assertEqual(
            self.test_repo.to_native_path(test_windows_path_reverse),
            test_linux_path
        )
        m1.restore()

    def test_to_native_path_returns_the_native_version_of_the_given_reverse_linux_path(self):
        """testing if the to_native_path returns the native version of the
        given reverse linux path
        """
        m1 = mocker.Mocker()
        o = m1.replace(platform.system)
        o()
        m1.result("Linux")
        m1.replay()

        self.test_repo.linux_path = '/mnt/T/Stalker_Projects'
        test_linux_path = '/mnt/T/Stalker_Projects/Sero/Task1/Task2/' \
                          'Some_file.ma'
        test_linux_path_reverse = '\\mnt\\T\\Stalker_Projects\\Sero\\Task1\\' \
                                  'Task2\\Some_file.ma'
        self.assertEqual(
            self.test_repo.to_native_path(test_linux_path_reverse),
            test_linux_path
        )
        m1.restore()

    def test_to_native_path_returns_the_native_version_of_the_given_reverse_osx_path(self):
        """testing if the to_native_path returns the native version of the
        given reverse osx path
        """
        m1 = mocker.Mocker()
        o = m1.replace(platform.system)
        o()
        m1.result("Linux")
        m1.replay()

        self.test_repo.linux_path = '/mnt/T/Stalker_Projects'
        self.test_repo.osx_path = '/Volumes/T/Stalker_Projects'
        test_linux_path = '/mnt/T/Stalker_Projects/Sero/Task1/Task2/' \
                          'Some_file.ma'
        test_osx_path_reverse = '\\Volumes\\T\\Stalker_Projects\\Sero\\' \
                                'Task1\\Task2\\Some_file.ma'
        self.assertEqual(
            self.test_repo.to_native_path(test_osx_path_reverse),
            test_linux_path
        )
        m1.restore()

    def test_to_native_path_raises_TypeError_if_path_is_None(self):
        """testing if to_native_path raises TypeError if path is None
        """
        self.assertRaises(TypeError, self.test_repo.to_native_path, None)

    def test_to_native_path_raises_TypeError_if_path_is_not_a_string(self):
        """testing if to_native_path raises TypeError if path is None
        """
        self.assertRaises(TypeError, self.test_repo.to_native_path, 123)

    def test_is_in_repo_returns_True_if_the_given_linux_path_is_in_this_repo(self):
        """testing if is_in_repo returns True if the given linux path is in
        this repo or False otherwise
        """
        self.test_repo.linux_path = '/mnt/T/Stalker_Projects'
        test_linux_path = '/mnt/T/Stalker_Projects/Sero/Task1/Task2/' \
                          'Some_file.ma'
        self.assertTrue(self.test_repo.is_in_repo(test_linux_path))

    def test_is_in_repo_returns_True_if_the_given_linux_reverse_path_is_in_this_repo(self):
        """testing if is_in_repo returns True if the given linux reverse path
        is in this repo or False otherwise
        """
        self.test_repo.linux_path = '/mnt/T/Stalker_Projects'
        test_linux_path_reverse = '\\mnt\\T\\Stalker_Projects\\Sero\\Task1\\' \
                                  'Task2\\Some_file.ma'
        self.assertTrue(self.test_repo.is_in_repo(test_linux_path_reverse))

    def test_is_in_repo_returns_False_if_the_given_linux_path_is_not_in_this_repo(self):
        """testing if is_in_repo returns False if the given linux path is not
        in this repo or False otherwise
        """
        self.test_repo.linux_path = '/mnt/T/Stalker_Projects'
        test_not_in_path_linux_path = '/mnt/T/Other_Projects/Sero/Task1/' \
                                      'Task2/Some_file.ma'
        self.assertFalse(
            self.test_repo.is_in_repo(test_not_in_path_linux_path))

    def test_is_in_repo_returns_True_if_the_given_windows_path_is_in_this_repo(self):
        """testing if is_in_repo returns True if the given windows path is in
        this repo or False otherwise
        """
        self.test_repo.windows_path = 'T:/Stalker_Projects'
        test_windows_path = 'T:/Stalker_Projects/Sero/Task1/Task2/Some_file.ma'
        self.assertTrue(self.test_repo.is_in_repo(test_windows_path))

    def test_is_in_repo_returns_True_if_the_given_windows_reverse_path_is_in_this_repo(self):
        """testing if is_in_repo returns True if the given windows reverse path
        is in this repo or False otherwise
        """
        self.test_repo.windows_path = 'T:/Stalker_Projects'
        test_windows_path_reverse = 'T:\\Stalker_Projects\\Sero\\Task1\\' \
                                    'Task2\\Some_file.ma'
        self.assertTrue(self.test_repo.is_in_repo(test_windows_path_reverse))

    def test_is_in_repo_returns_False_if_the_given_windows_path_is_not_in_this_repo(self):
        """testing if is_in_repo returns False if the given windows path is not
        in this repo or False otherwise
        """
        self.test_repo.windows_path = 'T:/Stalker_Projects'
        test_not_in_path_windows_path = 'T:/Other_Projects/Sero/Task1/Task2/' \
                                        'Some_file.ma'
        self.assertFalse(
            self.test_repo.is_in_repo(test_not_in_path_windows_path))

    def test_is_in_repo_returns_True_if_the_given_osx_path_is_in_this_repo(self):
        """testing if is_in_repo returns True if the given osx path is in
        this repo or False otherwise
        """
        self.test_repo.osx_path = '/Volumes/T/Stalker_Projects'
        test_osx_path = '/Volumes/T/Stalker_Projects/Sero/Task1/Task2/' \
                        'Some_file.ma'
        self.assertTrue(self.test_repo.is_in_repo(test_osx_path))

    def test_is_in_repo_returns_True_if_the_given_osx_reverse_path_is_in_this_repo(self):
        """testing if is_in_repo returns True if the given osx reverse path
        is in this repo or False otherwise
        """
        self.test_repo.osx_path = '/Volumes/T/Stalker_Projects'
        test_osx_path_reverse = '\\Volumes\\T\\Stalker_Projects\\Sero\\' \
                                'Task1\\Task2\\Some_file.ma'
        self.assertTrue(self.test_repo.is_in_repo(test_osx_path_reverse))

    def test_is_in_repo_returns_False_if_the_given_osx_path_is_not_in_this_repo(self):
        """testing if is_in_repo returns False if the given osx path is not
        in this repo or False otherwise
        """
        self.test_repo.osx_path = '/Volumes/T/Stalker_Projects'
        test_not_in_path_osx_path = '/Volumes/T/Other_Projects/Sero/Task1/' \
                                    'Task2/Some_file.ma'
        self.assertFalse(self.test_repo.is_in_repo(test_not_in_path_osx_path))

    def test_make_relative_method_converts_the_given_linux_path_to_relative_to_repo_root(self):
        """testing if Repository.make_relative() will convert the given Linux
        path to repository root relative path
        """
        # a Linux Path
        linux_path = '/mnt/T/Stalker_Projects/Sero/Task1/Task2/Some_file.ma'
        self.test_repo.linux_path = '/mnt/T/Stalker_Projects'
        result = self.test_repo.make_relative(linux_path)
        self.assertEqual(
            result,
            'Sero/Task1/Task2/Some_file.ma'
        )

    def test_make_relative_method_converts_the_given_osx_path_to_relative_to_repo_root(self):
        """testing if Repository.make_relative() will convert the given OSX
        path to repository root relative path
        """
        # an OSX Path
        osx_path = '/Volumes/T/Stalker_Projects/Sero/Task1/Task2/Some_file.ma'
        self.test_repo.osx_path = '/Volumes/T/Stalker_Projects'
        result = self.test_repo.make_relative(osx_path)
        self.assertEqual(
            result,
            'Sero/Task1/Task2/Some_file.ma'
        )

    def test_make_relative_method_converts_the_given_windows_path_to_relative_to_repo_root(self):
        """testing if Repository.make_relative() will convert the given Windows
        path to repository root relative path
        """
        # a Windows Path
        windows_path = 'T:/Stalker_Projects/Sero/Task1/Task2/Some_file.ma'
        self.test_repo.osx_path = 'T:/Stalker_Projects'
        result = self.test_repo.make_relative(windows_path)
        self.assertEqual(
            result,
            'Sero/Task1/Task2/Some_file.ma'
        )