def test_resource_directory(): r = resource('ssh://joe@localhost:/path/to/') assert issubclass(r.subtype, _Directory) r = resource('ssh://joe@localhost:/path/to/*.csv') assert r.subtype == Directory(CSV) assert r.path == '/path/to/'
def test_copy_remote_csv(): with tmpfile('csv') as target: with filetext('name,balance\nAlice,100\nBob,200', extension='csv') as fn: csv = resource(fn) scsv = into('ssh://localhost:foo.csv', csv) assert isinstance(scsv, SSH(CSV)) assert discover(scsv) == discover(csv) # Round trip csv2 = into(target, scsv) assert into(list, csv) == into(list, csv2)
def test_discover_from_resource(): with filetext('name,balance\nAlice,100\nBob,200', extension='csv') as fn: local = CSV(fn) remote = resource('ssh://localhost:' + fn) assert discover(local) == discover(remote)
def test_resource(): r = resource('ssh://joe@localhost:/path/to/myfile.csv') assert isinstance(r, SSH(CSV)) assert r.path == '/path/to/myfile.csv' assert r.auth['hostname'] == 'localhost' assert r.auth['username'] == 'joe'