Beispiel #1
0
    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
Beispiel #2
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
Beispiel #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()
Beispiel #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)
Beispiel #5
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)
Beispiel #6
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)
Beispiel #7
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()
Beispiel #8
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)
Beispiel #9
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)
Beispiel #10
0
import tempfile

from easyshare.commands.commands import Commands
from easyshare.es.client import Client
from easyshare.es.errors import ClientErrors

from tests.utils import tmpfile, tmpdir

client = Client()


def test_pwd():
    pass

def test_ls():
    pass

def test_tree():
    pass

def test_find():
    pass

def test_du():
    pass

def test_mkdir():
    with tempfile.TemporaryDirectory() as tmp:
        d = tmpdir(tmp)

        client.execute_command(Commands.LOCAL_CREATE_DIRECTORY, str(d))