Skip to content

Commit

Permalink
Prepare for unit test refactor. (#27)
Browse files Browse the repository at this point in the history
Converted Base class to regular class
Updated all subclasses to adapt to the change

Signed-off-by: apetrynet <flehnerheener@gmail.com>
  • Loading branch information
apetrynet authored Jun 26, 2024
1 parent 56cb268 commit c841804
Show file tree
Hide file tree
Showing 8 changed files with 15 additions and 6 deletions.
14 changes: 8 additions & 6 deletions src/pyfdl/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
NO_ROUNDING = {}


class Base(ABC):
class Base:
# Holds a list of known attributes
attributes = []
# Maps attribute names that clash with reserved builtin functions to safe alternatives (id -> id_)
Expand All @@ -30,8 +30,7 @@ class Base(ABC):
# The rounding strategy is used when rounding dimensions
rounding_strategy = None

@abstractmethod
def __init__(self, *args: Any, **kwargs: Any):
def __init__(self):
"""Base class not to be instanced directly.
Args:
Expand All @@ -50,7 +49,7 @@ def __init__(self, *args: Any, **kwargs: Any):
subclasses of [Base](#Base)
"""
pass
...

def apply_defaults(self) -> None:
"""Applies default values defined in the `defaults` attribute to attributes that are `None`"""
Expand Down Expand Up @@ -196,9 +195,8 @@ def set_rounding_strategy(cls, rules: Union[dict, None] = DEFAULT_ROUNDING_STRAT
def generate_uuid():
return str(uuid.uuid4())

@abstractmethod
def __repr__(self) -> str:
pass
return f'{self.__class__.__name__}'

def __str__(self) -> str:
return str(self.to_dict())
Expand Down Expand Up @@ -315,6 +313,7 @@ def __init__(self, width: float, height: float):
width:
height:
"""
super().__init__()
self.width = width
self.height = height

Expand Down Expand Up @@ -361,6 +360,7 @@ def __init__(self, width: int, height: int):
width:
height:
"""
super().__init__()
self.width = width.__int__()
self.height = height.__int__()

Expand Down Expand Up @@ -411,6 +411,7 @@ def __init__(self, x: float, y: float):
x:
y:
"""
super().__init__()
self.x = x
self.y = y

Expand Down Expand Up @@ -446,6 +447,7 @@ def __init__(self, even: str = None, mode: str = None):
Raises:
FDLError: if you provide a value other than the ones listed above
"""
super().__init__()
self.even = even
self.mode = mode

Expand Down
1 change: 1 addition & 0 deletions src/pyfdl/canvas.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ def __init__(
anamorphic_squeeze: float = None,
framing_decisions: TypedCollection = None
):
super().__init__()
self.label = label
self.id = id_
self.source_canvas_id = source_canvas_id
Expand Down
1 change: 1 addition & 0 deletions src/pyfdl/canvas_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ def __init__(
pad_to_maximum: bool = None,
round_: RoundStrategy = None
):
super().__init__()
self.label = label
self.id = id_
self.target_dimensions = target_dimensions
Expand Down
1 change: 1 addition & 0 deletions src/pyfdl/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ class Context(Base):
id_attribute = "label"

def __init__(self, label: str = None, context_creator: str = None, canvases: TypedCollection = None):
super().__init__()
self.label = label
self.context_creator = context_creator
self.canvases = canvases or TypedCollection(Canvas)
Expand Down
1 change: 1 addition & 0 deletions src/pyfdl/framing_decision.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ def __init__(
protection_dimensions: DimensionsFloat = None,
protection_anchor_point: Point = None
):
super().__init__()
self.label = label
self.id = id_
self.framing_intent_id = framing_intent_id
Expand Down
1 change: 1 addition & 0 deletions src/pyfdl/framing_intent.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ def __init__(
aspect_ratio: DimensionsInt = None,
protection: float = None
):
super().__init__()
self.id = id_
self.label = label
self.aspect_ratio = aspect_ratio
Expand Down
1 change: 1 addition & 0 deletions src/pyfdl/header.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ def __init__(
fdl_creator: str = None,
default_framing_intent: str = None
):
super().__init__()
self.uuid = _uuid
self.version = version
self.fdl_creator = fdl_creator
Expand Down
1 change: 1 addition & 0 deletions src/pyfdl/pyfdl.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ def __init__(
contexts: TypedCollection = None,
canvas_templates: TypedCollection = None
):
super().__init__()
self.uuid = _uuid
self.version = version
self.fdl_creator = fdl_creator
Expand Down

0 comments on commit c841804

Please sign in to comment.