Commit 45ff3605 authored by Tanguy Le Carrour's avatar Tanguy Le Carrour
Browse files

Implement a Path class in the domain.

parent b139daf9
from abc import ABC
from dataclasses import dataclass
import pathlib
......@@ -8,6 +9,22 @@ class Interval:
end: int = 0
class Path:
__path: str
def from_string(cls, a_string: str) -> "Path":
return Path(a_string)
def __str__(self) -> str:
return self.__path
def with_suffix(self, a_suffix: str) -> "Path":
path = pathlib.Path(self.__path)
return Path(str(path.with_suffix(f"{a_suffix}{path.suffix}")))
class Track(ABC):
def extract(self, an_interval: Interval) -> "Track":
raise NotImplementedError()
from mamba import describe, it, _it # type: ignore
from robber import expect # type: ignore
from splito.domain.audio_editing.model import Interval
from splito.domain.audio_editing.model import Interval, Path
with describe(Interval):
......@@ -26,3 +26,29 @@ with describe(Interval):
_ = Interval(1, 1)
with describe(Path):
with describe(Path.from_string):
with it("returns a Path object"):
path = Path.from_string("a_path/a_file.ext")
with describe(Path.__str__):
with it("returns the actual path as a string"):
path = Path.from_string("a_path/a_file.ext")
with describe(Path.with_suffix):
with it("returns a new Path object with an extra suffix"):
path = Path.from_string("a_path/a_file.ext")
path = path.with_suffix(".suffix")
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