aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/data/simple/.gitignore1
-rw-r--r--tests/data/simple/items/11189ee47ddf4796b718a483b379f976.yaml3
-rw-r--r--tests/data/simple/settings.yaml20
-rw-r--r--tests/test_views.py25
4 files changed, 47 insertions, 2 deletions
diff --git a/tests/data/simple/.gitignore b/tests/data/simple/.gitignore
new file mode 100644
index 0000000..17f377f
--- /dev/null
+++ b/tests/data/simple/.gitignore
@@ -0,0 +1 @@
+.lesana
diff --git a/tests/data/simple/items/11189ee47ddf4796b718a483b379f976.yaml b/tests/data/simple/items/11189ee47ddf4796b718a483b379f976.yaml
new file mode 100644
index 0000000..e1f7fc1
--- /dev/null
+++ b/tests/data/simple/items/11189ee47ddf4796b718a483b379f976.yaml
@@ -0,0 +1,3 @@
+name: Another item
+description: with just a short description
+position: somewhere
diff --git a/tests/data/simple/settings.yaml b/tests/data/simple/settings.yaml
new file mode 100644
index 0000000..20f35d8
--- /dev/null
+++ b/tests/data/simple/settings.yaml
@@ -0,0 +1,20 @@
+name: "Simple lesana collection"
+lang: 'english'
+entry_label: '{{ uid }}: {{ name }}'
+fields:
+ - name: name
+ type: string
+ index: free
+ - name: description
+ type: text
+ index: free
+ - name: position
+ type: string
+ index: facet
+ - name: quantity
+ type: integer
+ index: no
+ help: 'how many items are there'
+ - name: other
+ type: yaml
+ help: ''
diff --git a/tests/test_views.py b/tests/test_views.py
index 9c0c471..efb87bf 100644
--- a/tests/test_views.py
+++ b/tests/test_views.py
@@ -1,11 +1,12 @@
-import cherrypy
+from lesana import Collection
+import cherrypy
from cherrypy.test import helper
from cherry_lesana import App
-class TestViews(helper.CPWebCase):
+class TestNoCollection(helper.CPWebCase):
def setup_server():
cherrypy.tree.mount(App())
setup_server = staticmethod(setup_server)
@@ -13,3 +14,23 @@ class TestViews(helper.CPWebCase):
def test_root(self):
self.getPage('/')
self.assertStatus(200)
+
+ def test_list(self):
+ self.getPage('/list')
+ self.assertStatus(200)
+ self.assertInBody('No collection loaded')
+
+
+class TestSimpleCollection(helper.CPWebCase):
+ def setup_server():
+ collection = Collection('tests/data/simple')
+ collection.update_cache()
+ cherrypy.tree.mount(App(Collection('tests/data/simple')))
+ setup_server = staticmethod(setup_server)
+
+ def test_list(self):
+ self.getPage('/list')
+ self.assertStatus(200)
+ self.assertNotInBody('No collection loaded')
+ self.assertInBody('Simple lesana collection')
+ self.assertInBody('Another item')