From 5d8bde959eec1c70ad6bdc40393b3ad8e5fa4b2f Mon Sep 17 00:00:00 2001 From: Marty Oehme Date: Thu, 16 Dec 2021 13:11:49 +0100 Subject: [PATCH] Add tested Parser Interface --- src/habitmove/parser.py | 17 +++++++++++++---- tests/test_parser.py | 19 +++++++++++++++++++ 2 files changed, 32 insertions(+), 4 deletions(-) create mode 100644 tests/test_parser.py diff --git a/src/habitmove/parser.py b/src/habitmove/parser.py index f33499e..61141dd 100644 --- a/src/habitmove/parser.py +++ b/src/habitmove/parser.py @@ -1,11 +1,16 @@ -from habitmove.nomiedata import Event, Tracker +from __future__ import annotations + +from habitmove.nomiedata import Event, ImportData, Tracker class Parser: - def __init__(self, path: str, filename: str) -> None: + def parse(self, path: str, filename: str) -> ImportData: """Load in a data set""" - self.path = path - self.filename = filename + raise NotImplementedError + + def extract_version(self) -> str: + """Extract import dataset version from the data set""" + raise NotImplementedError def extract_trackers(self) -> list[Tracker]: """Extract trackers from the data set""" @@ -14,3 +19,7 @@ class Parser: def extract_events(self) -> list[Event]: """Extract events from the data set""" raise NotImplementedError + + +class NomieParser(Parser): + pass diff --git a/tests/test_parser.py b/tests/test_parser.py new file mode 100644 index 0000000..55cef76 --- /dev/null +++ b/tests/test_parser.py @@ -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