mirror of
https://github.com/gradio-app/gradio.git
synced 2025-04-24 13:01:18 +08:00
added some tests for tunneling
This commit is contained in:
parent
32ada31745
commit
f15a033232
@ -20,7 +20,7 @@ en = {
|
||||
"COLAB_DEBUG_TRUE": "Colab notebook detected. This cell will run indefinitely so that you can see errors and logs. "
|
||||
"To turn off, set debug=False in launch().",
|
||||
"COLAB_DEBUG_FALSE": "Colab notebook detected. To show errors in colab notebook, set debug=True in launch()",
|
||||
"SHARE_LINK_MESSAGE": "This share link will expire in 24 hours. If you need a permanent link, visit: https://gradio.app/introducing-hosted (NEW!)",
|
||||
"SHARE_LINK_MESSAGE": "This share link will expire in 72 hours. If you need a permanent link, visit: https://gradio.app/introducing-hosted (NEW!)",
|
||||
"PRIVATE_LINK_MESSAGE": "Since this is a private endpoint, this share link will never expire.",
|
||||
"SHARE_LINK_DISPLAY": "Running on External URL: {}",
|
||||
"INLINE_DISPLAY_BELOW": "Interface loading below...",
|
||||
|
@ -1,17 +1,30 @@
|
||||
import io
|
||||
import sys
|
||||
import json
|
||||
import unittest
|
||||
import unittest.mock as mock
|
||||
from gradio import tunneling
|
||||
from gradio import tunneling, networking, Interface
|
||||
import threading
|
||||
import paramiko
|
||||
|
||||
|
||||
# class TestTunneling(unittest.TestCase):
|
||||
# pass
|
||||
# @mock.patch("pkg_resources.require")
|
||||
# def test_should_fail_with_distribution_not_found(self, mock_require):
|
||||
class TestTunneling(unittest.TestCase):
|
||||
def test_create_tunnel(self):
|
||||
response = networking.url_request(networking.GRADIO_API_SERVER)
|
||||
payload = json.loads(response.read().decode("utf-8"))[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(":")
|
||||
threading.Thread.start = mock.MagicMock(return_value=None)
|
||||
paramiko.SSHClient.connect = mock.MagicMock(return_value=None)
|
||||
tunneling.create_tunnel(payload, localhost, port)
|
||||
threading.Thread.start.assert_called_once()
|
||||
paramiko.SSHClient.connect.assert_called_once()
|
||||
io.close()
|
||||
|
||||
|
||||
class TestVerbose(unittest.TestCase):
|
||||
"""Unncessary tests but just including them for the sake of completion."""
|
||||
"""Not absolutely needed but just including them for the sake of completion."""
|
||||
|
||||
def setUp(self):
|
||||
self.message = "print test"
|
||||
|
Loading…
x
Reference in New Issue
Block a user