Ejemplo n.º 1
0
    def test_symbols(self, mocked_get_logger):
        gpm['Feedback__limit_size'] = 1
        symbols_size = 100 * 1024 * 1023
        symbols = SymbolsFactory.create_batch(20, file_size=symbols_size)
        deleted_symbols = symbols[7]
        self.assertEqual(Symbols.objects.count(), 20)

        extra_meta = dict(count=10,
                          reason='manual',
                          meta=True,
                          log_id='36446dc3-ae7c-42ad-ae4e-6a826dcf0a00',
                          model='Symbols',
                          limit_duplicated=None,
                          limit_size=1,
                          limit_days=None,
                          size='999.0 MB')
        log_extra_msg = add_extra_to_log_message('Manual cleanup',
                                                 extra=extra_meta)

        extra = dict(id=deleted_symbols.id,
                     element_created=deleted_symbols.created.strftime(
                         "%d. %B %Y %I:%M%p"),
                     log_id='36446dc3-ae7c-42ad-ae4e-6a826dcf0a00')
        log_msg = add_extra_to_log_message('Manual 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))
            deferred_manual_cleanup(['crash', 'Symbols'], limit_size=1)
        self.assertEqual(mocked_logger.info.call_count, 11)
        mocked_logger.info.assert_any_call(log_extra_msg)
        mocked_logger.info.assert_any_call(log_msg)
Ejemplo n.º 2
0
    def test_symbols(self, mocked_get_logger):
        gpm['Feedback__limit_size'] = 1
        symbols_size = 100*1024*1023
        symbols = SymbolsFactory.create_batch(20, file_size=symbols_size)
        deleted_symbols = symbols[7]
        self.assertEqual(Symbols.objects.count(), 20)

        extra_meta = dict(count=10, reason='manual', meta=True, log_id='36446dc3-ae7c-42ad-ae4e-6a826dcf0a00',
                          model='Symbols', limit_duplicated=None, limit_size=1, limit_days=None, size='999.0 MB')
        log_extra_msg = add_extra_to_log_message('Manual cleanup', extra=extra_meta)

        extra = dict(Symbols_id=deleted_symbols.id, element_created=deleted_symbols.created.strftime("%d. %B %Y %I:%M%p"),
                     log_id='36446dc3-ae7c-42ad-ae4e-6a826dcf0a00')
        log_msg = add_extra_to_log_message('Manual 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))
            deferred_manual_cleanup(['crash', 'Symbols'], limit_size=1)
        self.assertEqual(mocked_logger.info.call_count, 11)
        mocked_logger.info.assert_any_call(log_extra_msg)
        mocked_logger.info.assert_any_call(log_msg)
Ejemplo n.º 3
0
 def test_get_size(self):
     file_size = 42
     SymbolsFactory.create_batch(10, file_size=file_size)
     size = Symbols.objects.get_size()
     self.assertEqual(size, file_size * 10)