Skip to content

Commit

Permalink
Remove dependency on website.www_root
Browse files Browse the repository at this point in the history
  • Loading branch information
chadwhitacre committed Oct 3, 2014
1 parent d2c007c commit 5e6ac6d
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 6 deletions.
1 change: 1 addition & 0 deletions aspen/algorithms/website.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ def dispatch_request_to_filesystem(website, request):
, pathparts=request.line.uri.path.parts
, uripath=request.line.uri.path.raw
, querystring=request.line.uri.querystring.raw
, startdir=website.www_root
)
request.fs = result.match
for k, v in result.wildcards.iteritems():
Expand Down
3 changes: 1 addition & 2 deletions aspen/dispatcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ def update_neg_type(media_type_default, capture_accept, filename):


def dispatch(website, indices, media_type_default, pathparts, uripath, querystring,
pure_dispatch=False):
startdir, pure_dispatch=False):
"""Concretize dispatch_abstract.
"""

Expand All @@ -278,7 +278,6 @@ def dispatch(website, indices, media_type_default, pathparts, uripath, querystri
traverse = os.path.join
find_index = lambda x: match_index(indices, x)
noext_matched = lambda x: update_neg_type(media_type_default, capture_accept, x)
startdir = website.www_root


# Dispatch!
Expand Down
28 changes: 24 additions & 4 deletions tests/test_dispatcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,23 +51,43 @@ def assert_body(harness, uripath, expected_body):

def test_dispatcher_returns_a_result(harness):
harness.fs.www.mk(('index.html', 'Greetings, program!'),)
result = dispatcher.dispatch(harness.client.website, ['index.html'], '', [''], '/', '')
result = dispatcher.dispatch( harness.client.website
, ['index.html']
, ''
, ['']
, '/'
, ''
, harness.fs.www.root
)
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_favicon(harness):
website = harness.client.website
result = dispatcher.dispatch(website, [], '', ['favicon.ico'], '/favicon.ico', '')
result = dispatcher.dispatch( harness.client.website
, []
, ''
, ['favicon.ico']
, '/favicon.ico'
, ''
, harness.fs.www.root
)
assert result.status == dispatcher.DispatchStatus.okay
assert result.match == harness.client.website.find_ours('favicon.ico')
assert result.wildcards == {}
assert result.detail == 'Found.'

def test_dispatcher_returns_a_result_for_autoindex(harness):
harness.client.website.list_directories = True
result = dispatcher.dispatch(harness.client.website, [], '', [''], '/', '')
result = dispatcher.dispatch( harness.client.website
, []
, ''
, ['']
, '/'
, ''
, harness.fs.www.root
)
assert result.status == dispatcher.DispatchStatus.okay
assert result.match == harness.client.website.find_ours('autoindex.html.spt')
assert result.wildcards == {}
Expand Down

0 comments on commit 5e6ac6d

Please sign in to comment.