Esempio n. 1
0
    def test_save(self, statsd_obj):
        config = self.setup_config('timing')
        cs =  StatsdBenchmarkingCrashStorage(config)
        now_str = 'socorro.external.statsd.statsd_base.datetime'
        with patch(now_str) as now_mock:
            times =  [
                datetime(2015, 5, 4, 15, 10, 3),
                datetime(2015, 5, 4, 15, 10, 2),
                datetime(2015, 5, 4, 15, 10, 1),
                datetime(2015, 5, 4, 15, 10, 0),
            ]
            now_mock.now.side_effect =  lambda: times.pop()
            config.wrapped_object_class.__name__ =  \
                'SomeWrappedCrashStoreClass'

            # the call to be tested
            cs.save_raw_crash({}, [], 'some_id')

            statsd_timing = statsd_obj.timing
            statsd_timing.has_calls(
                [call(
                    'timing.SomeWrappedCrashStoreClass.save_raw_crash',
                    1000
                )]
            )
            config.wrapped_object_class.return_value.save_raw_crash.has_calls(
                [call({}, [], 'some_id')]
            )
Esempio n. 2
0
    def test_save(self, statsd_obj):
        config = self.setup_config('timing')
        cs = StatsdBenchmarkingCrashStorage(config)
        now_str = 'socorro.external.statsd.statsd_base.datetime'
        with patch(now_str) as now_mock:
            times = [
                datetime(2015, 5, 4, 15, 10, 3),
                datetime(2015, 5, 4, 15, 10, 2),
                datetime(2015, 5, 4, 15, 10, 1),
                datetime(2015, 5, 4, 15, 10, 0),
            ]
            now_mock.now.side_effect = lambda: times.pop()
            config.wrapped_object_class.__name__ = 'SomeWrappedCrashStoreClass'

            # the call to be tested
            cs.save_raw_crash({}, [], 'some_id')

            statsd_timing = statsd_obj.timing
            statsd_timing.has_calls(
                [call(
                    'timing.SomeWrappedCrashStoreClass.save_raw_crash',
                    1000
                )]
            )
            config.wrapped_object_class.return_value.save_raw_crash.has_calls(
                [call({}, [], 'some_id')]
            )
Esempio n. 3
0
    def test_get(self, statsd_obj):
        config = self.setup_config('timing')
        cs =  StatsdBenchmarkingCrashStorage(config)
        now_str = 'socorro.external.statsd.statsd_base.datetime'
        with patch(now_str) as now_mock:
            times =  [
                datetime(2015, 5, 4, 15, 10, 3),
                datetime(2015, 5, 4, 15, 10, 2),
                datetime(2015, 5, 4, 15, 10, 1),
                datetime(2015, 5, 4, 15, 10, 0),
            ]
            now_mock.now.side_effect =  lambda: times.pop()
            wrapped_crashstore_instance = config.wrapped_object_class.return_value
            config.wrapped_object_class.__name__ =  \
                'SomeWrappedCrashStoreClass'
            raw_crash = {
                'crash_id': 'some_id',
                'data': 'payload',
            }
            wrapped_crashstore_instance.get_raw_crash.return_value = raw_crash

            # the call to be tested
            result =  cs.get_raw_crash('some_id')

            statsd_timing = statsd_obj.timing
            statsd_timing.has_calls(
                [call(
                    'timing.SomeWrappedCrashStoreClass.get_raw_crash',
                    1000
                )]
            )
            config.wrapped_object_class.return_value.save_raw_crash.has_calls(
                [call({}, [], 'some_id')]
            )
            eq_(result, raw_crash)
Esempio n. 4
0
    def test_get(self, statsd_obj):
        config = self.setup_config('timing')
        cs = StatsdBenchmarkingCrashStorage(config)
        now_str = 'socorro.external.statsd.statsd_base.datetime'
        with patch(now_str) as now_mock:
            times = [
                datetime(2015, 5, 4, 15, 10, 3),
                datetime(2015, 5, 4, 15, 10, 2),
                datetime(2015, 5, 4, 15, 10, 1),
                datetime(2015, 5, 4, 15, 10, 0),
            ]
            now_mock.now.side_effect = lambda: times.pop()
            wrapped_crashstore_instance = config.wrapped_object_class.return_value
            config.wrapped_object_class.__name__ = 'SomeWrappedCrashStoreClass'
            raw_crash = {
                'crash_id': 'some_id',
                'data': 'payload',
            }
            wrapped_crashstore_instance.get_raw_crash.return_value = raw_crash

            # the call to be tested
            result = cs.get_raw_crash('some_id')

            statsd_timing = statsd_obj.timing
            statsd_timing.has_calls(
                [call(
                    'timing.SomeWrappedCrashStoreClass.get_raw_crash',
                    1000
                )]
            )
            config.wrapped_object_class.return_value.save_raw_crash.has_calls(
                [call({}, [], 'some_id')]
            )
            assert result == raw_crash