Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Fixes Bug 1007242 - corrected SQL parameters & added get_raw_crash test #2047

Merged
merged 1 commit into from

3 participants

@twobraids
Owner

Adrian was quite correct, that SQL statement could never have worked and a unit test would have discovered that flaw. I offer the correction.

@peterbe
Owner

r+

@AdrianGaudebert

Thanks Lars! \o/

@AdrianGaudebert AdrianGaudebert merged commit bf58dbe into from
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
View
2  socorro/external/postgresql/crashstorage.py
@@ -161,7 +161,7 @@ def _get_raw_crash_transaction(self, connection, crash_id):
raw_crash_table_name = (
'raw_crash_%s' % self._table_suffix_for_crash_id(crash_id)
)
- fetch_sql = 'select raw_crash from %s where uuid = %ss' % \
+ fetch_sql = 'select raw_crash from %s where uuid = %%s' % \
raw_crash_table_name
try:
return single_value_sql(connection, fetch_sql, (crash_id,))
View
42 socorro/unittest/external/postgresql/test_crashstorage.py
@@ -589,3 +589,45 @@ def broken_connection(*args):
actual_sql = remove_whitespace(actual_sql)
eq_(expected_sql, actual_sql)
eq_(expected_params, actual_params)
+
+ def test_get_raw_crash(self):
+ mock_logging = mock.Mock()
+ mock_postgres = mock.Mock()
+ mock_postgres.return_value = mock.MagicMock()
+
+ required_config = PostgreSQLCrashStorage.get_required_config()
+ required_config.add_option('logger', default=mock_logging)
+
+ config_manager = ConfigurationManager(
+ [required_config],
+ app_name='testapp',
+ app_version='1.0',
+ app_description='app description',
+ values_source_list=[{
+ 'logger': mock_logging,
+ 'database_class': mock_postgres,
+ 'transaction_executor_class':
+ TransactionExecutorWithLimitedBackoff,
+ 'backoff_delays': [0, 0, 0],
+ }],
+ argv_source=[]
+ )
+
+ with config_manager.context() as config:
+ a_crash_id = "936ce666-ff3b-4c7a-9674-367fe2120408"
+ crashstorage = PostgreSQLCrashStorage(config)
+ connection = crashstorage.database.return_value.__enter__.return_value
+ connection.cursor.return_value.fetchall.return_value = [[
+ {
+ 'uuid': a_crash_id,
+ }
+ ]]
+
+ a_crash = crashstorage.get_raw_crash(a_crash_id)
+
+ ok_(a_crash['uuid'] == a_crash_id)
+ connection.cursor.return_value.execute. \
+ assert_called_with(
+ 'select raw_crash from raw_crash_20120402 where uuid = %s',
+ ('936ce666-ff3b-4c7a-9674-367fe2120408',)
+ )
Something went wrong with that request. Please try again.