summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/sample_configs/test_func.ini13
-rw-r--r--tests/test_config.py28
2 files changed, 41 insertions, 0 deletions
diff --git a/tests/sample_configs/test_func.ini b/tests/sample_configs/test_func.ini
new file mode 100644
index 0000000..a0d28c4
--- /dev/null
+++ b/tests/sample_configs/test_func.ini
@@ -0,0 +1,13 @@
+[application:main]
+use = call:fakeapp.apps:make_basic_app
+
+[application:other]
+use = call:fakeapp.apps:make_basic_app2
+
+[composit:remote_addr]
+use = call:fakeapp.apps:make_remote_addr
+app.1 = main
+addr.1 = 127.0.0.1
+
+app.2 = other
+addr.2 = 0.0.0.0 \ No newline at end of file
diff --git a/tests/test_config.py b/tests/test_config.py
index b6cd158..6dee066 100644
--- a/tests/test_config.py
+++ b/tests/test_config.py
@@ -3,6 +3,7 @@ from nose.tools import eq_
from paste.deploy import loadapp, appconfig
from tests.fixture import *
import fakeapp.configapps as fc
+import fakeapp.apps
ini_file = 'config:sample_configs/test_config.ini'
@@ -62,6 +63,33 @@ def test_config3():
test_config2()
+def test_main():
+ app = loadapp('config:test_func.ini',
+ relative_to=config_path)
+ assert app is fakeapp.apps.basic_app
+ app = loadapp('config:test_func.ini#main',
+ relative_to=config_path)
+ assert app is fakeapp.apps.basic_app
+ app = loadapp('config:test_func.ini',
+ relative_to=config_path, name='main')
+ assert app is fakeapp.apps.basic_app
+ app = loadapp('config:test_func.ini#ignored',
+ relative_to=config_path, name='main')
+ assert app is fakeapp.apps.basic_app
+
+
+def test_other():
+ app = loadapp('config:test_func.ini#other', relative_to=config_path)
+ assert app is fakeapp.apps.basic_app2
+
+
+def test_composit():
+ app = loadapp('config:test_func.ini#remote_addr', relative_to=config_path)
+ assert isinstance(app, fakeapp.apps.RemoteAddrDispatch)
+ assert app.map['127.0.0.1'] is fakeapp.apps.basic_app
+ assert app.map['0.0.0.0'] is fakeapp.apps.basic_app2
+
+
def test_foreign_config():
app = loadapp(ini_file, relative_to=here, name='test_foreign_config')
assert isinstance(app, fc.SimpleApp)