소스 검색

test: add mocks module for commonly-mocked objects

Includes:
 - MockInterval
 - MockFeature
 - MockSource
main
Rob Hallam 2 달 전
부모
커밋
3dc2a5c858
1개의 변경된 파일35개의 추가작업 그리고 0개의 파일을 삭제
  1. +35
    -0
      test/mocks.py

+ 35
- 0
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

불러오는 중...
취소
저장