Files
deb-python-pecan/pecan/tests/test_static.py
Ryan Petrello 7cdf9d3afd A handful of improvements:
* Fixing a few broken tests (https://github.com/dreamhost/pecan/issues/28)
* Removing py.test as a package requirement.
* Moving tests *into* the package.
* Adding code to use native unittest discovery (or unittest2 fallback).
2012-03-02 11:58:12 -05:00

26 lines
861 B
Python

import os
from pecan import expose, make_app
from webtest import TestApp
class TestStatic(object):
def test_simple_static(self):
class RootController(object):
@expose()
def index(self):
return 'Hello, World!'
# make sure Cascade is working properly
text = os.path.join(os.path.dirname(__file__), 'static/text.txt')
static_root = os.path.join(os.path.dirname(__file__), 'static')
app = TestApp(make_app(RootController(), static_root=static_root))
response = app.get('/index.html')
assert response.status_int == 200
assert response.body == 'Hello, World!'
# get a static resource
response = app.get('/text.txt')
assert response.status_int == 200
assert response.body == open(text, 'rb').read()