forked from byteskeptical/sftpretty
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_getcwd.py
33 lines (26 loc) · 1.09 KB
/
test_getcwd.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
'''test sftpretty.getcwd
until you issue a .chdir/cwd command paramiko returns None for .getcwd,
unless you have set default_path in the Connection args'''
from common import conn, VFS
from sftpretty import Connection
def test_getcwd_none(sftpserver):
'''test .getcwd as the first operation - need pristine connection
and no default_path arg'''
with sftpserver.serve_content(VFS):
cnn = conn(sftpserver)
cnn['default_path'] = None
with Connection(**cnn) as sftp:
assert sftp.getcwd() is None
def test_getcwd_default_path(sftpserver):
'''test .getcwd when using default_path arg'''
with sftpserver.serve_content(VFS):
with Connection(**conn(sftpserver)) as sftp:
assert sftp.getcwd() == '/home/test'
def test_getcwd_after_chdir(sftpserver):
'''test getcwd after a chdir operation'''
with sftpserver.serve_content(VFS):
cnn = conn(sftpserver)
cnn['default_path'] = None
with Connection(**cnn) as sftp:
sftp.chdir('/home/test/pub/foo1')
assert sftp.getcwd() == '/home/test/pub/foo1'