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_s3_to_ssh(): pytest.importorskip('boto') tips_uri = 's3://nyqpug/tips.csv' with tmpfile('.csv') as fn: result = into(Temp(SSH(CSV))(fn, hostname='localhost'), tips_uri) assert into(list, result) == into(list, tips_uri) assert discover(result) == discover(resource(tips_uri))
def test_ssh_csv_to_s3_csv(): # for some reason this can only be run in the same file as other ssh tests # and must be a Temp(SSH(CSV)) otherwise tests above this one fail s3_bucket = pytest.importorskip('odo.backends.tests.test_aws').s3_bucket with filetext('name,balance\nAlice,100\nBob,200', extension='csv') as fn: remote = into(Temp(SSH(CSV)), CSV(fn), hostname='localhost') with s3_bucket('.csv') as b: result = into(b, remote) assert discover(result) == discover(resource(b))
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) uri = 'ssh://localhost:%s.csv' % target scsv = into(uri, 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'