예제 #1
0
    def test_save_raw_and_processed(self):
        config = self.get_standard_config()
        db_sampling = DBCrashStorageWrapperNewCrashSource(config)
        crash_id = '86b58ff2-9708-487d-bfc4-9dac32121214'

        fake_raw_crash = SocorroDotDict({
            "name": "Gabi",
            "submitted_timestamp": "2012-12-14T00:00:00"
        })
        fake_dumps_as_files = FileDumpsMapping({
            'upload_file_minidump':
                '86b58ff2-9708-487d-bfc4-9dac32121214'
                '.upload_file_minidump.TEMPORARY.dump'
        })
        fake_processed = SocorroDotDict({
            "name": "Gabi",
            "submitted_timestamp": "2012-12-14T00:00:00"
        })

        # the call to be tested
        db_sampling.save_raw_and_processed(
            fake_raw_crash,
            fake_dumps_as_files,
            fake_processed,
            crash_id
        )

        # this is what should have happened
        db_sampling._implementation.save_raw_and_processed \
            .assert_called_once_with(
                fake_raw_crash,
                fake_dumps_as_files,
                fake_processed,
                crash_id
            )
예제 #2
0
    def test_save_raw_and_processed(self):
        config = self.get_standard_config()
        db_sampling = DBCrashStorageWrapperNewCrashSource(config)
        crash_id = '86b58ff2-9708-487d-bfc4-9dac32121214'

        fake_raw_crash = SocorroDotDict({
            "name": "Gabi",
            "submitted_timestamp": "2012-12-14T00:00:00"
        })
        fake_dumps_as_files = FileDumpsMapping({
            'upload_file_minidump':
                '86b58ff2-9708-487d-bfc4-9dac32121214'
                '.upload_file_minidump.TEMPORARY.dump'
        })
        fake_processed = SocorroDotDict({
            "name": "Gabi",
            "submitted_timestamp": "2012-12-14T00:00:00"
        })

        # the call to be tested
        db_sampling.save_raw_and_processed(
            fake_raw_crash,
            fake_dumps_as_files,
            fake_processed,
            crash_id
        )

        # this is what should have happened
        db_sampling._implementation.save_raw_and_processed \
            .assert_called_once_with(
                fake_raw_crash,
                fake_dumps_as_files,
                fake_processed,
                crash_id
            )
예제 #3
0
    def test_remove(self):
        config = self.get_standard_config()
        db_sampling = DBCrashStorageWrapperNewCrashSource(config)
        crash_id = '86b58ff2-9708-487d-bfc4-9dac32121214'

        # the call to be tested
        db_sampling.remove(crash_id)

        # this is what should have happened
        db_sampling._implementation.remove.assert_called_with(crash_id)
예제 #4
0
    def test_remove(self):
        config = self.get_standard_config()
        db_sampling = DBCrashStorageWrapperNewCrashSource(config)
        crash_id = '86b58ff2-9708-487d-bfc4-9dac32121214'

        # the call to be tested
        db_sampling.remove(crash_id)

        # this is what should have happened
        db_sampling._implementation.remove \
            .assert_called_with(crash_id)
예제 #5
0
    def test_new_crashes(self):
        config = self.get_standard_config()
        db_sampling = DBCrashStorageWrapperNewCrashSource(config)

        # the call to be tested & what should have happened
        for i, (exp, actual) in enumerate(
                izip_longest(self.expected_sequence,
                             db_sampling.new_crashes())):
            assert exp == actual

        assert i == 4
예제 #6
0
    def test_new_crashes(self):
        config = self.get_standard_config()
        db_sampling = DBCrashStorageWrapperNewCrashSource(config)

        # the call to be tested & what should have happened
        for i, (exp, actual) in enumerate(
                izip_longest(self.expected_sequence,
                             db_sampling.new_crashes())):
            eq_(exp, actual)

        eq_(
            i, 4, 'there should have been exactly 5 iterations, instead: %d' %
            (i + 1))
예제 #7
0
    def test_save_processed(self):
        config = self.get_standard_config()
        db_sampling = DBCrashStorageWrapperNewCrashSource(config)

        fake_processed = SocorroDotDict({
            "name": "Gabi",
            "submitted_timestamp": "2012-12-14T00:00:00"
        })

        # the call to be tested
        db_sampling.save_processed(fake_processed)

        # this is what should have happened
        db_sampling._implementation.save_processed.assert_called_once_with(
            fake_processed
        )
예제 #8
0
    def test_get_raw_dump(self):
        config = self.get_standard_config()
        db_sampling = DBCrashStorageWrapperNewCrashSource(config)

        crash_id = '86b58ff2-9708-487d-bfc4-9dac32121214'
        fake_dump = 'contents of dump 86b58ff2-9708-487d-bfc4-9dac32121214'
        mocked_get_raw_dump = Mock(return_value=fake_dump)
        db_sampling._implementation.get_raw_dump = mocked_get_raw_dump

        # the call to be tested
        raw_dump = db_sampling.get_raw_dump(crash_id, 'fred')

        # this is what should have happened
        assert fake_dump is raw_dump
        db_sampling._implementation.get_raw_dump.assert_called_with(
            crash_id, 'fred')
예제 #9
0
    def test_save_processed(self):
        config = self.get_standard_config()
        db_sampling = DBCrashStorageWrapperNewCrashSource(config)

        fake_processed = SocorroDotDict({
            "name": "Gabi",
            "submitted_timestamp": "2012-12-14T00:00:00"
        })

        # the call to be tested
        db_sampling.save_processed(fake_processed)

        # this is what should have happened
        db_sampling._implementation.save_processed.assert_called_once_with(
            fake_processed
        )
예제 #10
0
    def test_init_and_close(self):
        config = self.get_standard_config()

        # the calls to be tested
        db_sampling = DBCrashStorageWrapperNewCrashSource(config)
        db_sampling.close()

        # this is what should have happened
        assert db_sampling.config is config
        config.database_class.assert_called_once_with(config)
        config.transaction_executor_class.assert_called_once_with(
            config, db_sampling.database, quit_check_callback=None)
        config.implementation.crashstorage_class.assert_called_once_with(
            config.implementation, None)
        db_sampling.database.close.assert_called_once_with()
        db_sampling._implementation.close.assert_called_once_with()
예제 #11
0
    def test_new_crashes(self):
        config = self.get_standard_config()
        db_sampling = DBCrashStorageWrapperNewCrashSource(config)

        # the call to be tested & what should have happened
        for i, (exp, actual) in enumerate(izip_longest(
            self.expected_sequence,
            db_sampling.new_crashes())
        ):
            eq_(exp, actual)

        eq_(
            i,
            4,
            'there should have been exactly 5 iterations, instead: %d'
            % (i + 1)
        )
예제 #12
0
    def test_get_raw_dumps(self):
        config = self.get_standard_config()
        db_sampling = DBCrashStorageWrapperNewCrashSource(config)

        crash_id = '86b58ff2-9708-487d-bfc4-9dac32121214'
        fake_raw_dumps = MemoryDumpsMapping({
            'upload_file_minidump':
                'contents of dump 86b58ff2-9708-487d-bfc4-9dac32121214'
        })
        mocked_get_raw_dumps = Mock(return_value=fake_raw_dumps)
        db_sampling._implementation.get_raw_dumps = mocked_get_raw_dumps

        # the call to be tested
        raw_dumps = db_sampling.get_raw_dumps(crash_id)

        # this is what should have happened
        ok_(fake_raw_dumps is raw_dumps)
        db_sampling._implementation.get_raw_dumps.assert_called_with(crash_id)
예제 #13
0
    def test_get_raw_dumps(self):
        config = self.get_standard_config()
        db_sampling = DBCrashStorageWrapperNewCrashSource(config)

        crash_id = '86b58ff2-9708-487d-bfc4-9dac32121214'
        fake_raw_dumps = MemoryDumpsMapping({
            'upload_file_minidump':
                'contents of dump 86b58ff2-9708-487d-bfc4-9dac32121214'
        })
        mocked_get_raw_dumps = Mock(return_value=fake_raw_dumps)
        db_sampling._implementation.get_raw_dumps = mocked_get_raw_dumps

        # the call to be tested
        raw_dumps = db_sampling.get_raw_dumps(crash_id)

        # this is what should have happened
        ok_(fake_raw_dumps is raw_dumps)
        db_sampling._implementation.get_raw_dumps.assert_called_with(crash_id)
예제 #14
0
    def test_get_processed(self):
        config = self.get_standard_config()
        db_sampling = DBCrashStorageWrapperNewCrashSource(config)

        crash_id = '86b58ff2-9708-487d-bfc4-9dac32121214'
        fake_processed = SocorroDotDict({
            "name": "Gabi",
            "submitted_timestamp": "2012-12-14T00:00:00"
        })

        mocked_get_processed = Mock(return_value=fake_processed)
        db_sampling._implementation.get_processed = mocked_get_processed

        # the call to be tested
        processed = db_sampling.get_processed(crash_id)

        # this is what should have happened
        ok_(fake_processed is processed)
        db_sampling._implementation.get_processed.assert_called_with(crash_id)
예제 #15
0
    def test_get_processed(self):
        config = self.get_standard_config()
        db_sampling = DBCrashStorageWrapperNewCrashSource(config)

        crash_id = '86b58ff2-9708-487d-bfc4-9dac32121214'
        fake_processed = SocorroDotDict({
            "name": "Gabi",
            "submitted_timestamp": "2012-12-14T00:00:00"
        })

        mocked_get_processed = Mock(return_value=fake_processed)
        db_sampling._implementation.get_processed = mocked_get_processed

        # the call to be tested
        processed = db_sampling.get_processed(crash_id)

        # this is what should have happened
        ok_(fake_processed is processed)
        db_sampling._implementation.get_processed.assert_called_with(crash_id)
예제 #16
0
    def test_get_raw_dumps_as_files(self):
        config = self.get_standard_config()
        db_sampling = DBCrashStorageWrapperNewCrashSource(config)

        crash_id = '86b58ff2-9708-487d-bfc4-9dac32121214'
        fake_dumps_as_files = FileDumpsMapping({
            'upload_file_minidump':
            '86b58ff2-9708-487d-bfc4-9dac32121214'
            '.upload_file_minidump.TEMPORARY.dump'
        })
        mocked_get_raw_dumps_as_files = Mock(return_value=fake_dumps_as_files)
        db_sampling._implementation.get_raw_dumps_as_files = mocked_get_raw_dumps_as_files

        # the call to be tested
        raw_dumps_as_files = db_sampling.get_raw_dumps_as_files(crash_id)

        # this is what should have happened
        assert fake_dumps_as_files is raw_dumps_as_files
        db_sampling._implementation.get_raw_dumps_as_files.assert_called_with(
            crash_id)
예제 #17
0
    def test_get_raw_dump(self):
        config = self.get_standard_config()
        db_sampling = DBCrashStorageWrapperNewCrashSource(config)

        crash_id = '86b58ff2-9708-487d-bfc4-9dac32121214'
        fake_dump = 'contents of dump 86b58ff2-9708-487d-bfc4-9dac32121214'
        mocked_get_raw_dump = Mock(return_value=fake_dump)
        db_sampling._implementation.get_raw_dump = mocked_get_raw_dump

        # the call to be tested
        raw_dump = db_sampling.get_raw_dump(
            crash_id,
            'fred'
        )

        # this is what should have happened
        ok_(fake_dump is raw_dump)
        db_sampling._implementation.get_raw_dump.assert_called_with(
            crash_id,
            'fred'
        )
예제 #18
0
    def test_init_and_close(self):
        config = self.get_standard_config()

        # the calls to be tested
        db_sampling = DBCrashStorageWrapperNewCrashSource(config)
        db_sampling.close()

        # this is what should have happened
        ok_(db_sampling.config is config)
        config.database_class.assert_called_once_with(config)
        config.transaction_executor_class.assert_called_once_with(
            config,
            db_sampling.database,
            quit_check_callback=None
        )
        config.implementation.crashstorage_class.assert_called_once_with(
            config.implementation,
            None
        )
        db_sampling.database.close.assert_called_once_with()
        db_sampling._implementation.close.assert_called_once_with()