def test_calling_dir_getter_from_ls_command_output(buffer_connection): from moler.cmd.unix.ls import Ls command_output, expected_result = command_output_and_expected_result() buffer_connection.remote_inject_response([command_output]) ls_cmd = Ls(connection=buffer_connection.moler_connection, options="-l") ls_cmd() dirs = ls_cmd.get_dirs() expected_dirs = { "bin": { "permissions": "drwxr-xr-x", "hard_links_count": 2, "owner": "root", "group": "root", "size_bytes": 4096, "size_raw": "4096", "date": "Sep 25 2014", "name": "bin", }, "btslog2": { "permissions": "drwxr-xr-x", "hard_links_count": 5, "owner": "root", "group": "root", "size_bytes": 4096, "size_raw": "4096", "date": "Mar 20 2015", "name": "btslog2" }, } assert dirs == expected_dirs
def test_ls_throw_ResultNotAvailableYet(buffer_connection): from moler.exceptions import ResultNotAvailableYet ls_cmd = Ls(buffer_connection, options="-l") with pytest.raises(ResultNotAvailableYet): ls_cmd.get_dirs()