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)
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)
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')
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
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')
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
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')
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')
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')
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')
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')
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')
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')
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')
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')
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')
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')
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')
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')
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()) )
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')
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')
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')
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()))
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()))
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)