summaryrefslogtreecommitdiff
path: root/tests/test_filter.py
blob: 6a4a69afcd8f6335df3806e167748457091dd9d4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
import os

import fakeapp.apps

from paste.deploy import loadapp

here = os.path.dirname(__file__)


def test_filter_app():
    app = loadapp('config:sample_configs/test_filter.ini#filt', relative_to=here)
    assert isinstance(app, fakeapp.apps.CapFilter)
    assert app.app is fakeapp.apps.basic_app
    assert app.method_to_call == 'lower'


def test_pipeline():
    app = loadapp('config:sample_configs/test_filter.ini#piped', relative_to=here)
    assert isinstance(app, fakeapp.apps.CapFilter)
    assert app.app is fakeapp.apps.basic_app
    assert app.method_to_call == 'upper'


def test_filter_app2():
    app = loadapp('config:sample_configs/test_filter.ini#filt2', relative_to=here)
    assert isinstance(app, fakeapp.apps.CapFilter)
    assert app.app is fakeapp.apps.basic_app
    assert app.method_to_call == 'lower'


def test_pipeline2():
    app = loadapp('config:sample_configs/test_filter.ini#piped2', relative_to=here)
    assert isinstance(app, fakeapp.apps.CapFilter)
    assert app.app is fakeapp.apps.basic_app
    assert app.method_to_call == 'upper'


def test_filter_app_inverted():
    app = loadapp('config:sample_configs/test_filter.ini#inv', relative_to=here)
    assert isinstance(app, fakeapp.apps.CapFilter)
    assert app.app is fakeapp.apps.basic_app


def test_filter_with_filter_with():
    app = loadapp('config:sample_configs/test_filter_with.ini', relative_to=here)
    assert isinstance(app, fakeapp.apps.CapFilter)
    assert isinstance(app.app, fakeapp.apps.CapFilter)
    assert app.app.app is fakeapp.apps.basic_app


def test_bad_pipeline():
    try:
        loadapp('config:sample_configs/test_filter.ini#piped3', relative_to=here)
    except LookupError as err:
        assert 'has extra (disallowed) settings' in err.args[0]
    else:
        raise AssertionError('should have raised LookupError')