Example #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"
Example #2
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'
Example #3
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'
Example #4
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
Example #5
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
Example #6
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
Example #7
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()
Example #8
0
 def test_moved_permanently(self):
     location = 'http://localhost/abc'
     r = http.moved_permanently(location)
     assert r.status.startswith('301')
     assert r.headers['Location'] == location