Esempio n. 1
0
def test_site(settings):
    # default using Sites framework
    settings.POOTLE_CANONICAL_URL = ""
    pootle_site = site.get()
    assert (
        pootle_site.build_absolute_uri("/foo")
        == u'https://example.com/foo')
    assert not pootle_site.use_insecure_http
    settings.USE_INSECURE_HTTP = True
    assert pootle_site.use_insecure_http
    assert (
        pootle_site.build_absolute_uri("/foo")
        == u'http://example.com/foo')
    contrib_site = Site.objects.get_current()
    contrib_site.domain = "foo.com"
    contrib_site.save()
    assert (
        pootle_site.build_absolute_uri("/foo")
        == u'http://foo.com/foo')
    assert pootle_site.use_http_port == 80
    settings.USE_HTTP_PORT = 8008
    assert pootle_site.use_http_port == 8008
    assert (
        pootle_site.build_absolute_uri("/foo")
        == u'http://foo.com:8008/foo')
Esempio n. 2
0
def test_site_canonical(settings):
    # default using POOTLE_CANONICAL_URL
    pootle_site = site.get()
    settings.POOTLE_CANONICAL_URL = "http://foo.com"
    assert not pootle_site.uses_sites
    assert not pootle_site.contrib_site
    assert pootle_site.use_insecure_http
    assert pootle_site.use_http_port == 80
    assert pootle_site.domain == "foo.com"
    assert (
        pootle_site.build_absolute_uri("/foo")
        == u'http://foo.com/foo')

    settings.POOTLE_CANONICAL_URL = "http://foo.com/bar"
    pootle_site = site.get()
    assert not pootle_site.uses_sites
    assert not pootle_site.contrib_site
    assert pootle_site.use_insecure_http
    assert pootle_site.use_http_port == 80
    assert pootle_site.domain == "foo.com"
    assert (
        pootle_site.build_absolute_uri("/foo")
        == u'http://foo.com/bar/foo')

    settings.POOTLE_CANONICAL_URL = "https://foo.com/bar"
    pootle_site = site.get()
    assert not pootle_site.uses_sites
    assert not pootle_site.contrib_site
    assert not pootle_site.use_insecure_http
    assert pootle_site.use_http_port == 80
    assert pootle_site.domain == "foo.com"
    assert (
        pootle_site.build_absolute_uri("/foo")
        == u'https://foo.com/bar/foo')

    settings.POOTLE_CANONICAL_URL = "https://foo.com:8008/bar"
    pootle_site = site.get()
    assert not pootle_site.uses_sites
    assert not pootle_site.contrib_site
    assert not pootle_site.use_insecure_http
    assert pootle_site.use_http_port == 8008
    assert pootle_site.domain == "foo.com"
    assert (
        pootle_site.build_absolute_uri("/foo")
        == u'https://foo.com:8008/bar/foo')
Esempio n. 3
0
def test_site_canonical(settings):
    # default using POOTLE_CANONICAL_URL
    pootle_site = site.get()
    settings.POOTLE_CANONICAL_URL = "http://foo.com"
    assert not pootle_site.uses_sites
    assert not pootle_site.contrib_site
    assert pootle_site.use_insecure_http
    assert pootle_site.use_http_port == 80
    assert pootle_site.domain == "foo.com"
    assert (pootle_site.build_absolute_uri("/foo") == u'http://foo.com/foo')

    settings.POOTLE_CANONICAL_URL = "http://foo.com/bar"
    pootle_site = site.get()
    assert not pootle_site.uses_sites
    assert not pootle_site.contrib_site
    assert pootle_site.use_insecure_http
    assert pootle_site.use_http_port == 80
    assert pootle_site.domain == "foo.com"
    assert (
        pootle_site.build_absolute_uri("/foo") == u'http://foo.com/bar/foo')

    settings.POOTLE_CANONICAL_URL = "https://foo.com/bar"
    pootle_site = site.get()
    assert not pootle_site.uses_sites
    assert not pootle_site.contrib_site
    assert not pootle_site.use_insecure_http
    assert pootle_site.use_http_port == 80
    assert pootle_site.domain == "foo.com"
    assert (
        pootle_site.build_absolute_uri("/foo") == u'https://foo.com/bar/foo')

    settings.POOTLE_CANONICAL_URL = "https://foo.com:8008/bar"
    pootle_site = site.get()
    assert not pootle_site.uses_sites
    assert not pootle_site.contrib_site
    assert not pootle_site.use_insecure_http
    assert pootle_site.use_http_port == 8008
    assert pootle_site.domain == "foo.com"
    assert (pootle_site.build_absolute_uri("/foo") ==
            u'https://foo.com:8008/bar/foo')
Esempio n. 4
0
def test_site(settings):
    # default using Sites framework
    settings.POOTLE_CANONICAL_URL = ""
    pootle_site = site.get()
    assert (
        pootle_site.build_absolute_uri("/foo") == u'https://example.com/foo')
    assert not pootle_site.use_insecure_http
    settings.USE_INSECURE_HTTP = True
    assert pootle_site.use_insecure_http
    assert (
        pootle_site.build_absolute_uri("/foo") == u'http://example.com/foo')
    contrib_site = Site.objects.get_current()
    contrib_site.domain = "foo.com"
    contrib_site.save()
    assert (pootle_site.build_absolute_uri("/foo") == u'http://foo.com/foo')
    assert pootle_site.use_http_port == 80
    settings.USE_HTTP_PORT = 8008
    assert pootle_site.use_http_port == 8008
    assert (
        pootle_site.build_absolute_uri("/foo") == u'http://foo.com:8008/foo')
Esempio n. 5
0
 def build_absolute_uri(self, url):
     return site.get().build_absolute_uri(url)
Esempio n. 6
0
 def build_absolute_uri(self, url):
     return site.get().build_absolute_uri(url)