aboutsummaryrefslogtreecommitdiff
path: root/tests/test_app.py
blob: f78149b86a9570395e0dea57706458e1a708487c (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
from tornado.testing import AsyncHTTPTestCase

from pyapd import app, config, objects


class TestApp(AsyncHTTPTestCase):
    def get_app(self, *args, **kw):
        if not getattr(self, 'app', None):
            self.app = app.App(config.Config('tests/data/test_config.yaml'))
        return self.app

    def test_root(self):
        res = self.fetch('/')
        self.assertEqual(res.code, 200)

    def test_object_view(self):
        oid = self.get_url('/object/12345')
        obj = objects.Object(id=oid)
        self.app.store.add(obj)
        res = self.fetch('/object/12345')
        self.assertEqual(res.code, 200)

    def test_object_view_non_existing(self):
        res = self.fetch('/object/does_not_exist')
        self.assertEqual(res.code, 404)