| Index: sitescripts/notifications/test/parser.py |
| =================================================================== |
| --- a/sitescripts/notifications/test/parser.py |
| +++ b/sitescripts/notifications/test/parser.py |
| @@ -28,24 +28,24 @@ |
| file_stream = StringIO.StringIO(text) |
| tar_info = tarfile.TarInfo(name) |
| tar_info.size = len(file_stream.buf) |
| - with tarfile.open(mode="w", fileobj=archive_stream) as archive: |
| + with tarfile.open(mode='w', fileobj=archive_stream) as archive: |
| archive.addfile(tar_info, file_stream) |
| return archive_stream.getvalue() |
| def _format_time(time): |
| - return datetime.datetime.strftime(time, "%Y-%m-%dT%H:%M") |
| + return datetime.datetime.strftime(time, '%Y-%m-%dT%H:%M') |
| class TestParser(unittest.TestCase): |
| def setUp(self): |
| - self.call_patcher = mock.patch("subprocess.call") |
| + self.call_patcher = mock.patch('subprocess.call') |
| self.call_patcher.start() |
| - self.check_output_patcher = mock.patch("subprocess.check_output") |
| + self.check_output_patcher = mock.patch('subprocess.check_output') |
| check_output_mock = self.check_output_patcher.start() |
| def check_output_side_effect(command): |
| - if "hg" in command and "archive" in command: |
| + if 'hg' in command and 'archive' in command: |
| return _create_notification_archive(*self.notification_to_load) |
| check_output_mock.side_effect = check_output_side_effect |
| @@ -54,85 +54,85 @@ |
| self.check_output_patcher.stop() |
| def test_typical(self): |
| - self.notification_to_load = ("1", """ |
| + self.notification_to_load = ('1', ''' |
| severity = information |
| title.en-US = The title |
| message.en-US = The message |
| -""") |
| +''') |
| notifications = parser.load_notifications() |
| self.assertEqual(len(notifications), 1) |
| - self.assertEqual(notifications[0]["id"], "1") |
| - self.assertEqual(notifications[0]["severity"], "information") |
| - self.assertEqual(notifications[0]["title"]["en-US"], "The title") |
| - self.assertEqual(notifications[0]["message"]["en-US"], "The message") |
| - self.assertNotIn("inactive", notifications[0]) |
| + self.assertEqual(notifications[0]['id'], '1') |
| + self.assertEqual(notifications[0]['severity'], 'information') |
| + self.assertEqual(notifications[0]['title']['en-US'], 'The title') |
| + self.assertEqual(notifications[0]['message']['en-US'], 'The message') |
| + self.assertNotIn('inactive', notifications[0]) |
| def test_inactive(self): |
| - self.notification_to_load = ("1", """ |
| + self.notification_to_load = ('1', ''' |
| inactive = Yes |
| -""") |
| +''') |
| notifications = parser.load_notifications() |
| self.assertEqual(len(notifications), 1) |
| - self.assertTrue(notifications[0]["inactive"]) |
| - self.notification_to_load = ("1", """ |
| + self.assertTrue(notifications[0]['inactive']) |
| + self.notification_to_load = ('1', ''' |
| inactive = No |
| -""") |
| +''') |
| notifications = parser.load_notifications() |
| self.assertEqual(len(notifications), 1) |
| - self.assertFalse(notifications[0]["inactive"]) |
| + self.assertFalse(notifications[0]['inactive']) |
| def test_in_range(self): |
| current_time = datetime.datetime.now() |
| hour_delta = datetime.timedelta(hours=1) |
| start_time = current_time - hour_delta |
| end_time = current_time + hour_delta |
| - self.notification_to_load = ("1", """ |
| + self.notification_to_load = ('1', ''' |
| start = %s |
| end = %s |
| -""" % (_format_time(start_time), _format_time(end_time))) |
| +''' % (_format_time(start_time), _format_time(end_time))) |
| notifications = parser.load_notifications() |
| self.assertEqual(len(notifications), 1) |
| - self.assertEqual(notifications[0]["id"], "1") |
| - self.assertNotIn("inactive", notifications[0]) |
| + self.assertEqual(notifications[0]['id'], '1') |
| + self.assertNotIn('inactive', notifications[0]) |
| def test_after_range(self): |
| current_time = datetime.datetime.now() |
| start_time = current_time - datetime.timedelta(hours=2) |
| end_time = current_time - datetime.timedelta(hours=1) |
| - self.notification_to_load = ("1", """ |
| + self.notification_to_load = ('1', ''' |
| start = %s |
| end = %s |
| -""" % (_format_time(start_time), _format_time(end_time))) |
| +''' % (_format_time(start_time), _format_time(end_time))) |
| notifications = parser.load_notifications() |
| self.assertEqual(len(notifications), 1) |
| - self.assertTrue(notifications[0]["inactive"]) |
| + self.assertTrue(notifications[0]['inactive']) |
| def test_before_range(self): |
| current_time = datetime.datetime.now() |
| start_time = current_time + datetime.timedelta(hours=1) |
| end_time = current_time + datetime.timedelta(hours=2) |
| - self.notification_to_load = ("1", """ |
| + self.notification_to_load = ('1', ''' |
| start = %s |
| end = %s |
| -""" % (_format_time(start_time), _format_time(end_time))) |
| +''' % (_format_time(start_time), _format_time(end_time))) |
| notifications = parser.load_notifications() |
| self.assertEqual(len(notifications), 1) |
| - self.assertTrue(notifications[0]["inactive"]) |
| + self.assertTrue(notifications[0]['inactive']) |
| def test_start_and_end_not_present(self): |
| current_time = datetime.datetime.now() |
| hour_delta = datetime.timedelta(hours=1) |
| start_time = current_time - hour_delta |
| end_time = current_time + hour_delta |
| - self.notification_to_load = ("1", """ |
| + self.notification_to_load = ('1', ''' |
| start = %s |
| end = %s |
| -""" % (_format_time(start_time), _format_time(end_time))) |
| +''' % (_format_time(start_time), _format_time(end_time))) |
| notifications = parser.load_notifications() |
| self.assertEqual(len(notifications), 1) |
| - self.assertNotIn("inactive", notifications[0]) |
| - self.assertNotIn("start", notifications[0]) |
| - self.assertNotIn("end", notifications[0]) |
| + self.assertNotIn('inactive', notifications[0]) |
| + self.assertNotIn('start', notifications[0]) |
| + self.assertNotIn('end', notifications[0]) |
| -if __name__ == "__main__": |
| +if __name__ == '__main__': |
| unittest.main() |