tests: check convert to sql errors using str() (#36515)
This commit is contained in:
parent
8c1fc39764
commit
31cc721510
|
@ -68,27 +68,27 @@ def test_command_exists():
|
|||
def test_unknown_publisher_fails(pub):
|
||||
with pytest.raises(CommandError) as excinfo:
|
||||
call_command('convert_to_sql', '-d', 'unknown.net', '--database', 'foobar')
|
||||
assert excinfo.value.message == 'unknown tenant'
|
||||
assert str(excinfo.value) == 'unknown tenant'
|
||||
|
||||
|
||||
def test_failing_connection(pub):
|
||||
with pytest.raises(psycopg2.OperationalError) as excinfo:
|
||||
call_command('convert_to_sql', '-d', 'example.net', '--database', 'foobar', '--port', '666')
|
||||
assert 'could not connect' in excinfo.value.message
|
||||
assert 'could not connect' in str(excinfo.value)
|
||||
|
||||
|
||||
def test_database_does_not_exist(pub):
|
||||
new_database = 'test_%s' % random.randint(1000, 9999)
|
||||
with pytest.raises(psycopg2.OperationalError) as excinfo:
|
||||
call_command('convert_to_sql', '-d', 'example.net', '--database', new_database)
|
||||
assert 'exist' in excinfo.value.message # works for english + french postgresql
|
||||
assert 'exist' in str(excinfo.value) # works for english + french postgresql
|
||||
|
||||
|
||||
def test_already_migrated_fails():
|
||||
pub = create_temporary_pub(sql_mode=True)
|
||||
with pytest.raises(CommandError) as excinfo:
|
||||
call_command('convert_to_sql', '-d', 'example.net', '--database', 'foobar')
|
||||
assert excinfo.value.message == 'tenant already using postgresql'
|
||||
assert str(excinfo.value) == 'tenant already using postgresql'
|
||||
cleanup_connection()
|
||||
force_connections_close()
|
||||
clean_temporary_pub()
|
||||
|
|
Loading…
Reference in New Issue