From 28a686d7eb0446632ffb9bb671d8f4af414a9250 Mon Sep 17 00:00:00 2001 From: Maciej Maciaszek Date: Mon, 29 Jun 2015 10:41:49 +0200 Subject: [PATCH] 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 --- tests/test_alarm_processor.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) mode change 100755 => 100644 tests/test_alarm_processor.py diff --git a/tests/test_alarm_processor.py b/tests/test_alarm_processor.py old mode 100755 new mode 100644 index 95ef7d4..0ecb7c2 --- a/tests/test_alarm_processor.py +++ b/tests/test_alarm_processor.py @@ -75,10 +75,12 @@ class TestAlarmProcessor(unittest.TestCase): def test_old_timestamp(self): """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", "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) + expected_datetime = time.ctime(timestamp / 1000) notifications, partition, offset = self._run_alarm_processor(alarm, None) @@ -87,7 +89,7 @@ class TestAlarmProcessor(unittest.TestCase): self.assertEqual(offset, 2) 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)