Exemplo n.º 1
0
    def test_is_port_open__port_is_open__port_is_not_open(self):
        host = "www.google.com"
        port = 443
        host_ip = dns_ip_address(host)
        timeout = 0.10

        assert is_port_open(host=host, port=port, timeout=timeout) is True
        assert is_port_open(host=host_ip, port=port, timeout=timeout) is True
        assert is_port_open(host=host, port=port + 1, timeout=timeout) is False
        assert is_port_open(host=host_ip, port=port + 1,
                            timeout=timeout) is False

        assert port_is_open(host=host, port=port, timeout=timeout) is True
        assert port_is_open(host=host_ip, port=port, timeout=timeout) is True
        assert port_is_open(host=host, port=port + 1, timeout=timeout) is False
        assert port_is_open(host=host_ip, port=port + 1,
                            timeout=timeout) is False

        assert port_is_not_open(host=host, port=port, timeout=timeout) is False
        assert port_is_not_open(host=host_ip, port=port,
                                timeout=timeout) is False
        assert port_is_not_open(host=host, port=port + 1,
                                timeout=timeout) is True
        assert port_is_not_open(host=host_ip, port=port + 1,
                                timeout=timeout) is True
Exemplo n.º 2
0
    async def test_port(self):
        ws_endpoint = await self.chrome.ws_endpoint()
        port = await self.chrome.port()
        assert ws_endpoint.startswith(f'ws://127.0.0.1:{port}')

        assert port_is_open(port)
        assert port_is_not_open(port + 1)
Exemplo n.º 3
0
 def wait_for_server_started(
     self,
     max_number_of_tries=30
 ):  # 0.75 of a Sec should be enough to start the server
     while max_number_of_tries > 0:
         max_number_of_tries -= 1
         sleep(0.025)  # wait 0.025 of a second (0.025 * 30 = 0.75 sec)
         if port_is_open(self.port):
             return True
     return False
Exemplo n.º 4
0
 async def browser_connect(self):
     last_chrome_session = self.get_last_chrome_session()
     url_chrome = last_chrome_session.get('url_chrome')
     port = last_chrome_session.get('port')
     if url_chrome and port_is_open(
             port):  # needs pip install websocket-client
         kwargs = {
             'browserWSEndpoint': url_chrome,
             'slowMo': self.options[
                 'slowMo']  # todo: confirm this has no side effects when set to 0 (i.e. slow it down)
         }
         self._browser = await connect(**kwargs)
         return True
     return False
Exemplo n.º 5
0
 async def test_browser_connect(self):
     browser = await self.chrome.browser_launch_or_connect()
     port = await self.chrome.port()
     assert type(browser).__name__ == 'Browser'
     assert port_is_open(port)
Exemplo n.º 6
0
 async def test_browser(self):
     browser = await self.chrome.browser()
     port = await self.chrome.port()
     assert type(browser).__name__ == 'Browser'
     assert port_is_open(port)
     assert (await browser.pages()).pop().url == 'about:blank'
Exemplo n.º 7
0
 async def test_port(self):
     assert port_is_open(await self.chrome.port())
     browser = await self.chrome.browser()
     assert (await browser.pages()).pop().url == 'about:blank'
Exemplo n.º 8
0
 async def test_connection(self):
     connection = await self.chrome.connection()
     assert connection.closed == False
     assert connection.open == True
     assert connection.remote_address[0] == '127.0.0.1'
     assert port_is_open(connection.remote_address[1])