Ejemplo n.º 1
0
def test_rm():
    with pytest.raises(SystemExit):
        cli.rm([]) # argparse should raise systemexit without the mandatory arguments
    assert cli.rm(['testmkdir'])
    d = jfs.getObject('/Jotta/Sync/testmkdir')
    assert isinstance(d, JFS.JFSFolder)
    assert d.is_deleted() == True
Ejemplo n.º 2
0
def test_rm():
    with pytest.raises(SystemExit):
        cli.rm(
            []
        )  # argparse should raise systemexit without the mandatory arguments
    assert cli.rm(['testmkdir'])
    d = jfs.getObject('//Jotta/Sync/testmkdir')
    assert isinstance(d, JFS.JFSFolder)
    assert d.is_deleted() == True
Ejemplo n.º 3
0
def test_upload_crazy_filenames(tmpdir):
    # test crazy filenames
    jotta_test_path = '//Jotta/Archive/crazyfilename'
    cli.mkdir([jotta_test_path])
    zip = zipfile.ZipFile('tests/crazyfilenames.zip')
    zip.extractall(path=str(tmpdir))
    for crazyfilename in tmpdir.join('crazyfilenames').listdir():
        _filename = crazyfilename.basename
        _base, _enc, _ext = _filename.split('.')
        assert cli.upload([str(crazyfilename), jotta_test_path])
        # TODO: enable this
        #assert cli.cat([os.path.join(jotta_test_path, _filename), ]) == crazyfilename.read()
    cli.rm([jotta_test_path])
Ejemplo n.º 4
0
def test_upload_crazy_filenames(tmpdir):
    # test crazy filenames
    jotta_test_path = '//Jotta/Archive/crazyfilename'
    cli.mkdir([jotta_test_path])
    zip = zipfile.ZipFile('tests/crazyfilenames.zip')
    zip.extractall(path=str(tmpdir))
    for crazyfilename in tmpdir.join('crazyfilenames').listdir():
        _filename = crazyfilename.basename
        _base, _enc, _ext = _filename.split('.') 
        assert cli.upload([str(crazyfilename), jotta_test_path])
        # TODO: enable this
        #assert cli.cat([os.path.join(jotta_test_path, _filename), ]) == crazyfilename.read()
    cli.rm([jotta_test_path])
Ejemplo n.º 5
0
def test_download(tmpdir):
    with pytest.raises(SystemExit):
        cli.download(
            []
        )  # argparse should raise systemexit without the mandatory arguments
    testcontents = u'12345test'
    testdir = '//Jotta/Archive/Test'
    cli.mkdir([testdir])
    testfile = 'test.txt'
    testpath = posixpath.join(testdir, testfile)
    d = jfs.up(testpath, StringIO(testcontents))
    with tmpdir.as_cwd():
        assert cli.download(['%s' % testpath])
        assert cli.download(['%s' % testpath, '--checksum'])
        #TODO: implement when --resume is - assert cli.download(['/%s' % testpath, '--resume'])
        assert tmpdir.join(testfile).read_text('utf-8') == testcontents
        # download the whole directlry
        assert cli.download(['%s' % testdir])
        assert cli.download(['%s' % testdir, '--checksum'])
        assert tmpdir.join('Test').join(testfile).read() == testcontents
    cli.rm([testdir])