Esempio n. 1
0
    def test_get_name(self):
        repository = Repository(
            rep_type=Constants.REPOSITORY_TYPE_ZIP,
            rep_path='http://ezored.com/downloads/dependency-sample.zip',
            rep_version='')

        self.assertEqual(repository.get_name(), 'dependency-sample')
Esempio n. 2
0
    def test_github_get_name(self):
        repository = Repository(
            rep_type=Repository.TYPE_GITHUB,
            rep_name='ezored/dependency-sample',
            rep_version='b:master',
        )

        self.assertEqual(repository.get_name(), 'ezored-dependency-sample')
Esempio n. 3
0
    def test_local_get_name(self):
        repository = Repository(
            rep_type=Repository.TYPE_LOCAL,
            rep_name='/tmp/repository-test',
            rep_version='1.0.0',
        )

        self.assertEqual(repository.get_name(), 'repository-test')
Esempio n. 4
0
    def test_git_get_name(self):
        repository = Repository(
            rep_type=Constants.REPOSITORY_TYPE_GIT,
            rep_path='https://github.com/ezored/dependency-sample.git',
            rep_version='t:1.0.0',
        )

        self.assertEqual(repository.get_name(), 'dependency-sample')
Esempio n. 5
0
    def test_local_get_name(self):
        repository = Repository(
            rep_type=Constants.REPOSITORY_TYPE_LOCAL,
            rep_path='/tmp/repository-test',
            rep_version='1.0.0',
        )

        self.assertEqual(repository.get_name(), 'repository-test')
Esempio n. 6
0
    def test_merge_target_data(self, d):
        os.chdir(d.path)

        # create project
        project = Project()
        project.config['name'] = Constants.PROJECT_NAME

        # create dependency
        dep_repository = Repository(
            rep_type=Constants.REPOSITORY_TYPE_LOCAL,
            rep_path='/tmp/dep-repository-test',
            rep_version='1.0.0',
        )

        dependency = Dependency(name='repository-test',
                                repository=dep_repository)

        project.dependencies = [dependency]

        # create target
        target_repository = Repository(
            rep_type=Constants.REPOSITORY_TYPE_LOCAL,
            rep_path='/tmp/target-repository-test',
            rep_version='1.0.0',
        )

        target1 = Target(name='test', repository=target_repository)

        target2 = Target(name='test', repository=target_repository)

        project.targets = [target1, target2]

        # process data
        process_data = ProcessData()
        process_data.reset()
        process_data.project_name = project.get_config_value('name')

        # process target data
        for target in project.targets:
            # get all target data from project dependencies
            print('Who is the target:')
            print(target.get_name())
            print("")

            target_data = TargetData()

            for dependency in project.dependencies:
                print('Who is the dependency:')
                print(dependency.get_name())
                print("")

                dependency.prepare_from_process_data(process_data)

                new_target_data = TargetData()
                new_target_data.c_flags.extend(['flag'])
                target_data.merge(new_target_data)

            self.assertEqual(len(target_data.c_flags), 1)
Esempio n. 7
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)
Esempio n. 8
0
    def test_match_target_name_and_target_data(self):
        # create dependency
        dep_repository = Repository(
            rep_type=Constants.REPOSITORY_TYPE_LOCAL,
            rep_path='dep-repository-test',
            rep_version='1.0.0',
        )

        dependency = Dependency(name='repository-test',
                                repository=dep_repository)

        # check match
        match = dependency.match_name('test1-test2', 'test1-test2')
        self.assertEqual(match, True)

        match = dependency.match_name('test', 'test1-test2')
        self.assertEqual(match, True)

        match = dependency.match_name('test1', 'test1-test2')
        self.assertEqual(match, True)

        match = dependency.match_name('test2', 'test1-test2')
        self.assertEqual(match, True)

        match = dependency.match_name('-', 'test1-test2')
        self.assertEqual(match, True)

        match = dependency.match_name('arm', 'armv7-linux')
        self.assertEqual(match, True)

        match = dependency.match_name('linux', 'armv7-linux')
        self.assertEqual(match, True)
Esempio n. 9
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)
Esempio n. 10
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')
Esempio n. 11
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
Esempio n. 12
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')
Esempio n. 13
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
Esempio n. 14
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')
Esempio n. 15
0
    def test_local_get_name_with_null_name(self):
        repository = Repository(
            rep_type=Repository.TYPE_LOCAL,
            rep_name='/tmp/repository-test',
            rep_version='1.0.0',
        )

        target = Target(name=None, repository=repository)

        self.assertEqual(target.get_name(), 'repository-test')
Esempio n. 16
0
    def test_local_get_name_with_null_name(self):
        repository = Repository(
            rep_type=Repository.TYPE_LOCAL,
            rep_name='/tmp/repository-test',
            rep_version='1.0.0',
        )

        dependency = Dependency(repository=repository)

        self.assertEqual(dependency.get_name(), 'repository-test')
Esempio n. 17
0
    def test_constructor(self):
        repository = Repository(
            rep_type=Constants.REPOSITORY_TYPE_LOCAL,
            rep_path='/tmp/repository-test',
            rep_version='1.0.0',
        )

        self.assertEqual(repository.rep_type, Constants.REPOSITORY_TYPE_LOCAL)
        self.assertEqual(repository.rep_path, '/tmp/repository-test')
        self.assertEqual(repository.rep_version, '1.0.0')
Esempio n. 18
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')
Esempio n. 19
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')
Esempio n. 20
0
    def test_constructor(self):
        repository = Repository(
            rep_type=Repository.TYPE_LOCAL,
            rep_name='/tmp/repository-test',
            rep_version='1.0.0',
        )

        self.assertEqual(repository.rep_type, Repository.TYPE_LOCAL)
        self.assertEqual(repository.rep_name, '/tmp/repository-test')
        self.assertEqual(repository.rep_version, '1.0.0')
Esempio n. 21
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')
Esempio n. 22
0
    def test_local_get_name_with_null_name(self):
        repository = Repository(
            rep_type=Constants.REPOSITORY_TYPE_LOCAL,
            rep_path='/tmp/repository-test',
            rep_version='1.0.0',
        )

        dependency = Dependency(name=None, repository=repository)

        self.assertEqual(dependency.get_name(), None)
Esempio n. 23
0
    def test_local_get_name_with_different_name_from_repository(self):
        repository = Repository(
            rep_type=Constants.REPOSITORY_TYPE_LOCAL,
            rep_path='/tmp/repository-test',
            rep_version='1.0.0',
        )

        target = Target(name='repository-test-diff', repository=repository)

        self.assertEqual(target.get_name(), 'repository-test-diff')
Esempio n. 24
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')
Esempio n. 25
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')
Esempio n. 26
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')
Esempio n. 27
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')
Esempio n. 28
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')
Esempio n. 29
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')
Esempio n. 30
0
    def test_constructor(self):
        repository = Repository(
            rep_type=Repository.TYPE_LOCAL,
            rep_name='/tmp/repository-test',
            rep_version='1.0.0',
        )

        target = Target(name='repository-test', repository=repository)

        self.assertEqual(target.get_name(), 'repository-test')
        self.assertEqual(target.repository.rep_type, Repository.TYPE_LOCAL)
        self.assertEqual(target.repository.rep_name, '/tmp/repository-test')
        self.assertEqual(target.repository.rep_version, '1.0.0')