Skip to content

Commit

Permalink
Merge pull request #534 from OP-TED/feature/TED4-153
Browse files Browse the repository at this point in the history
  • Loading branch information
kaleanych authored Apr 18, 2024
2 parents ea25402 + 1e581c0 commit bc409c7
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 5 deletions.
3 changes: 0 additions & 3 deletions ted_sws/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,9 +145,6 @@ class GitHubArtefacts:
def GITHUB_TED_SWS_ARTEFACTS_URL(self, config_value: str) -> str:
return config_value

@env_property(config_resolver_class=AirflowAndEnvConfigResolver, default_value="ted-rdf-mapping")
def GITHUB_TED_SWS_ARTEFACTS_REPOSITORY_NAME(self, config_value: str) -> str:
return config_value


class API:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,14 @@
MAPPINGS_DIR_NAME = "mappings"


def get_repo_name_from_repo_url(repository_url: str) -> str:
"""
This method will extract the name of the repository from a repository URL
"""
url_path = pathlib.PurePosixPath(repository_url)
return url_path.stem


class MappingSuitePackageDownloaderABC(abc.ABC):
"""
This class is intended to download mapping_suite_package from external resources.
Expand Down Expand Up @@ -35,7 +43,7 @@ def __init__(self, github_repository_url: str, branch_or_tag_name: str):
"""
self.github_repository_url = github_repository_url
self.branch_or_tag_name = branch_or_tag_name
self.repository_name = config.GITHUB_TED_SWS_ARTEFACTS_REPOSITORY_NAME
self.repository_name = get_repo_name_from_repo_url(repository_url=github_repository_url)

def download(self, output_mapping_suite_package_path: pathlib.Path) -> str:
"""
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import pathlib
from ted_sws import config
from ted_sws.mapping_suite_processor.adapters.github_package_downloader import GitHubMappingSuitePackageDownloader
from ted_sws.mapping_suite_processor.adapters.github_package_downloader import GitHubMappingSuitePackageDownloader, \
get_repo_name_from_repo_url
from tests.e2e.mapping_suite_processor import MAPPING_SUITE_PACKAGE_NAME


Expand All @@ -11,3 +12,10 @@ def test_github_mapping_suite_package_downloader(tmpdir):
mapping_suite_package_downloader.download(output_mapping_suite_package_path=tmp_dir_path)
mapping_suite_package_path = tmp_dir_path / MAPPING_SUITE_PACKAGE_NAME
assert mapping_suite_package_path.is_dir()


def test_get_repo_name_from_repo_url():
repo_url = "https://github.com/OP-TED/ted-rdf-mapping.git"
repo_name = get_repo_name_from_repo_url(repository_url=repo_url)
assert repo_name == "ted-rdf-mapping"
assert isinstance(repo_name, str)

0 comments on commit bc409c7

Please sign in to comment.