示例#1
0
 def test_moved_permanently_headers(self):
     r = http.moved_permanently("/", headers=[("Set-Cookie", "name=value")])
     # Pass through WebTest for lint-like checks
     webtest.TestApp(app.RestishApp(r)).get("/")
     # Test response details.
     assert r.headers["Location"] == "/"
     assert r.headers["Set-Cookie"] == "name=value"
示例#2
0
文件: test_http.py 项目: ish/restish
 def test_moved_permanently_headers(self):
     r = http.moved_permanently('/', headers=[('Set-Cookie', 'name=value')])
     # Pass through WebTest for lint-like checks
     webtest.TestApp(app.RestishApp(r)).get('/')
     # Test response details.
     assert r.headers['Location'] == '/'
     assert r.headers['Set-Cookie'] == 'name=value'
示例#3
0
 def test_moved_permanently(self):
     location = "http://localhost/abc?a=1&b=2"
     r = http.moved_permanently(location)
     # Pass through WebTest for lint-like checks
     webtest.TestApp(app.RestishApp(r)).get("/")
     # Test response details.
     assert r.status.startswith("301")
     assert r.headers["Location"] == location
     assert r.headers["Content-Length"]
     assert "301 Moved Permanently" in r.body
     assert cgi.escape(location) in r.body
示例#4
0
文件: test_http.py 项目: ish/restish
 def test_moved_permanently(self):
     location = 'http://localhost/abc?a=1&b=2'
     r = http.moved_permanently(location)
     # Pass through WebTest for lint-like checks
     webtest.TestApp(app.RestishApp(r)).get('/')
     # Test response details.
     assert r.status.startswith('301')
     assert r.headers['Location'] == location
     assert r.headers['Content-Length']
     assert '301 Moved Permanently' in r.body
     assert cgi.escape(location) in r.body
示例#5
0
    def dispatch(self, request, segments):
        url = '/'+'/'.join(segments)
        if len(segments) > 1:
            if segments[0] == 'about' and url.endswith('.asp'):
                return http.moved_permanently('/about')
            if segments[0] in ['portfolio','products'] and url.endswith('.asp'):
                return http.moved_permanently('/gallery')
            if len(segments) == 1 and segments[0] in ['portfolio','products']:
                return http.moved_permanently('/gallery')
            if segments[0] == 'events':
                return http.moved_permanently('/news')
            if segments[0] == 'news' and  url.endswith('.asp'):
                return http.moved_permanently('/news')
            if segments[0] == 'contact' and url.endswith('.asp'):
                return http.moved_permanently('/contact')
            if segments[0] == 'workshop':
                return http.moved_permanently('/workshops')

        return RootResource()
示例#6
0
文件: test_http.py 项目: psr/restish
 def test_moved_permanently(self):
     location = 'http://localhost/abc'
     r = http.moved_permanently(location)
     assert r.status.startswith('301')
     assert r.headers['Location'] == location