Exemplo n.º 1
0
 def test_static_url_noscheme_uses_scheme_from_request(self):
     from pyramid.interfaces import IStaticURLInfo
     from pyramid.config.views import StaticURLInfo
     info = StaticURLInfo()
     here = os.path.abspath(os.path.dirname(__file__))
     info.add(self.config, '//subdomain.example.com/static', here)
     request = self._makeOne({'wsgi.url_scheme': 'https'})
     registry = request.registry
     registry.registerUtility(info, IStaticURLInfo)
     abspath = os.path.join(here, 'test_url.py')
     result = request.static_url(abspath)
     self.assertEqual(result,
                      'https://subdomain.example.com/static/test_url.py')
Exemplo n.º 2
0
 def test_static_url_noscheme_uses_scheme_from_request(self):
     from pyramid.interfaces import IStaticURLInfo
     from pyramid.config.views import StaticURLInfo
     info = StaticURLInfo()
     here = os.path.abspath(os.path.dirname(__file__))
     info.add(self.config, '//subdomain.example.com/static', here)
     request = self._makeOne({'wsgi.url_scheme': 'https'})
     registry = request.registry
     registry.registerUtility(info, IStaticURLInfo)
     abspath = os.path.join(here, 'test_url.py')
     result = request.static_url(abspath)
     self.assertEqual(result,
                      'https://subdomain.example.com/static/test_url.py')
Exemplo n.º 3
0
 def test_static_url_abspath_integration_with_staticurlinfo(self):
     from pyramid.interfaces import IStaticURLInfo
     from pyramid.config.views import StaticURLInfo
     info = StaticURLInfo()
     here = os.path.abspath(os.path.dirname(__file__))
     info.add(self.config, 'absstatic', here)
     request = self._makeOne()
     registry = request.registry
     registry.registerUtility(info, IStaticURLInfo)
     abspath = os.path.join(here, 'test_url.py')
     result = request.static_url(abspath)
     self.assertEqual(result,
                      'http://example.com:5432/absstatic/test_url.py')
Exemplo n.º 4
0
 def test_static_url_abspath_integration_with_staticurlinfo(self):
     from pyramid.interfaces import IStaticURLInfo
     from pyramid.config.views import StaticURLInfo
     info = StaticURLInfo()
     here = os.path.abspath(os.path.dirname(__file__))
     info.add(self.config, 'absstatic', here)
     request = self._makeOne()
     registry = request.registry
     registry.registerUtility(info, IStaticURLInfo)
     abspath = os.path.join(here, 'test_url.py')
     result = request.static_url(abspath)
     self.assertEqual(result,
                      'http://example.com:5432/absstatic/test_url.py')