added absolute paths for other static and template tests

This commit is contained in:
Alfredo Deza
2010-12-06 15:39:06 -05:00
parent be62d192c6
commit 5eda96b779
2 changed files with 16 additions and 9 deletions

View File

@@ -1,3 +1,4 @@
import os
from pecan import Pecan, expose, request, response, redirect
from webtest import TestApp
from formencode import Schema, validators
@@ -100,18 +101,20 @@ class TestBase(object):
class TestEngines(object):
template_path = os.path.join(os.path.dirname(__file__), 'templates')
def test_genshi(self):
class RootController(object):
@expose('genshi:genshi.html')
def index(self, name='Jonathan'):
return dict(name=name)
app = TestApp(Pecan(RootController(), template_path='tests/templates'))
app = TestApp(Pecan(RootController(), template_path=self.template_path))
r = app.get('/')
assert r.status_int == 200
assert "<h1>Hello, Jonathan!</h1>" in r.body
app = TestApp(Pecan(RootController(), template_path='tests/templates'))
app = TestApp(Pecan(RootController(), template_path=self.template_path))
r = app.get('/index.html?name=World')
assert r.status_int == 200
assert "<h1>Hello, World!</h1>" in r.body
@@ -122,12 +125,12 @@ class TestEngines(object):
def index(self, name='Jonathan'):
return dict(name=name)
app = TestApp(Pecan(RootController(), template_path='tests/templates'))
app = TestApp(Pecan(RootController(), template_path=self.template_path))
r = app.get('/')
assert r.status_int == 200
assert "<h1>Hello, Jonathan!</h1>" in r.body
app = TestApp(Pecan(RootController(), template_path='tests/templates'))
app = TestApp(Pecan(RootController(), template_path=self.template_path))
r = app.get('/index.html?name=World')
assert r.status_int == 200
assert "<h1>Hello, World!</h1>" in r.body
@@ -138,12 +141,12 @@ class TestEngines(object):
def index(self, name='Jonathan'):
return dict(name=name)
app = TestApp(Pecan(RootController(), template_path='tests/templates'))
app = TestApp(Pecan(RootController(), template_path=self.template_path))
r = app.get('/')
assert r.status_int == 200
assert "<h1>Hello, Jonathan!</h1>" in r.body
app = TestApp(Pecan(RootController(), template_path='tests/templates'))
app = TestApp(Pecan(RootController(), template_path=self.template_path))
r = app.get('/index.html?name=World')
assert r.status_int == 200
assert "<h1>Hello, World!</h1>" in r.body
@@ -253,4 +256,4 @@ class TestEngines(object):
app = TestApp(Pecan(RootController()))
r = app.get('/test/1/2/3/4')
assert r.status_int == 200
assert r.body == 'it worked'
assert r.body == 'it worked'

View File

@@ -1,3 +1,4 @@
import os
from pecan import expose, make_app
from webtest import TestApp
@@ -10,7 +11,10 @@ class TestStatic(object):
return 'Hello, World!'
# make sure Cascade is working properly
app = TestApp(make_app(RootController(), static_root='tests/static'))
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!'
@@ -18,4 +22,4 @@ class TestStatic(object):
# get a static resource
response = app.get('/text.txt')
assert response.status_int == 200
assert response.body == open('tests/static/text.txt', 'rb').read()
assert response.body == open(text, 'rb').read()