Пример #1
0
    def test_parse_text_list(self, d):
        os.chdir(d.path)

        process_data = ProcessData()
        process_data.reset()

        repository = Repository.from_dict({
            'type': 'git',
            'path': 'https://github.com/ezored/dependency-sample.git',
            'version': 't:1.0.0',
        })

        process_data.set_dependency_data(
            name=repository.get_name(),
            temp_dir=repository.get_temp_dir(),
            vendor_dir=repository.get_vendor_dir(),
            source_dir=repository.get_source_dir(),
            build_dir=repository.get_vendor_dir(),
        )

        parse_text_list = [
            '${EZORED_DEPENDENCY_TEMP_DIR}',
            '${EZORED_DEPENDENCY_BUILD_DIR}',
            '${EZORED_DEPENDENCY_VENDOR_DIR}',
            '${EZORED_PROJECT_HOME}',
        ]

        parsed_text_list = process_data.parse_text_list(parse_text_list)

        self.assertEqual(parsed_text_list[0], process_data.dependency_temp_dir)
        self.assertEqual(parsed_text_list[1], process_data.dependency_build_dir)
        self.assertEqual(parsed_text_list[2], process_data.dependency_vendor_dir)
        self.assertEqual(parsed_text_list[3], process_data.project_home_dir)
Пример #2
0
    def test_parse_text(self, d):
        os.chdir(d.path)

        process_data = ProcessData()
        process_data.reset()

        repository = Repository.from_dict({
            'type': 'github',
            'name': 'ezored/dependency-sample',
            'version': 't:1.0.0',
        })

        process_data.set_dependency_data(
            name=repository.get_name(),
            temp_dir=repository.get_temp_dir(),
            vendor_dir=repository.get_vendor_dir(),
            source_dir=repository.get_source_dir(),
            build_dir=repository.get_vendor_dir(),
        )

        parsed_text = process_data.parse_text('${EZORED_DEPENDENCY_TEMP_DIR}')
        self.assertEqual(parsed_text, repository.get_temp_dir())

        parsed_text = process_data.parse_text('${EZORED_DEPENDENCY_BUILD_DIR}')
        self.assertEqual(parsed_text, repository.get_vendor_dir())

        parsed_text = process_data.parse_text(
            '${EZORED_DEPENDENCY_VENDOR_DIR}')
        self.assertEqual(parsed_text, repository.get_vendor_dir())

        parsed_text = process_data.parse_text('${EZORED_PROJECT_HOME}')
        self.assertEqual(parsed_text, process_data.project_home_dir)
Пример #3
0
    def test_from_dict(self):
        repository = Repository.from_dict({
            'type': Constants.REPOSITORY_TYPE_TAR,
            'path': 'http://ezored.com/downloads/dependency-sample.tar.gz',
        })

        self.assertEqual(repository.rep_type, Constants.REPOSITORY_TYPE_TAR)
        self.assertEqual(repository.rep_path, 'http://ezored.com/downloads/dependency-sample.tar.gz')
Пример #4
0
    def from_dict(dict_data):
        repository_data = dict_data[
            'repository'] if 'repository' in dict_data else {}

        target = Target(name=dict_data['name'] if 'name' in dict_data else '',
                        repository=Repository.from_dict(repository_data))

        return target
Пример #5
0
    def test_get_dir_name(self):
        repository = Repository.from_dict({
            'type': Constants.REPOSITORY_TYPE_TAR,
            'path': 'http://ezored.com/downloads/dependency-sample.tar.gz',
        })

        dir_name = repository.get_dir_name()

        self.assertEqual(dir_name, 'dependency-sample')
Пример #6
0
    def from_dict(dict_data):
        repository_data = dict_data[
            'repository'] if 'repository' in dict_data else {}

        dependency = Dependency(
            name=dict_data['name'],
            repository=Repository.from_dict(repository_data))

        return dependency
Пример #7
0
    def test_from_dict(self):
        repository = Repository.from_dict({
            'type': 'github',
            'name': 'ezored/dependency-sample',
            'version': '1.0.0',
        })

        self.assertEqual(repository.rep_type, Repository.TYPE_GITHUB)
        self.assertEqual(repository.rep_name, 'ezored/dependency-sample')
        self.assertEqual(repository.rep_version, '1.0.0')
Пример #8
0
    def test_local_get_dir_name(self):
        repository = Repository.from_dict({
            'type': 'local',
            'name': '/opt/ezored/sample-dependency',
            'version': '',
        })

        dir_name = repository.get_dir_name()

        self.assertEqual(dir_name, 'sample-dependency')
Пример #9
0
    def test_local_temp_working_dir(self):
        repository = Repository.from_dict({
            'type': Constants.REPOSITORY_TYPE_LOCAL,
            'path': '/opt/ezored/sample-dependency',
            'version': '',
        })

        temp_working_dir = repository.get_temp_dir()

        self.assertEqual(temp_working_dir, '/opt/ezored/sample-dependency')
Пример #10
0
    def test_local_temp_working_dir(self):
        repository = Repository.from_dict({
            'type': 'local',
            'name': '/opt/ezored/sample-dependency',
            'version': '',
        })

        temp_working_dir = repository.get_temp_dir()

        self.assertEqual(temp_working_dir, '/opt/ezored/sample-dependency')
Пример #11
0
    def test_git_get_dir_name(self):
        repository = Repository.from_dict({
            'type': Constants.REPOSITORY_TYPE_GIT,
            'path': 'https://github.com/ezored/dependency-sample.git',
            'version': 't:1.0.0',
        })

        dir_name = repository.get_dir_name()

        self.assertEqual(dir_name, 'dependency-sample')
Пример #12
0
    def test_local_get_dir_name(self):
        repository = Repository.from_dict({
            'type': Constants.REPOSITORY_TYPE_LOCAL,
            'path': '/opt/ezored/sample-dependency',
            'version': '',
        })

        dir_name = repository.get_dir_name()

        self.assertEqual(dir_name, 'sample-dependency')
Пример #13
0
    def test_github_get_dir_name(self):
        repository = Repository.from_dict({
            'type': 'github',
            'name': 'ezored/dependency-sample',
            'version': 't:1.0.0',
        })

        dir_name = repository.get_dir_name()

        self.assertEqual(dir_name, 'dependency-sample-1-0-0')
Пример #14
0
    def test_download_filename(self):
        repository = Repository.from_dict({
            'type':
            Constants.REPOSITORY_TYPE_ZIP,
            'path':
            'http://ezored.com/downloads/dependency-sample.zip',
        })

        download_filename = repository.get_download_filename()

        self.assertEqual(download_filename, 'dependency-sample.zip')
Пример #15
0
    def test_from_dict(self):
        repository = Repository.from_dict({
            'type': Constants.REPOSITORY_TYPE_GIT,
            'path': 'https://github.com/ezored/dependency-sample.git',
            'version': '1.0.0',
        })

        self.assertEqual(repository.rep_type, Constants.REPOSITORY_TYPE_GIT)
        self.assertEqual(repository.rep_path,
                         'https://github.com/ezored/dependency-sample.git')
        self.assertEqual(repository.rep_version, '1.0.0')
Пример #16
0
    def test_github_download_url(self):
        repository = Repository.from_dict({
            'type': 'github',
            'name': 'ezored/dependency-sample',
            'version': 't:1.0.0',
        })

        download_url = repository.get_download_url()

        self.assertEqual(
            download_url,
            'https://github.com/ezored/dependency-sample/archive/1.0.0.tar.gz')
Пример #17
0
    def test_get_git_data_commit(self):
        repository = Repository.from_dict({
            'type': 'github',
            'name': 'ezored/dependency-sample',
            'version': 'c:123456',
        })

        git_data_name, git_data_type, git_data_version = repository.get_git_data(
        )

        self.assertEqual(git_data_name, 'ezored/dependency-sample')
        self.assertEqual(git_data_type, Repository.GIT_TYPE_COMMIT)
        self.assertEqual(git_data_version, '123456')
Пример #18
0
    def test_get_git_data_tag(self):
        repository = Repository.from_dict({
            'type': 'github',
            'name': 'ezored/dependency-sample',
            'version': 't:1.0.0',
        })

        git_data_name, git_data_type, git_data_version = repository.get_git_data(
        )

        self.assertEqual(git_data_name, 'ezored/dependency-sample')
        self.assertEqual(git_data_type, Repository.GIT_TYPE_TAG)
        self.assertEqual(git_data_version, '1.0.0')
Пример #19
0
    def test_get_git_data_branch(self):
        repository = Repository.from_dict({
            'type': 'github',
            'name': 'ezored/dependency-sample',
            'version': 'b:master',
        })

        git_data_name, git_data_type, git_data_version = repository.get_git_data(
        )

        self.assertEqual(git_data_name, 'ezored/dependency-sample')
        self.assertEqual(git_data_type, Repository.GIT_TYPE_BRANCH)
        self.assertEqual(git_data_version, 'master')
Пример #20
0
    def test_temp_working_dir(self, d):
        os.chdir(d.path)

        repository = Repository.from_dict({
            'type': Constants.REPOSITORY_TYPE_TAR,
            'path': 'http://ezored.com/downloads/dependency-sample.tar.gz',
        })

        temp_working_dir = repository.get_temp_dir()

        self.assertEqual(
            temp_working_dir,
            os.path.join(FileUtil.get_current_dir(), Constants.TEMP_DIR, repository.get_temp_dir())
        )
Пример #21
0
    def test_get_git_data_empty_version(self):
        repository = Repository.from_dict({
            'type': Constants.REPOSITORY_TYPE_GIT,
            'path': 'https://github.com/ezored/dependency-sample.git',
            'version': '',
        })

        git_data_path, git_data_type, git_data_version = repository.get_git_data(
        )

        self.assertEqual(git_data_path,
                         'https://github.com/ezored/dependency-sample.git')
        self.assertEqual(git_data_type, Constants.GIT_TYPE_BRANCH)
        self.assertEqual(git_data_version, 'master')
Пример #22
0
    def test_get_git_data_commit(self):
        repository = Repository.from_dict({
            'type': Constants.REPOSITORY_TYPE_GIT,
            'path': 'https://github.com/ezored/dependency-sample.git',
            'version': 'c:123456',
        })

        git_data_path, git_data_type, git_data_version = repository.get_git_data(
        )

        self.assertEqual(git_data_path,
                         'https://github.com/ezored/dependency-sample.git')
        self.assertEqual(git_data_type, Constants.GIT_TYPE_COMMIT)
        self.assertEqual(git_data_version, '123456')
Пример #23
0
    def test_get_git_data_tag_without_prefix(self):
        repository = Repository.from_dict({
            'type': Constants.REPOSITORY_TYPE_GIT,
            'path': 'https://github.com/ezored/dependency-sample.git',
            'version': '1.0.0',
        })

        git_data_path, git_data_type, git_data_version = repository.get_git_data(
        )

        self.assertEqual(git_data_path,
                         'https://github.com/ezored/dependency-sample.git')
        self.assertEqual(git_data_type, Constants.GIT_TYPE_TAG)
        self.assertEqual(git_data_version, '1.0.0')
Пример #24
0
    def test_git_temp_working_dir(self, d):
        os.chdir(d.path)

        repository = Repository.from_dict({
            'type': Constants.REPOSITORY_TYPE_GIT,
            'path': 'https://github.com/ezored/dependency-sample.git',
            'version': 't:1.0.0',
        })

        temp_working_dir = repository.get_temp_dir()

        self.assertEqual(
            temp_working_dir,
            os.path.join(FileUtil.get_current_dir(), Constants.TEMP_DIR,
                         repository.get_temp_dir()))
Пример #25
0
    def test_github_temp_working_dir(self, d):
        os.chdir(d.path)

        repository = Repository.from_dict({
            'type': 'github',
            'name': 'ezored/dependency-sample',
            'version': 't:1.0.0',
        })

        temp_working_dir = repository.get_temp_dir()

        self.assertEqual(
            temp_working_dir,
            os.path.join(FileUtil.get_current_dir(), Constants.TEMP_DIR,
                         repository.get_dir_name()))
Пример #26
0
    def test_set_repository_name(self, d):
        os.chdir(d.path)

        repository_name = 'test-repository'

        process_data = ProcessData()
        process_data.reset()

        repository = Repository.from_dict({
            'type': 'github',
            'name': 'ezored/dependency-sample',
            'version': 't:1.0.0',
        })

        process_data.set_dependency_data(
            name=repository_name,
            temp_dir=repository.get_temp_dir(),
            vendor_dir=repository.get_vendor_dir(),
            source_dir=repository.get_source_dir(),
            build_dir=repository.get_vendor_dir(),
        )

        self.assertEqual(process_data.dependency_name, repository_name)