Exemplo n.º 1
0
def test_shelf_in(writer, filename, password):
    with file_cleanup(test_file):
        shelf = pc.EncryptedShelf(writer, filename, password)
        shelf["key"] = "value"
        assert "key" in shelf
        assert "notkey" not in shelf
        shelf.close()
Exemplo n.º 2
0
def test_shelf_in(writer, filename, password):
    with file_cleanup(test_file):
        shelf = pc.EncryptedShelf(writer, filename, password)
        shelf["key"] = "value"
        assert "key" in shelf
        assert "notkey" not in shelf
        shelf.close()
Exemplo n.º 3
0
def test_tell(method):
    test_data = "some even more different test data"
    with file_cleanup(test_file):
        file = method(open(test_file, 'w'), test_pass)
        assert file.tell() == 0
        file.write(test_data)
        assert file.tell() == len(test_data)
        file.close()
Exemplo n.º 4
0
def test_tell(method):
    test_data = "some even more different test data"
    with file_cleanup(test_file):
        file = method(open(test_file, 'w'), test_pass)
        assert file.tell() == 0
        file.write(test_data)
        assert file.tell() == len(test_data)
        file.close()
Exemplo n.º 5
0
def test_shelf_get(writer, filename, password):
    with file_cleanup(test_file):
        shelf = pc.EncryptedShelf(writer, filename, password)
        shelf["key"] = "value"
        assert shelf["key"] == "value"
        assert shelf.get("key") == "value"
        assert shelf.get("notkey") is None
        assert shelf.get("notkey", "notvalue") == "notvalue"
        shelf.close()
Exemplo n.º 6
0
def test_shelf_get(writer, filename, password):
    with file_cleanup(test_file):
        shelf = pc.EncryptedShelf(writer, filename, password)
        shelf["key"] = "value"
        assert shelf["key"] == "value"
        assert shelf.get("key") == "value"
        assert shelf.get("notkey") is None
        assert shelf.get("notkey", "notvalue") == "notvalue"
        shelf.close()
Exemplo n.º 7
0
def test_read(method):
    test_data = "Some more test data"
    with file_cleanup(test_file):
        file = method(open(test_file, 'w'), test_pass)
        file.write(test_data)
        file.close()

        file = method(test_file, test_pass)
        assert test_data == file.read()
        file.close()
Exemplo n.º 8
0
def test_read(method):
    test_data = "Some more test data"
    with file_cleanup(test_file):
        file = method(open(test_file, 'w'), test_pass)
        file.write(test_data)
        file.close()

        file = method(test_file, test_pass) 
        assert test_data == file.read()
        file.close()
Exemplo n.º 9
0
def test_seek(method):
    test_data = "1234567890"
    with file_cleanup(test_file):
        file = method(open(test_file, 'w'), test_pass)
        file.write(test_data)
        file.close()

        file = method(test_file, test_pass)
        file.seek(-2, 2)
        assert file.read() == test_data[-2:]
        file.close()
Exemplo n.º 10
0
def test_seek(method):
    test_data = "1234567890"
    with file_cleanup(test_file):
        file = method(open(test_file, 'w'), test_pass)
        file.write(test_data)
        file.close()

        file = method(test_file, test_pass)
        file.seek(-2, 2)
        assert file.read() == test_data[-2:]
        file.close()
Exemplo n.º 11
0
def test_shelf_save(writer, filename, password):
    with file_cleanup(test_file):
        shelf = pc.EncryptedShelf(writer, filename, password)
        shelf["somekey"] = "somevalue"
        shelf.close()

        shelf = None

        # load up the old shelf
        shelf = pc.EncryptedShelf(writer, filename, password)
        assert shelf["somekey"] == "somevalue"
        shelf.close()
Exemplo n.º 12
0
def test_shelf_save(writer, filename, password):
    with file_cleanup(test_file):
        shelf = pc.EncryptedShelf(writer, filename, password)
        shelf["somekey"] = "somevalue"
        shelf.close()

        shelf = None

        # load up the old shelf
        shelf = pc.EncryptedShelf(writer, filename, password)
        assert shelf["somekey"] == "somevalue"
        shelf.close()
Exemplo n.º 13
0
def test_write(method):
    with file_cleanup(test_file):
        file = method(open(test_file, 'w'), test_pass)
        file.write("some test data")
        file.close()
Exemplo n.º 14
0
def test_shelf_set(writer, filename, password):
    with file_cleanup(test_file):
        shelf = pc.EncryptedShelf(writer, filename, password)
        shelf["key"] = "value"
        assert shelf["key"] == "value"
        shelf.close()
Exemplo n.º 15
0
def test_write(method):
    with file_cleanup(test_file):
        file = method(open(test_file, 'w'), test_pass)
        file.write("some test data")
        file.close()
Exemplo n.º 16
0
def test_shelf_create(writer, filename, password):
    with file_cleanup(test_file):
        shelf = pc.EncryptedShelf(writer, filename, password)
        shelf.close()
Exemplo n.º 17
0
def test_constructors(method):
    "Test the various file's constructors"
    with file_cleanup(test_file):
        file = method(open(test_file, 'w'), test_pass)
        file.close()
Exemplo n.º 18
0
def test_shelf_set(writer, filename, password):
    with file_cleanup(test_file):
        shelf = pc.EncryptedShelf(writer, filename, password)
        shelf["key"] = "value"
        assert shelf["key"] == "value"
        shelf.close()
Exemplo n.º 19
0
def test_constructors(method):
    "Test the various file's constructors"
    with file_cleanup(test_file):
        file = method(open(test_file, 'w'), test_pass)
        file.close()
Exemplo n.º 20
0
def test_shelf_create(writer, filename, password):
    with file_cleanup(test_file):
        shelf = pc.EncryptedShelf(writer, filename, password)
        shelf.close()