From 3dc2a5c85840d3ee61bedd998def5548dc85cb47 Mon Sep 17 00:00:00 2001 From: Rob Hallam <0504004h@student.gla.ac.uk> Date: Thu, 22 Aug 2024 13:21:02 +0100 Subject: [PATCH] test: add mocks module for commonly-mocked objects Includes: - MockInterval - MockFeature - MockSource --- test/mocks.py | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 test/mocks.py diff --git a/test/mocks.py b/test/mocks.py new file mode 100644 index 0000000..a9153e9 --- /dev/null +++ b/test/mocks.py @@ -0,0 +1,35 @@ +"""Mocks for testing""" + +class MockInterval(): + """Mock Interval object for testing Feature""" + def __init__(self, start, end): + self.start = start + self.end = end + self.duration = end - start + + def to_json(self): + return {"start": self.start, "end": self.end} + +class MockFeature(): + """Mock feature object for testing""" + def __init__(self, interval, source=None): + self.interval = interval + self.source = source + + def to_json(self): + return {"interval": self.interval} + +class MockSource(): + """Mock Source object for testing Feature""" + def __init__(self, source=None, path=None): + self.source = source + self.path = path + + def __str__(self): + return self.source + + def to_json(self): + return {"source": self.source} + + def __eq__(self, other): + return self.source == other.source