示例#1
0
def list_library(arg,
                 library_db=_library_db,
                 query_start=_query_start,
                 query_end=_query_end):
    """handles listing loaded libraries"""
    from src.praxxis.library import list_library

    list_library.list_library(library_db, query_start, query_end)
示例#2
0
def test_add_regular_library(setup, library_db, git_root, query_start,
                             query_end):
    from src.praxxis.library import add_library
    from src.praxxis.library import list_library
    from src.praxxis.library import remove_library
    from tests.src.praxxis.util import dummy_object

    library_path = dummy_object.make_dummy_library_path()
    library = dummy_object.make_dummy_library()

    add_library.add_library(library_path, library_db, git_root)

    libraries = list_library.list_library(library_db, query_start, query_end)
    assert len(libraries) == 1
    remove_library.remove_library(library, library_db, query_start, query_end)
    libraries = list_library.list_library(library_db, query_start, query_end)
    assert len(libraries) == 0
示例#3
0
def test_add_git_library(setup, library_db, git_root, query_start, query_end):
    from src.praxxis.library import add_library
    from src.praxxis.library import remove_library
    from src.praxxis.library import list_library
    from tests.src.praxxis.util import dummy_object
    from src.praxxis.util import rmtree

    url = dummy_object.make_dummy_git_repo()
    add_library.add_library(url, library_db, git_root)

    libraries = list_library.list_library(library_db, query_start, query_end)
    assert len(libraries) == 1
    remove_library.remove_library(url, library_db, query_start, query_end)
    libraries = list_library.list_library(library_db, query_start, query_end)

    assert len(libraries) == 0
    rmtree.rmtree(git_root, test=True)
示例#4
0
def test_add_library(setup, library_db, query_start, query_end): 
    from tests.src.praxxis.util import dummy_object
    from src.praxxis.library import remove_library
    from src.praxxis.library import list_library

    dummy_library = dummy_object.make_dummy_library_path()
    entry_library.add_library(dummy_library, library_db)
    assert len(list_library.list_library(library_db, query_start, query_end)) == 1

    remove_library.remove_library(dummy_library, library_db, query_start, query_end)
示例#5
0
def test_sync_library(setup, add_test_library, library_root, library_db,
                      libraries_list, query_start, query_end):
    """
    tests sync_library functionality. Requires that setup is run and the test notebooks are added.
    """
    from src.praxxis.library import sync_library
    from src.praxxis.library import list_library
    from tests.src.praxxis.util import dummy_object
    import os

    sync_library.sync_library(library_root, library_db)

    assert set(libraries_list) == set(
        *list_library.list_library(library_db, query_start, query_end))
示例#6
0
def setup(init_root, library_root, telemetry_db, library_db, output_root,
          scene_root, history_db, default_scene_name, query_start, query_end,
          rulesengine_root, rulesengine_db):
    """
    sets up directories in the temp dir
    """
    from src.praxxis.sqlite import sqlite_init
    from src.praxxis.sqlite import sqlite_scene
    from src.praxxis.sqlite import sqlite_library
    from src.praxxis.sqlite import sqlite_rulesengine
    from src.praxxis.util import roots
    from src.praxxis.scene import new_scene
    from src.praxxis.scene import list_scene
    from src.praxxis.parameter import list_param
    from src.praxxis.library import list_library
    from src.praxxis.notebook import list_notebook
    from src.praxxis.sqlite import sqlite_telemetry

    if not os.path.exists(init_root):
        os.mkdir(init_root)
        assert os.path.exists(init_root)

    if not os.path.exists(library_root):
        os.mkdir(library_root)
        assert os.path.exists(library_root)

    if not os.path.exists(library_db):
        sqlite_init.init_library_db(library_db)
        assert os.path.exists(library_db)

    if not os.path.exists(output_root):
        os.mkdir(output_root)
        assert os.path.exists(output_root)

    if not os.path.exists(scene_root):
        os.mkdir(scene_root)
        assert os.path.exists(scene_root)

    if not os.path.exists(history_db):
        sqlite_init.init_history(history_db, default_scene_name)
        assert os.path.exists(history_db)

    if not os.path.exists(telemetry_db):
        sqlite_init.init_user_info(telemetry_db, 0)

    if not os.path.exists(rulesengine_root):
        os.mkdir(rulesengine_root)
        assert os.path.exists(rulesengine_root)

    if not os.path.exists(rulesengine_db):
        sqlite_init.init_rulesengine_db(rulesengine_db)

    new_scene.new_scene(default_scene_name, scene_root, history_db)
    yield
    current_scene_db = roots.get_current_scene_db(scene_root, history_db)
    assert len(list_scene.list_scene(init_root, history_db)) == 1
    assert len(list_param.list_param(current_scene_db, query_start,
                                     query_end)) == 0
    assert len(list_library.list_library(library_db, query_start,
                                         query_end)) == 0
    assert len(
        list_notebook.list_notebook(library_db, current_scene_db, query_start,
                                    query_end)) == 0
示例#7
0
def test_list_library(setup, add_test_library, library_db, query_start, query_end):
    from src.praxxis.library import list_library
    entry_library.list_library("", library_db)
    assert len(list_library.list_library(library_db, query_start, query_end)) == 1
示例#8
0
def test_sync_library(setup, library_root, library_db, query_start, query_end):
    from src.praxxis.library import list_library

    entry_library.sync_library("", library_root, library_db)
    libraries = list_library.list_library(library_db, query_start, query_end)
    assert len(libraries) == 0