Exemple #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()
Exemple #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()
Exemple #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()
Exemple #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()
Exemple #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()
Exemple #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()
Exemple #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()
Exemple #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()
Exemple #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()
Exemple #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()
Exemple #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()
Exemple #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()
Exemple #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()
Exemple #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()
Exemple #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()
Exemple #16
0
def test_shelf_create(writer, filename, password):
    with file_cleanup(test_file):
        shelf = pc.EncryptedShelf(writer, filename, password)
        shelf.close()
Exemple #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()
Exemple #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()
Exemple #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()
Exemple #20
0
def test_shelf_create(writer, filename, password):
    with file_cleanup(test_file):
        shelf = pc.EncryptedShelf(writer, filename, password)
        shelf.close()