def test_create_test_db(self, *mocked_objects): creation = PostgreSQLDatabaseCreation(connection) # Simulate test database creation raising "database already exists" with self.patch_test_db_creation( self._execute_raise_database_already_exists): with mock.patch('builtins.input', return_value='no'): with self.assertRaises(SystemExit): # SystemExit is raised if the user answers "no" to the # prompt asking if it's okay to delete the test database. creation._create_test_db(verbosity=0, autoclobber=False, keepdb=False) # "Database already exists" error is ignored when keepdb is on creation._create_test_db(verbosity=0, autoclobber=False, keepdb=True) # Simulate test database creation raising unexpected error with self.patch_test_db_creation( self._execute_raise_permission_denied): with self.assertRaises(SystemExit): creation._create_test_db(verbosity=0, autoclobber=False, keepdb=False) with self.assertRaises(SystemExit): creation._create_test_db(verbosity=0, autoclobber=False, keepdb=True)
def check_sql_table_creation_suffix(self, settings, expected): with self.changed_test_settings(**settings): creation = PostgreSQLDatabaseCreation(connection) suffix = creation.sql_table_creation_suffix() self.assertEqual(suffix, expected)