25개 이상의 토픽을 선택하실 수 없습니다. Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

mocks.py 1.1 KiB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. """Mocks for testing"""
  2. class MockInterval():
  3. """Mock Interval object for testing Feature"""
  4. def __init__(self, start, end):
  5. self.start = start
  6. self.end = end
  7. self.duration = end - start
  8. def to_json(self):
  9. return {"start": self.start, "end": self.end}
  10. class MockFeature():
  11. """Mock feature object for testing"""
  12. def __init__(self, interval, source=None, feature_extractor="mock", score=0.0):
  13. self.interval = interval
  14. self.source = source
  15. self.feature_extractor = feature_extractor
  16. self.score = score
  17. def to_json(self):
  18. return {"interval": self.interval}
  19. class MockSource():
  20. """Mock Source object for testing Feature"""
  21. def __init__(self, source=None, path=None):
  22. self.source = source
  23. self.path = path
  24. def __str__(self):
  25. return self.source
  26. def to_json(self):
  27. return {"source": self.source}
  28. def __eq__(self, other):
  29. return self.source == other.source
  30. def duration(self, duration=30.0):
  31. """Mock a float duration"""
  32. return duration