Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(568)

Unified Diff: mojo/devtools/common/devtoolslib/http_server_unittest.py

Issue 1269863004: Support mapping multiple local paths under the same url prefix. (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Fix typos in tests. Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « mojo/devtools/common/devtoolslib/http_server.py ('k') | mojo/devtools/common/devtoolslib/linux_shell.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/devtools/common/devtoolslib/http_server_unittest.py
diff --git a/mojo/devtools/common/devtoolslib/http_server_unittest.py b/mojo/devtools/common/devtoolslib/http_server_unittest.py
index dec4571c0244fbd7e995ee366720c23fc3891d2b..f279712ce63b181a51ec75b5c8cccf3085832338 100644
--- a/mojo/devtools/common/devtoolslib/http_server_unittest.py
+++ b/mojo/devtools/common/devtoolslib/http_server_unittest.py
@@ -56,8 +56,8 @@ class HttpServerTest(unittest.TestCase):
there.
"""
mappings = [
- ('hello/', self.hello_dir),
- ('other/', self.other_dir),
+ ('hello/', [self.hello_dir]),
+ ('other/', [self.other_dir]),
]
server_address = ('http://%s:%u/' %
http_server.start_http_server(mappings))
@@ -72,10 +72,54 @@ class HttpServerTest(unittest.TestCase):
other_relpath)
self.assertEquals(200, other_response.getcode())
+ def test_unmapped_path(self):
+ """Verifies that the server returns 404 when a request for unmapped url
+ prefix is made.
+ """
+ mappings = [
+ ('hello/', [self.hello_dir]),
+ ]
+ server_address = ('http://%s:%u/' %
+ http_server.start_http_server(mappings))
+
+ error_code = None
+ try:
+ urllib2.urlopen(server_address + 'unmapped/abc')
+ except urllib2.HTTPError as error:
+ error_code = error.code
+ self.assertEquals(404, error_code)
+
+ def test_multiple_paths(self):
+ """Verfies mapping multiple local paths under the same url prefix."""
+ mappings = [
+ ('singularity/', [self.hello_dir, self.other_dir]),
+ ]
+ server_address = ('http://%s:%u/' %
+ http_server.start_http_server(mappings))
+
+ hello_relpath = os.path.relpath(self.hello_file.name, self.hello_dir)
+ hello_response = urllib2.urlopen(server_address + 'singularity/' +
+ hello_relpath)
+ self.assertEquals(200, hello_response.getcode())
+
+ other_relpath = os.path.relpath(self.other_file.name, self.other_dir)
+ other_response = urllib2.urlopen(server_address + 'singularity/' +
+ other_relpath)
+ self.assertEquals(200, other_response.getcode())
+
+ # Verify that a request for a file not present under any of the mapped
+ # directories results in 404.
+ error_code = None
+ try:
+ urllib2.urlopen(server_address + 'singularity/unavailable')
+ except urllib2.HTTPError as error:
+ error_code = error.code
+ self.assertEquals(404, error_code)
+
def test_gzip(self):
"""Verifies the gzip content encoding of the files being served."""
mappings = [
- ('hello/', self.hello_dir),
+ ('hello/', [self.hello_dir]),
]
server_address = ('http://%s:%u/' %
http_server.start_http_server(mappings))
« no previous file with comments | « mojo/devtools/common/devtoolslib/http_server.py ('k') | mojo/devtools/common/devtoolslib/linux_shell.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698