Exemplo n.º 1
0
def test_check_database_connected_success(mocker):
    errors = checks.check_database_connected([])
    assert errors == []
Exemplo n.º 2
0
def test_check_database_connected_misconfigured(mocker):
    ensure_connection = mocker.patch('django.db.connection.ensure_connection')
    ensure_connection.side_effect = ImproperlyConfigured
    errors = checks.check_database_connected([])
    assert len(errors) == 1
    assert errors[0].id == checks.ERROR_MISCONFIGURED_DATABASE
Exemplo n.º 3
0
def test_check_database_connected_unsuable(mocker):
    mocker.patch('django.db.connection.is_usable', return_value=False)
    errors = checks.check_database_connected([])
    assert len(errors) == 1
    assert errors[0].id == checks.ERROR_UNUSABLE_DATABASE
Exemplo n.º 4
0
def test_check_database_connected_cannot_connect(mocker):
    ensure_connection = mocker.patch('django.db.connection.ensure_connection')
    ensure_connection.side_effect = OperationalError
    errors = checks.check_database_connected([])
    assert len(errors) == 1
    assert errors[0].id == checks.ERROR_CANNOT_CONNECT_DATABASE