Skip to content

Commit

Permalink
Merge pull request #2012 from selenamarie/bug983807-reprocessingjobs-…
Browse files Browse the repository at this point in the history
…test-fix

Fixes bug 983807 change reprocessing exception test to rename not remove table
  • Loading branch information
selenamarie committed Apr 19, 2014
2 parents 561cfe3 + dbbe59e commit 276964e
Showing 1 changed file with 23 additions and 15 deletions.
38 changes: 23 additions & 15 deletions socorro/unittest/cron/jobs/test_reprocessingjobs.py
Expand Up @@ -18,9 +18,7 @@ class IntegrationTestReprocessingJobs(IntegrationTestCaseBase):
def _clear_tables(self):
self.conn.cursor().execute("""
TRUNCATE
crontabber
, crontabber_log
--, reprocessing_jobs
reprocessing_jobs
CASCADE
""")

Expand Down Expand Up @@ -86,17 +84,27 @@ def test_reprocessing_exception(self):
cursor = self.conn.cursor()

# Test exception handling
cursor.execute('drop table reprocessing_jobs')
self.conn.commit()

with config_manager.context() as config:
tab = crontabber.CronTabber(config)
tab.run_all()

cursor.execute("""
select json_extract_path_text(last_error, 'type')
from crontabber
alter table reprocessing_jobs RENAME TO test_reprocessing_jobs
""")
res_expected = "<class 'psycopg2.ProgrammingError'>"
res, = cursor.fetchone()
eq_(res, res_expected)
# Need to commit this in order to test the exception handling
# because the crontabber invocation happens in a different Pg
# transaction.
self.conn.commit()

try:
with config_manager.context() as config:
tab = crontabber.CronTabber(config)
tab.run_all()

state = tab.job_database['reprocessing-jobs']
res_expected = "<class 'psycopg2.ProgrammingError'>"
res = state['last_error']['type']
eq_(res, res_expected)

finally:
# Change table name back
cursor.execute("""
alter table test_reprocessing_jobs RENAME TO reprocessing_jobs
""")
self.conn.commit()

0 comments on commit 276964e

Please sign in to comment.