예제 #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