Commit 0f06c710 authored by Tanguy Le Carrour's avatar Tanguy Le Carrour
Browse files

Fix domain.

parent 3fb6cbef
from abc import ABC
from abc import ABC, abstractmethod
from dataclasses import dataclass
import pathlib
@dataclass(frozen=True)
class Interval:
"""A time interval in seconds."""
start: int = 0
end: int = 0
def __post_init__(self) -> None:
if self.start >= self.end:
raise AttributeError(
"Start MUST be before end! ({self.start} >= {self.end})"
)
@dataclass(frozen=True)
class Path:
......@@ -26,13 +34,16 @@ class Path:
class Track(ABC):
@abstractmethod
def extract(self, an_interval: Interval) -> "Track":
raise NotImplementedError()
class Tracks(ABC):
@abstractmethod
def __getitem__(self, a_path: str) -> Track:
raise NotImplementedError()
@abstractmethod
def __setitem__(self, a_path: str, a_track: Track) -> None:
raise NotImplementedError()
from mamba import describe, it, _it # type: ignore
from mamba import describe, it # type: ignore
from robber import expect # type: ignore
from splito.domain.audio_editing.model import Interval, Path
from splito.domain.audio_editing.model import Interval, Path, Track, Tracks
with describe(Interval):
......@@ -13,14 +13,14 @@ with describe(Interval):
expect(action).not_to.throw(Exception)
with _it("does not build if start is after end"):
with it("does not build if start is after end"):
def action() -> None:
_ = Interval(1, 0)
expect(action).to.throw(Exception)
with _it("does not build if start is equal to end"):
with it("does not build if start is equal to end"):
def action() -> None:
_ = Interval(1, 1)
......@@ -52,3 +52,33 @@ with describe(Path):
path = path.with_suffix(".suffix")
expect(path).to.eq(Path.from_string("a_path/a_file.suffix.ext"))
with describe(Track):
with it("is an interface"):
pass
with describe(Track.extract):
with it("extracts a sub-track"):
pass
with describe(Tracks):
with it("is an interface"):
pass
with describe(Tracks.__getitem__):
with it("returns a track if it exists"):
pass
with it("raises a key error if the track does not exist"):
pass
with describe(Tracks.__setitem__):
with it("saves a track"):
pass
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment