Beispiel #1
0
def test_save_store_when_saving_to_same_file_then_file_is_overridden(
        empty_store, store, test_dir_path, test_file_path, create_test_dir,
        remove_test_dir):
    save_store(store=store, target_dir=test_dir_path)
    save_store(store=empty_store, target_dir=test_dir_path)
    __assert_json_file_contains(content=empty_store.pcs,
                                file_path=test_file_path)
Beispiel #2
0
def test_save_store_when_store_not_empty_then_it_is_saved(
        store, test_dir_path, test_file_path, create_test_dir,
        remove_test_dir):
    content = [{
        store.pcs[0].name: store.pcs[0].components
    }, {
        store.pcs[1].name: store.pcs[1].components
    }]
    save_store(store=store, target_dir=test_dir_path)
    __assert_json_file_contains(content=content, file_path=test_file_path)
Beispiel #3
0
def test_saving_and_loading_store(test_dir_path, remove_test_dir):
    store = Store(pcs=[PC(name='gaming rig',
                          components={'cpu': {'name': 'i7-9700K'},
                                      'gpu': {'name': 'RTX 3070'}}),
                       PC(name='workstation',
                          components={'mobo': {'name': 'ASRock Z390 EXTREME4',
                                               'format': 'ATX'}})])

    save_store(store=store, target_dir=test_dir_path)
    loaded_store = load_store(source_dir=test_dir_path)

    assert len(loaded_store.pcs) == len(store.pcs)

    for pc_id, loaded_pc in enumerate(loaded_store.pcs):
        assert loaded_pc.name == store.pcs[pc_id].name
        assert loaded_pc.components == store.pcs[pc_id].components
Beispiel #4
0
def test_save_store_when_target_dir_is_there_then_it_is_used(
        empty_store, test_dir_path, test_file_path, create_test_dir,
        remove_test_dir):
    save_store(store=empty_store, target_dir=test_dir_path)
    __assert_json_file_contains(content=empty_store.pcs,
                                file_path=test_file_path)