You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

53 lines
1.5 KiB

  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. @classmethod
  9. def from_duration(cls, duration):
  10. return cls(start=0, end=duration)
  11. def to_json(self):
  12. return {"start": self.start, "end": self.end}
  13. def __eq__(self, other):
  14. return self.start == other.start and self.end == other.end
  15. class MockFeature():
  16. """Mock feature object for testing"""
  17. def __init__(self, interval, source=None, feature_extractor="mock", score=0.0):
  18. self.interval = interval
  19. self.source = source
  20. self.feature_extractor = feature_extractor
  21. self.score = score
  22. def to_json(self):
  23. return {"interval": self.interval}
  24. def __eq__(self, other):
  25. return (self.interval == other.interval and self.source == other.source
  26. and self.feature_extractor == other.feature_extractor)
  27. class MockSource():
  28. """Mock Source object for testing Feature"""
  29. def __init__(self, source=None, path=None):
  30. self.source = source
  31. self.path = path
  32. def __str__(self):
  33. return self.source
  34. def to_json(self):
  35. return {"source": self.source}
  36. def __eq__(self, other):
  37. return self.source == other.source
  38. def duration(self, duration=30.0):
  39. """Mock a float duration"""
  40. return duration