# -*- coding: utf-8 -*-
import unittest
import monitoring as mon


class RecordTestCase(unittest.TestCase):

    def testRecordValueList(self):
        r = mon.Record(values=[1, 2, 3])
        self.assertEqual(r.values, [1, 2, 3])

    def testRecordSingleValue(self):
        r = mon.Record(values=1)
        self.assertEqual(r.values, [1])

    def testRecordLoggerOrigin(self):
        r = mon.Record(values=[1, 2, 3])
        self.assertEqual(r.origin, 'logger')

    def testRecordSampleOrigin(self):
        r = mon.Record(values=1)
        self.assertEqual(r.origin, 'sample')

    def testRecordTimesList(self):
        r = mon.Record(values=[1, 2, 3], startTime=0, interval=10)
        self.assertEqual(r.times, [0, 10, 20])

    def testRecordEndTime(self):
        r = mon.Record(values=[1, 2, 3], startTime=0, interval=10)
        self.assertEqual(r.endTime, 20)

    def testRecordLength(self):
        r = mon.Record(values=[1, 2, 3])
        self.assertEqual(len(r), 3)

    def testRecordSingleTime(self):
        r = mon.Record(values=1, startTime=0)
        self.assertEqual(r.times, [0])

    def testRecordIrregularInterval(self):
        r = mon.Record(values=1)
        self.assertEqual(r.interval, -1)

    def testRecordIrregularIntervalForce(self):
        """Single-value records always treated as irregular"""
        r = mon.Record(values=1, interval=999)
        self.assertEqual(r.interval, -1)
        
    def testIntervalStr15Min(self):
        r = mon.Record(interval=15)
        self.assertEqual(r.intervalStr, '15MIN')

    def testIntervalStr59Min(self):
        r = mon.Record(interval=59)
        self.assertEqual(r.intervalStr, '59MIN')

    def testIntervalStr1Hour(self):
        r = mon.Record(interval=60)
        self.assertEqual(r.intervalStr, '1HOUR')

    def testIntervalStr23Hour(self):
        r = mon.Record(interval=23*60)
        self.assertEqual(r.intervalStr, '23HOUR')

    def testIntervalStr1Day(self):
        r = mon.Record(interval=24*60)
        self.assertEqual(r.intervalStr, '1DAY')

    def testIntervalStr2Day(self):
        r = mon.Record(interval=24*60*2)
        self.assertEqual(r.intervalStr, '2DAY')


if __name__ == '__main__':
    unittest.main()


@@ -1497,18 +1497,33 @@
 erval=15
+, values=%5B1, 2%5D
 )%0A
-
         
@@ -1634,16 +1634,31 @@
 erval=59
+, values=%5B1, 2%5D
 )%0A      
@@ -1771,16 +1771,31 @@
 erval=60
+, values=%5B1, 2%5D
 )%0A      
@@ -1912,16 +1912,31 @@
 al=23*60
+, values=%5B1, 2%5D
 )%0A      
@@ -2052,16 +2052,31 @@
 al=24*60
+, values=%5B1, 2%5D
 )%0A      
@@ -2145,32 +2145,32 @@
 lStr2Day(self):%0A
-
         r = mon.
@@ -2192,16 +2192,31 @@
 =24*60*2
+, values=%5B1, 2%5D
 )%0A      

fix regular interval tests