Ejemplo n.º 1
0
def test_upload(tmpdir):
    with pytest.raises(SystemExit):
        cli.upload([]) # argparse should raise systemexit without the mandatory arguments

    testfile = tmpdir.join('test_upload-%s.txt' % timestamp()).ensure()
    testfile.write(TESTFILEDATA)
    assert cli.upload([str(testfile), '//Jotta/Archive'])
    fi = jfs.getObject('/Jotta/Archive/%s' % str(testfile.basename))
    assert isinstance(fi, JFS.JFSFile)
    assert fi.read() == TESTFILEDATA
    fi.delete()
Ejemplo n.º 2
0
def test_upload():
    with pytest.raises(SystemExit):
        cli.upload([]) # argparse should raise systemexit without the mandatory arguments
    f, filename = tempfile.mkstemp(suffix='.txt', prefix='test_upload-')
    f.write(TESTFILEDATA)
    f.close()
    assert cli.upload([filename, '.'])
    fi = jfs.getObject('/Jotta/Sync/%s' % os.path.basename(filename))
    assert isinstance(fi, JFS.JFSFile)
    assert d.is_deleted() == False
    fi.delete()
Ejemplo n.º 3
0
def test_upload(tmpdir):
    with pytest.raises(SystemExit):
        cli.upload(
            []
        )  # argparse should raise systemexit without the mandatory arguments

    testfile = tmpdir.join('test_upload-%s.txt' % timestamp()).ensure()
    testfile.write(TESTFILEDATA)
    assert cli.upload([str(testfile), '//Jotta/Archive/'])
    fi = jfs.getObject('//Jotta/Archive/%s' % str(testfile.basename))
    assert isinstance(fi, JFS.JFSFile)
    assert fi.read() == TESTFILEDATA
    fi.delete()
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_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])