-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
1,223 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
from kataloger.data.artifact.library import Library | ||
|
||
|
||
class TestLibrary: | ||
def test_library_to_path_should_return_path_part_from_library_coordinates(self): | ||
library: Library = Library( | ||
name="library", | ||
coordinates="com.library.group:library-artifact-id", | ||
version="1.0.0", | ||
) | ||
expected_path_part: str = "com/library/group/library-artifact-id" | ||
|
||
assert library.to_path() == expected_path_part |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
from kataloger.data.artifact.plugin import Plugin | ||
|
||
|
||
class TestPlugin: | ||
def test_plugin_to_path_should_return_path_part_from_plugin_coordinates(self): | ||
plugin: Plugin = Plugin( | ||
name="plugin", | ||
coordinates="com.plugin.artifact-id", | ||
version="1.0.0", | ||
) | ||
expected_path_part: str = "com/plugin/artifact-id/com.plugin.artifact-id.gradle.plugin" | ||
|
||
assert plugin.to_path() == expected_path_part |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
from typing import Optional | ||
|
||
from yarl import URL | ||
|
||
from kataloger.data.repository import Repository | ||
|
||
|
||
class TestRepository: | ||
def test_repository_should_require_authorization_when_user_and_password_is_not_none(self): | ||
self._test_require_authorization( | ||
user="repoUser", | ||
password="repoPassword", | ||
expected_requires_authorization=True, | ||
) | ||
|
||
def test_repository_should_not_require_authorization_when_user_is_not_none_but_password_is_none(self): | ||
self._test_require_authorization( | ||
user="repoUser", | ||
password=None, | ||
expected_requires_authorization=False, | ||
) | ||
|
||
def test_repository_should_not_require_authorization_when_password_is_not_none_but_user_is_none(self): | ||
self._test_require_authorization( | ||
user=None, | ||
password="repoPassword", | ||
expected_requires_authorization=False, | ||
) | ||
|
||
def test_repository_should_not_require_authorization_when_user_and_password_is_none(self): | ||
self._test_require_authorization( | ||
user=None, | ||
password=None, | ||
expected_requires_authorization=False, | ||
) | ||
|
||
@staticmethod | ||
def _test_require_authorization( | ||
user: Optional[str], | ||
password: Optional[str], | ||
expected_requires_authorization: bool, | ||
): | ||
repository: Repository = Repository( | ||
name="repository", | ||
address=URL("https://reposito,ry/"), | ||
user=user, | ||
password=password, | ||
) | ||
|
||
assert repository.requires_authorization() == expected_requires_authorization |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
from yarl import URL | ||
|
||
from kataloger.data.artifact.library import Library | ||
from kataloger.data.artifact.plugin import Plugin | ||
from kataloger.data.artifact_update import ArtifactUpdate | ||
from kataloger.data.repository import Repository | ||
|
||
|
||
class EntityFactory: | ||
@staticmethod | ||
def create_repository( | ||
name: str = "default_repository", | ||
address: URL = "https://reposito.ry/", | ||
user: str | None = None, | ||
password: str | None = None, | ||
) -> Repository: | ||
return Repository( | ||
name=name, | ||
address=address, | ||
user=user, | ||
password=password, | ||
) | ||
|
||
@staticmethod | ||
def create_library( | ||
name: str = "default_library", | ||
coordinates: str = "com.library.group:library", | ||
version: str = "1.0.0", | ||
) -> Library: | ||
return Library( | ||
name=name, | ||
coordinates=coordinates, | ||
version=version, | ||
) | ||
|
||
@staticmethod | ||
def create_plugin( | ||
name: str = "default_plugin", | ||
coordinates: str = "com.library.group:library", | ||
version: str = "1.0.0", | ||
) -> Plugin: | ||
return Plugin( | ||
name=name, | ||
coordinates=coordinates, | ||
version=version, | ||
) | ||
|
||
@staticmethod | ||
def create_artifact_update( | ||
name: str = "artifact_name", | ||
update_repository_name: str = "update_repository_name", | ||
current_version: str = "0.1.0", | ||
available_version: str = "1.0.0", | ||
) -> ArtifactUpdate: | ||
return ArtifactUpdate( | ||
name=name, | ||
update_repository_name=update_repository_name, | ||
current_version=current_version, | ||
available_version=available_version, | ||
) |
Oops, something went wrong.