gradio/test/test_tunneling.py
Abubakar Abid 010827e211
Refactoring to replace unittests with pytests (#2610)
* replace pytests with unittests

* formatting

* test blocks

* fixed test/blocks

* test components

* working on test components

* test components

* test components almost fixed

* removed unittest

* linting

* fix remaining tests

* lint

* formatting

* changelog
2022-11-08 01:37:55 +01:00

23 lines
734 B
Python

import os
import unittest.mock as mock
import paramiko
import requests
from gradio import Interface, networking, tunneling
os.environ["GRADIO_ANALYTICS_ENABLED"] = "False"
class TestTunneling:
def test_create_tunnel(self):
response = requests.get(networking.GRADIO_API_SERVER)
payload = response.json()[0]
io = Interface(lambda x: x, "text", "text")
_, path_to_local_server, _ = io.launch(prevent_thread_lock=True, share=False)
_, localhost, port = path_to_local_server.split(":")
paramiko.SSHClient.connect = mock.MagicMock(return_value=None)
tunneling.create_tunnel(payload, localhost, port)
paramiko.SSHClient.connect.assert_called_once()
io.close()