aboutsummaryrefslogtreecommitdiff
path: root/tests/test_views.py
blob: efb87bf80d8e5b96a9d082b6e8217cabeae37305 (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
from lesana import Collection

import cherrypy
from cherrypy.test import helper

from cherry_lesana import App


class TestNoCollection(helper.CPWebCase):
    def setup_server():
        cherrypy.tree.mount(App())
    setup_server = staticmethod(setup_server)

    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')