本文整理汇总了Python中social.utils.build_absolute_uri函数的典型用法代码示例。如果您正苦于以下问题:Python build_absolute_uri函数的具体用法?Python build_absolute_uri怎么用?Python build_absolute_uri使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了build_absolute_uri函数的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: build_absolute_uri
def build_absolute_uri(self, path=None):
"""Build absolute URI with given (optional) path"""
return build_absolute_uri(self.request.host_url, path)
示例2: build_absolute_uri
def build_absolute_uri(self, path=None):
# TODO: Quando a API diretamente (e não a partir de outro site) não tem
# "referrer". Como resolver isso?
return build_absolute_uri(
flask.request.referrer, path).partition("&")[0]
示例3: build_absolute_uri
def build_absolute_uri(self, path=None):
return build_absolute_uri('{0}://{1}'.format(self.request.protocol,
self.request.host),
path)
示例4: test_absolute_uri
def test_absolute_uri(self):
self.assertEqual(build_absolute_uri(self.host, '/foo/bar'),
'http://foobar.com/foo/bar')
示例5: test_path_none
def test_path_none(self):
self.assertEqual(build_absolute_uri(self.host), self.host)
示例6: test_path_https
def test_path_https(self):
self.assertEqual(build_absolute_uri(self.host, 'https://barfoo.com'),
'https://barfoo.com')
示例7: test_host_ends_with_slash_and_path_starts_with_slash
def test_host_ends_with_slash_and_path_starts_with_slash(self):
self.assertEqual(build_absolute_uri(self.host + '/', '/foo/bar'),
'http://foobar.com/foo/bar')
示例8: build_absolute_uri
def build_absolute_uri(self, path=None):
return build_absolute_uri(request.host_url, path)
示例9: test_path_empty
def test_path_empty(self):
self.assertEqual(build_absolute_uri(self.host, ''), self.host)
示例10: test_absolute_uri
def test_absolute_uri(self):
expect(build_absolute_uri(self.host, '/foo/bar')) \
.to.equal('http://foobar.com/foo/bar')
示例11: test_host_ends_with_slash_and_path_starts_with_slash
def test_host_ends_with_slash_and_path_starts_with_slash(self):
expect(build_absolute_uri(self.host + '/', '/foo/bar')) \
.to.equal('http://foobar.com/foo/bar')
示例12: test_path_https
def test_path_https(self):
expect(build_absolute_uri(self.host, 'https://barfoo.com')) \
.to.equal('https://barfoo.com')
示例13: test_path_empty
def test_path_empty(self):
expect(build_absolute_uri(self.host, '')).to.equal(self.host)
示例14: test_path_none
def test_path_none(self):
expect(build_absolute_uri(self.host)).to.equal(self.host)