Пример #1
0
def test_import_application_failed_loader():
    """Test that _import_application fails with a module that is not found."""
    with pytest.raises(CommandError) as e:
        cli._import_application('mymodule:app')
        assert 'Unable to find an import loader' in e.message
Пример #2
0
def test_import_application_explicit_app(good_mock_service):
    """Test that an app can be explicitly specified."""
    _, actual = cli._import_application('good_import:app')
    assert isinstance(actual, Application)
Пример #3
0
def test_import_application_only_module():
    """Test that _import_application fails with an invalid application_path."""
    with pytest.raises(CommandError) as e:
        cli._import_application('mymodule')
        assert 'Unable to find an import loader for mymodule' in e.message
Пример #4
0
def test_import_application_app_autodetect(good_mock_service):
    """Test that an app can be selected automatically."""
    _, actual = cli._import_application('good_import')
    assert isinstance(actual, Application)
Пример #5
0
def test_import_application_callable(good_mock_service):
    """Test that an app can be loaded from a callable."""
    _, actual = cli._import_application('good_import:create_app')
    assert isinstance(actual, Application)
Пример #6
0
def test_import_application_non_henson_app():
    """Test that _import_application fails with the incorrect app type."""
    with pytest.raises(CommandError) as e:
        cli._import_application('logging:INFO')
        assert ("app must be an instance of a Henson application. Got "
                "<class 'int'>" in e.message)
Пример #7
0
def test_import_application_app_autodetect(good_mock_service):
    """Test that an app can be selected automatically."""
    _, actual = cli._import_application('good_import')
    assert isinstance(actual, Application)
Пример #8
0
def test_import_application_attribute_error():
    """Test that _import_application fails without an application attribute."""
    # NOTE: we don't need a real application here, just something that
    # doesn't have an attribute called `app`.
    with pytest.raises(AttributeError):
        cli._import_application('logging:app')
Пример #9
0
def test_import_application_non_henson_app():
    """Test that _import_application fails with the incorrect app type."""
    with pytest.raises(CommandError) as e:
        cli._import_application('logging:INFO')
        assert ("app must be an instance of a Henson application. Got "
                "<class 'int'>" in e.message)
Пример #10
0
def test_import_application_failed_loader():
    """Test that _import_application fails with a module that is not found."""
    with pytest.raises(CommandError) as e:
        cli._import_application('mymodule:app')
        assert 'Unable to find an import loader' in e.message
Пример #11
0
def test_import_application_failed_import(bad_mock_service):
    """Test that _import_application fails on dependency import errors."""
    with pytest.raises(ImportError):
        cli._import_application('bad_import:app')
Пример #12
0
def test_import_application_only_module():
    """Test that _import_application fails with an invalid application_path."""
    with pytest.raises(CommandError) as e:
        cli._import_application('mymodule')
        assert 'Unable to find an import loader for mymodule' in e.message
Пример #13
0
def test_import_application_explicit_app(good_mock_service):
    """Test that an app can be explicitly specified."""
    _, actual = cli._import_application('good_import:app')
    assert isinstance(actual, Application)
Пример #14
0
def test_import_application_callable(good_mock_service):
    """Test that an app can be loaded from a callable."""
    _, actual = cli._import_application('good_import:create_app')
    assert isinstance(actual, Application)
Пример #15
0
def test_import_application_failed_import(bad_mock_service):
    """Test that _import_application fails on dependency import errors."""
    with pytest.raises(ImportError):
        cli._import_application('bad_import:app')
Пример #16
0
def test_import_application_without_application():
    """Test that _import_applocation fails without an app name or instance."""
    with pytest.raises(CommandError) as e:
        cli._import_application('logging')
        assert 'No Henson application found' in e.message
Пример #17
0
def test_import_application_attribute_error():
    """Test that _import_application fails without an application attribute."""
    # NOTE: we don't need a real application here, just something that
    # doesn't have an attribute called `app`.
    with pytest.raises(AttributeError):
        cli._import_application('logging:app')
Пример #18
0
def test_import_application_with_two_applications(double_mock_service):
    """Test that _import_application fails with ambiguous app choices."""
    with pytest.raises(CommandError) as e:
        cli._import_application('double_service')
        assert 'More than one Henson application found' in e.message
Пример #19
0
def test_import_application_without_application():
    """Test that _import_applocation fails without an app name or instance."""
    with pytest.raises(CommandError) as e:
        cli._import_application('logging')
        assert 'No Henson application found' in e.message
Пример #20
0
def test_import_application_with_two_applications(double_mock_service):
    """Test that _import_application fails with ambiguous app choices."""
    with pytest.raises(CommandError) as e:
        cli._import_application('double_service')
        assert 'More than one Henson application found' in e.message