Skip to content

Commit

Permalink
Failing tests for dispatch returning a result
Browse files Browse the repository at this point in the history
  • Loading branch information
chadwhitacre committed Oct 3, 2014
1 parent 55f903c commit 810da3a
Showing 1 changed file with 24 additions and 2 deletions.
26 changes: 24 additions & 2 deletions tests/test_dispatcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from pytest import raises

import aspen
from aspen import Response
from aspen import dispatcher, Response


# Helpers
Expand Down Expand Up @@ -43,6 +43,29 @@ def assert_body(harness, uripath, expected_body):
[-----] text/html
<h1>Greetings, Program!</h1>"""


# dispatcher.dispatch
# ===================

def test_dispatcher_returns_a_result(harness):
request = harness.make_request('Greetings, program!', 'index.html')
result = dispatcher.dispatch(harness.client.website, request)
assert result.status == dispatcher.DispatchStatus.okay
assert result.match == os.path.join(harness.fs.www.root, 'index.html')
assert result.wildcards == {}
assert result.detail == 'Found.'

def test_dispatcher_returns_a_result_for_autoindex(harness):
request = harness.make_request('Greetings, program!', 'index.html')
os.remove(request.fs)
harness.client.website.list_directories = True
result = dispatcher.dispatch(harness.client.website, request)
assert result.status == dispatcher.DispatchStatus.okay
assert result.match == os.path.join(harness.fs.www.root, '')
assert result.wildcards == {}
assert result.detail == 'Found.'


# Indices
# =======

Expand Down Expand Up @@ -462,4 +485,3 @@ def test_dont_serve_hidden_files(harness):
def test_dont_serve_spt_file_source(harness):
harness.fs.www.mk(('foo.html.spt', "Greetings, program!"),)
assert_raises_404(harness, '/foo.html.spt')

0 comments on commit 810da3a

Please sign in to comment.