Skip to content

Commit

Permalink
Add more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Maxim Avanov committed Jan 6, 2014
1 parent e7c878c commit dcd16fb
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 10 deletions.
2 changes: 1 addition & 1 deletion tests/testapp/testapp/index/views.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from rhetoric import view_config


@view_config(route_name='index.dashboard')
@view_config(route_name='index.dashboard', renderer='index.html')
def dashboard(request):
return {}
8 changes: 7 additions & 1 deletion tests/testapp/testapp/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@
For the full list of settings and their values, see
https://docs.djangoproject.com/en/1.6/ref/settings/
"""

# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
import os


BASE_DIR = os.path.dirname(os.path.dirname(__file__))
PROJECT_PATH = os.path.dirname(os.path.realpath(__file__))


# Quick-start development settings - unsuitable for production
Expand All @@ -24,6 +26,10 @@

TEMPLATE_DEBUG = True

TEMPLATE_DIRS = (
os.path.join(PROJECT_PATH, 'templates'),
)

ALLOWED_HOSTS = []


Expand Down
1 change: 1 addition & 0 deletions tests/testapp/testapp/templates/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Dashboard
2 changes: 1 addition & 1 deletion tests/testapp/testapp/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
# url(r'^$', 'testapp.views.home', name='home'),
# url(r'^blog/', include('blog.urls')),

#url(r'^admin/', include(admin.site.urls)),
url(r'^admin/', include(admin.site.urls)),
)

# Rhetorical routing
Expand Down
16 changes: 9 additions & 7 deletions tests/url_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,15 @@

class URLTest(BaseTestCase):

def test_routes(self):
from tests.testapp.testapp import urls

pattern_list = urls.urlpatterns
route_names = {p.name for p in pattern_list}
self.assertIn('test.new.routes', route_names)

def test_requests(self):
response = self.client.get('/blog/test/new/routes/abc')
assert response.status_code == 200

def test_dashboard_requests(self):
response = self.client.get('/dashboard')
assert response.status_code == 200
assert response.content.strip() == 'Dashboard'

def test_non_rhetoric_urls(self):
response = self.client.get('/admin/')
assert response.status_code == 200

0 comments on commit dcd16fb

Please sign in to comment.