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.
31 lines
809 B
31 lines
809 B
6 years ago
|
import unittest
|
||
|
import pandas as pd
|
||
|
|
||
|
from detectors import pattern_detector, threshold_detector
|
||
|
|
||
|
class TestPatternDetector(unittest.TestCase):
|
||
|
|
||
|
def test_small_dataframe(self):
|
||
|
|
||
|
data = [[0,1], [1,2]]
|
||
|
dataframe = pd.DataFrame(data, columns=['timestamp', 'values'])
|
||
|
cache = {'WINDOW_SIZE': 10}
|
||
|
|
||
|
detector = pattern_detector.PatternDetector('GENERAL', 'test_id')
|
||
|
|
||
|
with self.assertRaises(ValueError):
|
||
|
detector.detect(dataframe, cache)
|
||
|
|
||
|
|
||
|
class TestThresholdDetector(unittest.TestCase):
|
||
|
|
||
|
def test_invalid_cache(self):
|
||
|
|
||
|
detector = threshold_detector.ThresholdDetector()
|
||
|
|
||
|
with self.assertRaises(ValueError):
|
||
|
detector.detect([], None)
|
||
|
|
||
|
with self.assertRaises(ValueError):
|
||
|
detector.detect([], {})
|