added bunker.bunker.Bunker
This commit is contained in:
35
test/test_bunker_privates.py
Normal file
35
test/test_bunker_privates.py
Normal file
@@ -0,0 +1,35 @@
|
||||
import os
|
||||
import pytest
|
||||
|
||||
from bunker.bunker import Bunker
|
||||
from bunker.files.bunkeredfile import BunkeredFile
|
||||
|
||||
@pytest.fixture
|
||||
def bunker_with_test_file_empty(tmpdir):
|
||||
path = os.path.join(str(tmpdir), "test.bunker")
|
||||
bunker = Bunker.open(path)
|
||||
bunker._add_component("test", b"H6ihKLXV8HMQWbJs", "kvs")
|
||||
|
||||
return bunker, "test", b"H6ihKLXV8HMQWbJs"
|
||||
|
||||
def test_add_component(tmpdir):
|
||||
path = os.path.join(str(tmpdir), "test.bunker")
|
||||
bunker = Bunker.open(path)
|
||||
bunker._add_component("test", b"H6ihKLXV8HMQWbJs", "kvs")
|
||||
|
||||
assert {"component": "test"} in bunker._components
|
||||
|
||||
def test_load_component1(bunker_with_test_file_empty):
|
||||
bunker, component_name, password = bunker_with_test_file_empty
|
||||
component, type_ = bunker._load_component(component_name, password)
|
||||
|
||||
assert isinstance(component, BunkeredFile)
|
||||
|
||||
def test_save_and_load(bunker_with_test_file_empty):
|
||||
bunker, component_name, password = bunker_with_test_file_empty
|
||||
component, type_ = bunker._load_component(component_name, password)
|
||||
component.write(b"this is a test text")
|
||||
bunker._save_compontent(component_name, password, component)
|
||||
component, type_ = bunker._load_component(component_name, password)
|
||||
|
||||
assert component.read() == b"this is a test text"
|
Reference in New Issue
Block a user