示例#1
0
class EsConnectionTest:
    def __init__(self, sharing_name, cd=None, rcd=None):
        self.sharing_name = sharing_name
        self.cd = cd
        self.rcd = rcd
        self.client = None

    def enter(self):
        return self.__enter__()

    def exit(self):
        self.__exit__(None, None, None)

    def __enter__(self):
        self.client = Client()

        if self.cd:
            self.client.execute_command(Commands.LOCAL_CHANGE_DIRECTORY,
                                        str(self.cd))

        if self.sharing_name:
            self.client.execute_command(Commands.OPEN, self.sharing_name)

        if self.rcd:
            self.client.execute_command(Commands.REMOTE_CHANGE_DIRECTORY,
                                        str(self.rcd))
        return self.client

    def __exit__(self, exc_type, exc_val, exc_tb):
        return False
示例#2
0
 def test_open_by_sharing_name_at_ip_port(): # open [email protected]:12020
     client = Client()
     client.execute_command(Commands.OPEN, f"{esd.sharing_root.name}@{get_primary_ip():{DEFAULT_SERVER_PORT}}")
     assert client.is_connected_to_sharing()
     client.execute_command(Commands.DISCONNECT)
示例#3
0
 def test_close():
     client = Client()
     client.execute_command(Commands.OPEN, esd.sharing_root.name)
     assert client.is_connected_to_sharing()
     client.execute_command(Commands.CLOSE)
     assert not client.is_connected_to_sharing()
示例#4
0
 def test_open_by_sharing_name_at_server_name(): # open sharing-name@server-name
     client = Client()
     client.execute_command(Commands.OPEN, f"{esd.sharing_root.name}@{esd.server_name}")
     assert client.is_connected_to_sharing()
     client.execute_command(Commands.DISCONNECT)
示例#5
0
 def test_open_by_sharing_name(): # open sharing-name
     client = Client()
     client.execute_command(Commands.OPEN, esd.sharing_root.name)
     assert client.is_connected_to_sharing()
     client.execute_command(Commands.DISCONNECT)
示例#6
0
 def test_disconnect():
     client = Client()
     client.execute_command(Commands.CONNECT, esd.server_name)
     assert client.is_connected_to_server()
     client.execute_command(Commands.DISCONNECT)
     assert not client.is_connected_to_server()
示例#7
0
 def test_connect_by_ip(): # connect 192.168.1.110
     client = Client()
     client.execute_command(Commands.CONNECT, get_primary_ip())
     assert client.is_connected_to_server()
     client.execute_command(Commands.DISCONNECT)
示例#8
0
 def test_connect_by_name(): # connect server-name
     client = Client()
     client.execute_command(Commands.CONNECT, esd.server_name)
     assert client.is_connected_to_server()
     client.execute_command(Commands.DISCONNECT)