示例#1
0
 def test_accept_gzip(self, dcos_api_session: DcosApiSession) -> None:
     """
     Clients that send "Accept-Encoding: gzip" get gzipped responses
     for some assets.
     """
     r = dcos_api_session.get('/')
     r.raise_for_status()
     filenames = self.pat.findall(r.text)
     assert len(filenames) > 0
     for filename in set(filenames):
         log.info('Load %r', filename)
         r = dcos_api_session.head(filename,
                                   headers={'Accept-Encoding': 'gzip'})
         r.raise_for_status()
         log.info('Response headers: %s', repr(r.headers))
         assert r.headers.get('content-encoding') == 'gzip'
示例#2
0
def test_if_dcos_ui_is_up(dcos_api_session: DcosApiSession) -> None:
    r = dcos_api_session.get('/')

    assert r.status_code == 200
    assert len(r.text) > 100
    assert 'DC/OS' in r.text

    # Not sure if it's really needed, seems a bit of an overkill:
    soup = bs4.BeautifulSoup(r.text, "html.parser")
    for link in soup.find_all(['link', 'a'], href=True):
        if urllib.parse.urlparse(link.attrs['href']).netloc:
            # Relative URLs only, others are to complex to handle here
            continue
        # Some links might start with a dot (e.g. ./img/...). Remove.
        href = link.attrs['href'].lstrip('.')
        link_response = dcos_api_session.head(href)
        assert link_response.status_code == 200
示例#3
0
 def test_not_accept_gzip(self, dcos_api_session: DcosApiSession) -> None:
     """
     Clients that do not send "Accept-Encoding: gzip" do not get gzipped
     responses.
     """
     r = dcos_api_session.get('/')
     r.raise_for_status()
     filenames = self.pat.findall(r.text)
     assert len(filenames) > 0
     for filename in set(filenames):
         log.info('Load %r', filename)
         # Set a benign `Accept-Encoding` header to prevent underlying
         # libraries setting their own header based on their capabilities.
         r = dcos_api_session.head(filename,
                                   headers={'Accept-Encoding': 'identity'})
         r.raise_for_status()
         log.info('Response headers: %s', repr(r.headers))
         assert 'content-encoding' not in r.headers