def test_bad_args(self): """error states for coverage.""" # various bad values with self.assertRaises(ProcessorException): Align(dict()) with self.assertRaises(ProcessorException): Rate(dict()) with self.assertRaises(ProcessorException): self._simple_ts.align(method='bogus') with self.assertRaises(ProcessorException): self._simple_ts.align(limit='bogus') # non event types ticket_range = dict( name="outages", columns=["timerange", "title", "esnet_ticket"], points=[ [[1429673400000, 1429707600000], "BOOM", "ESNET-20080101-001"], [[1429673400000, 1429707600000], "BAM!", "ESNET-20080101-002"], ], ) ts = TimeSeries(ticket_range) with self.assertRaises(ProcessorException): ts.align() with self.assertRaises(ProcessorException): ts.rate()
def test_rate_mag(self): """test the rate processor order of mag.""" ts = TimeSeries(RATE) rate = ts.rate(field_spec='in') # one less than source self.assertEqual(rate.size(), len(RATE.get('points')) - 1) self.assertEqual(rate.at(2).get('in_rate'), 1) self.assertEqual(rate.at(3).get('in_rate'), 1) self.assertEqual(rate.at(4).get('in_rate'), 2) self.assertEqual(rate.at(8).get('in_rate'), 3) self.assertEqual(rate.at(9).get('in_rate'), 4)