Skip to content

Instantly share code, notes, and snippets.

@rhelmer
Created April 24, 2012 20:44
Show Gist options
  • Select an option

  • Save rhelmer/2483570 to your computer and use it in GitHub Desktop.

Select an option

Save rhelmer/2483570 to your computer and use it in GitHub Desktop.
def test_execute_postgres_with_acceptable_errors(self):
config_manager = self._setup_config_manager()
with config_manager.context() as config:
with setupdb_app.PostgreSQLManager('postgres') as db:
db.execute('CREATE DATABASE blah', ['not so good things'])
calls = self.psycopg2.mock_calls
self.assertEqual(calls[1], mock.call().set_isolation_level(0))
self.assertEqual(calls[2], mock.call().cursor())
self.assertEqual(calls[3], mock.call().cursor()
.execute('CREATE DATABASE blah'))
mock.call().throw(psycopg2.ProgrammingError('ERROR: very bad things'))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment