Add tested Parser Interface
This commit is contained in:
parent
70c626b748
commit
5d8bde959e
2 changed files with 32 additions and 4 deletions
|
@ -1,11 +1,16 @@
|
||||||
from habitmove.nomiedata import Event, Tracker
|
from __future__ import annotations
|
||||||
|
|
||||||
|
from habitmove.nomiedata import Event, ImportData, Tracker
|
||||||
|
|
||||||
|
|
||||||
class Parser:
|
class Parser:
|
||||||
def __init__(self, path: str, filename: str) -> None:
|
def parse(self, path: str, filename: str) -> ImportData:
|
||||||
"""Load in a data set"""
|
"""Load in a data set"""
|
||||||
self.path = path
|
raise NotImplementedError
|
||||||
self.filename = filename
|
|
||||||
|
def extract_version(self) -> str:
|
||||||
|
"""Extract import dataset version from the data set"""
|
||||||
|
raise NotImplementedError
|
||||||
|
|
||||||
def extract_trackers(self) -> list[Tracker]:
|
def extract_trackers(self) -> list[Tracker]:
|
||||||
"""Extract trackers from the data set"""
|
"""Extract trackers from the data set"""
|
||||||
|
@ -14,3 +19,7 @@ class Parser:
|
||||||
def extract_events(self) -> list[Event]:
|
def extract_events(self) -> list[Event]:
|
||||||
"""Extract events from the data set"""
|
"""Extract events from the data set"""
|
||||||
raise NotImplementedError
|
raise NotImplementedError
|
||||||
|
|
||||||
|
|
||||||
|
class NomieParser(Parser):
|
||||||
|
pass
|
||||||
|
|
19
tests/test_parser.py
Normal file
19
tests/test_parser.py
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
from habitmove.parser import Parser, NomieParser
|
||||||
|
|
||||||
|
|
||||||
|
def test_parser_interface_exists():
|
||||||
|
sut = Parser()
|
||||||
|
assert type(sut) == Parser
|
||||||
|
|
||||||
|
|
||||||
|
def test_parser_interface_contains_methods():
|
||||||
|
sut = Parser()
|
||||||
|
assert sut.__getattribute__("parse") != None
|
||||||
|
assert sut.__getattribute__("extract_version") != None
|
||||||
|
assert sut.__getattribute__("extract_trackers") != None
|
||||||
|
assert sut.__getattribute__("extract_events") != None
|
||||||
|
|
||||||
|
|
||||||
|
def test_nomie_parser_exists():
|
||||||
|
sut = NomieParser()
|
||||||
|
assert type(sut) == NomieParser
|
Loading…
Reference in a new issue