Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AdapterInterface uses ABC to enforce implementation #12

Merged
merged 2 commits into from
Jul 19, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 43 additions & 7 deletions src/pyMetricCli/adapter_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@
# Imports
################################################################################

from abc import ABC, abstractmethod
gabryelreyes marked this conversation as resolved.
Show resolved Hide resolved

################################################################################
# Variables
################################################################################
Expand All @@ -42,16 +44,51 @@
################################################################################


class AdapterInterface():
class AdapterInterface(ABC):
"""
Adapter interface class for handling different search results.
"""

output: dict
jira_config: dict
polarion_config: dict
superset_config: dict
@property
@abstractmethod
def output(self) -> dict:
"""
Output dictionary.
"""

@property
@abstractmethod
def jira_config(self) -> dict:
"""
JIRA configuration.
"""
@property
@abstractmethod
def polarion_config(self) -> dict:
"""
Polarion configuration.
"""
@property
@abstractmethod
def superset_config(self) -> dict:
"""
Superset configuration.
"""

def __init__(self) -> None:
"""
Initializes the adapter.
Must be called after the definition of the properties.
"""
assert isinstance(self.output, dict), "output must be a dictionary"
assert isinstance(self.jira_config,
dict), "jira_config must be a dictionary"
assert isinstance(self.polarion_config,
dict), "polarion_config config must be a dictionary"
assert isinstance(self.superset_config,
dict), "superset_config config must be a dictionary"

@abstractmethod
def handle_jira(self, _search_results: dict) -> bool:
"""
Handles the JIRA search results.
Expand All @@ -62,8 +99,8 @@ def handle_jira(self, _search_results: dict) -> bool:
Returns:
bool: True if the search results were handled successfully, False otherwise.
"""
return False

@abstractmethod
def handle_polarion(self, _search_results: dict) -> bool:
"""
Handles the Polarion search results.
Expand All @@ -74,7 +111,6 @@ def handle_polarion(self, _search_results: dict) -> bool:
Returns:
bool: True if the search results were handled successfully, False otherwise.
"""
return False

################################################################################
# Functions
Expand Down