Add fix for local time bug
The test 'test_old_timestamp' was not able to pass in different timezones due to hardcoded expected datetime Change `test_alarm_processor.py` permissions `test_alarm_processor.py` had different permissions than other test files. While `unittest` module could collect tests in this file, nosetests could't do it. Nose can collect tests in this file after permissions change Change-Id: I2b5791e7b352fbb0c05bc665b4000c412b63f1ef
This commit is contained in:
parent
c15a3471b9
commit
28a686d7eb
|
@ -75,10 +75,12 @@ class TestAlarmProcessor(unittest.TestCase):
|
||||||
|
|
||||||
def test_old_timestamp(self):
|
def test_old_timestamp(self):
|
||||||
"""Should cause the alarm_ttl to fire log a warning and push to finished queue."""
|
"""Should cause the alarm_ttl to fire log a warning and push to finished queue."""
|
||||||
|
timestamp = 1375346830042
|
||||||
alarm_dict = {"tenantId": "0", "alarmDefinitionId": "0", "alarmId": "1", "alarmName": "test Alarm",
|
alarm_dict = {"tenantId": "0", "alarmDefinitionId": "0", "alarmId": "1", "alarmName": "test Alarm",
|
||||||
"oldState": "OK", "newState": "ALARM", "stateChangeReason": "I am alarming!",
|
"oldState": "OK", "newState": "ALARM", "stateChangeReason": "I am alarming!",
|
||||||
"timestamp": 1375346830042, "actionsEnabled": 1, "metrics": "cpu_util"}
|
"timestamp": timestamp, "actionsEnabled": 1, "metrics": "cpu_util"}
|
||||||
alarm = self._create_raw_alarm(0, 2, alarm_dict)
|
alarm = self._create_raw_alarm(0, 2, alarm_dict)
|
||||||
|
expected_datetime = time.ctime(timestamp / 1000)
|
||||||
|
|
||||||
notifications, partition, offset = self._run_alarm_processor(alarm, None)
|
notifications, partition, offset = self._run_alarm_processor(alarm, None)
|
||||||
|
|
||||||
|
@ -87,7 +89,7 @@ class TestAlarmProcessor(unittest.TestCase):
|
||||||
self.assertEqual(offset, 2)
|
self.assertEqual(offset, 2)
|
||||||
|
|
||||||
old_msg = ('Received alarm older than the ttl, skipping. '
|
old_msg = ('Received alarm older than the ttl, skipping. '
|
||||||
'Alarm from Thu Aug 1 02:47:10 2013')
|
'Alarm from {datetime}'.format(datetime=expected_datetime))
|
||||||
|
|
||||||
self.assertIn(old_msg, self.trap)
|
self.assertIn(old_msg, self.trap)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue