Пример #1
0
    def test_crashes(self, mocked_get_logger):
        gpm['Crash__duplicate_number'] = 2
        crashes = CrashFactory.create_batch(10, signature='test')
        deleted_crash = crashes[7]
        self.assertEqual(Crash.objects.all().count(), 10)

        extra_meta = dict(count=8,
                          reason='duplicated',
                          meta=True,
                          log_id='36446dc3-ae7c-42ad-ae4e-6a826dcf0a00',
                          model='Crash',
                          size='0 bytes')
        log_extra_msg = add_extra_to_log_message('Automatic cleanup',
                                                 extra=extra_meta)

        extra = dict(Crash_id=deleted_crash.id,
                     element_created=deleted_crash.created.strftime(
                         "%d. %B %Y %I:%M%p"),
                     signature=deleted_crash.signature,
                     userid=deleted_crash.userid,
                     appid=deleted_crash.appid,
                     log_id='36446dc3-ae7c-42ad-ae4e-6a826dcf0a00')
        log_msg = add_extra_to_log_message('Automatic cleanup element',
                                           extra=extra)

        mocked_logger = mocked_get_logger.return_value
        with patch('uuid.uuid4') as mocked_uuid4:
            mocked_uuid4.side_effect = (uuid.UUID(
                '36446dc3-ae7c-42ad-ae4e-6a826dcf0a%02d' % x)
                                        for x in range(100))
            auto_delete_duplicate_crashes()

        self.assertEqual(mocked_logger.info.call_count, 10)
        mocked_logger.info.assert_any_call(log_extra_msg)
        mocked_logger.info.assert_any_call(log_msg)
Пример #2
0
    def test_crashes(self, mocked_get_logger):
        gpm['Crash__duplicate_number'] = 2
        crashes = CrashFactory.create_batch(10, signature='test')
        deleted_crash = crashes[7]
        self.assertEqual(Crash.objects.all().count(), 10)

        extra_meta = dict(count=8, reason='duplicated', meta=True, log_id='36446dc3-ae7c-42ad-ae4e-6a826dcf0a00',
                          model='Crash', size='0 bytes')
        log_extra_msg = add_extra_to_log_message('Automatic cleanup', extra=extra_meta)

        extra = dict(Crash_id=deleted_crash.id, element_created=deleted_crash.created.strftime("%d. %B %Y %I:%M%p"),
                     signature=deleted_crash.signature, userid=deleted_crash.userid, appid=deleted_crash.appid,
                     log_id='36446dc3-ae7c-42ad-ae4e-6a826dcf0a00')
        log_msg = add_extra_to_log_message('Automatic cleanup element', extra=extra)

        mocked_logger = mocked_get_logger.return_value
        with patch('uuid.uuid4') as mocked_uuid4:
            mocked_uuid4.side_effect = (uuid.UUID('36446dc3-ae7c-42ad-ae4e-6a826dcf0a%02d' % x) for x in range(100))
            auto_delete_duplicate_crashes()

        self.assertEqual(mocked_logger.info.call_count, 10)
        mocked_logger.info.assert_any_call(log_extra_msg)
        mocked_logger.info.assert_any_call(log_msg)