Ejemplo n.º 1
0
def test_backlog_creation_file_update(setup, telemetry_db, add_test_library):
    """tests whether backlog is initialized when updating a file"""
    from src.praxxis.telemetry import update_file_output
    from src.praxxis.sqlite import sqlite_telemetry
    from tests.src.praxxis.util import dummy_object
    
    notebook1 = dummy_object.make_dummy_notebook()
    ID = "garbageID"
    
    # turn on telem setting
    sqlite_telemetry.write_setting(telemetry_db, "TELEMETRY", 1)
    assert sqlite_telemetry.telem_on(telemetry_db)

    update_file_output.update_file_output_entrance(telemetry_db, notebook1.path, ID)

    backlog = sqlite_telemetry.get_backlog(telemetry_db)
    backlog_len = sqlite_telemetry.backlog_size(telemetry_db)

    assert len(backlog) == 1
    assert len(backlog) == backlog_len

    # check format of backlog
    assert len(backlog[0]) == 3
    assert backlog[0][0] == notebook1.path
    assert backlog[0][1] == ID
    assert backlog[0][2] == 1 # failed on delete
    
    # cleanup
    sqlite_telemetry.clear_backlog(telemetry_db)
    sqlite_telemetry.write_setting(telemetry_db, "TELEMETRY", 0)
Ejemplo n.º 2
0
def test_open_notebook_jupyter(setup, add_test_library, current_scene_db, library_db, ads_location):
    from src.praxxis.notebook import open_notebook
    from tests.src.praxxis.util import dummy_object

    notebook1 = dummy_object.make_dummy_notebook(viewer="jupyter")
    assert open_notebook.open_notebook(notebook1, current_scene_db, library_db, ads_location, test=True) == 0
    
Ejemplo n.º 3
0
def test_run_notebook(setup, add_test_library, telemetry_db, output_root, library_root, library_db, scene_root, history_db, current_scene_db):
    import os
    from src.praxxis.sqlite import sqlite_scene
    from src.praxxis.scene import history

    notebook = dummy_object.make_dummy_notebook()
    entry_notebook.run_notebook(notebook, telemetry_db, output_root, library_root, library_db, scene_root, history_db, current_scene_db)
    assert len(history.history(history_db, library_db, current_scene_db)) == 1
    sqlite_scene.clear_history(current_scene_db)
Ejemplo n.º 4
0
def test_backlog_continuation(setup, telemetry_db, add_test_library):
    """tests that backlog continues to be updated"""
    from src.praxxis.telemetry import telemetry
    from src.praxxis.sqlite import sqlite_telemetry
    from tests.src.praxxis.util import dummy_object

    sqlite_telemetry.clear_backlog(telemetry_db)
    
    notebook1 = dummy_object.make_dummy_notebook()
    notebook2 = dummy_object.make_dummy_notebook()
    ID = "garbageID"
    telemetry.telem_entrance(telemetry_db, "notebook1.path", ID)
    telemetry.telem_entrance(telemetry_db, "notebook2.path", ID)

    backlog = sqlite_telemetry.get_backlog(telemetry_db)

    assert len(backlog) == 2

    sqlite_telemetry.clear_backlog(telemetry_db)
Ejemplo n.º 5
0
def test_open_notebook_ads(setup, add_test_library, current_scene_db, library_db, ads_location):
    from src.praxxis.notebook import open_notebook
    from tests.src.praxxis.util import dummy_object
    from src.praxxis.util import error
    from src.praxxis.display import display_error

    notebook1 = dummy_object.make_dummy_notebook(viewer="ads")
    try:
        assert open_notebook.open_notebook(notebook1, current_scene_db, library_db, ads_location, test=True) == 0
    except error.ADSNotFoundError as e:
        assert str(e) == display_error.ads_not_found_error(ads_location)
Ejemplo n.º 6
0
def test_open_notebook(setup, add_test_library, scene_root, history_db, library_db, ads_location, current_scene_db,):
    notebook = dummy_object.make_dummy_notebook()
    from src.praxxis.util import error
    try:
        entry_notebook.open_notebook(notebook, scene_root, history_db, library_db, ads_location, current_scene_db)
    except error.EditorNotFoundError:
        assert 1
    except error.ADSNotFoundError:
        assert 1
    except Exception:
        assert 0
    else:
        assert 1
Ejemplo n.º 7
0
def test_open_notebook_editor(setup, add_test_library, current_scene_db, library_db, ads_location):
    from src.praxxis.notebook import open_notebook
    from tests.src.praxxis.util import dummy_object
    from src.praxxis.util import error
    from src.praxxis.display import display_error

    notebook1 = dummy_object.make_dummy_notebook()
    editor = "vim"
    try:
        assert open_notebook.open_notebook(notebook1, current_scene_db, library_db, ads_location, editor, test=True) == 0
    except error.EditorNotFoundError as e:
        # if vim not installed (e.g. windows)
        assert str(e) == display_error.editor_not_found_error(editor)
Ejemplo n.º 8
0
def generate_short_history(setup, add_test_library, telemetry_db, output_root,
                           current_scene_db, library_root, library_db,
                           query_start, query_end):
    from src.praxxis.notebook import run_notebook
    from tests.src.praxxis.util import dummy_object
    from src.praxxis.sqlite import sqlite_scene
    import os

    notebook1 = dummy_object.make_dummy_notebook()
    run_notebook.run_notebook(notebook1, telemetry_db, output_root,
                              current_scene_db, library_root, library_db,
                              query_start, query_end)
    yield
    sqlite_scene.clear_history(current_scene_db)
Ejemplo n.º 9
0
def test_telemetry_off(setup, telemetry_db, add_test_library):
    from src.praxxis.sqlite import sqlite_telemetry
    from src.praxxis.telemetry import update_file_output
    from src.praxxis.sqlite import sqlite_telemetry
    from tests.src.praxxis.util import dummy_object

    sqlite_telemetry.write_setting(telemetry_db, "TELEMETRY", 0)

    notebook1 = dummy_object.make_dummy_notebook()
    ID = "garbageID"
    update_file_output.update_file_output_entrance(telemetry_db, notebook1.path, ID)

    backlog_len = sqlite_telemetry.backlog_size(telemetry_db)

    assert backlog_len == 0
Ejemplo n.º 10
0
def test_add_notebook(setup, library_db, current_scene_db, query_start,
                      query_end):
    from src.praxxis.notebook import add_notebook
    from src.praxxis.notebook import remove_notebook
    from tests.src.praxxis.util import dummy_object
    from src.praxxis.notebook import list_notebook

    dummy_notebook_path = dummy_object.make_dummy_notebook_path()
    dummy_notebook = dummy_object.make_dummy_notebook()

    add_notebook.add_notebook(dummy_notebook_path, library_db)
    assert len(
        list_notebook.list_notebook(library_db, current_scene_db, query_start,
                                    query_end)) == 1

    remove_notebook.remove_notebook(dummy_notebook, library_db,
                                    current_scene_db)
    assert len(
        list_notebook.list_notebook(library_db, current_scene_db, query_start,
                                    query_end)) == 0
Ejemplo n.º 11
0
def test_backlog_creation(setup, telemetry_db, add_test_library):
    """tests whether backlog is initialized"""
    from src.praxxis.telemetry import telemetry
    from src.praxxis.sqlite import sqlite_telemetry
    from tests.src.praxxis.util import dummy_object
    
    notebook1 = dummy_object.make_dummy_notebook()
    ID = "garbageID"
    telemetry.telem_entrance(telemetry_db, notebook1.path, ID)

    backlog = sqlite_telemetry.get_backlog(telemetry_db)
    backlog_len = sqlite_telemetry.backlog_size(telemetry_db)

    assert len(backlog) == 1
    assert len(backlog) == backlog_len

    # check format of backlog
    assert len(backlog[0]) == 3
    assert backlog[0][0] == notebook1.path
    assert backlog[0][1] == ID
    
    sqlite_telemetry.clear_backlog(telemetry_db)
Ejemplo n.º 12
0
def test_list_notebook(setup, add_test_library, scene_root, history_db, library_root, library_db, query_start, query_end, current_scene_db):
    from src.praxxis.notebook import list_notebook
    notebook = dummy_object.make_dummy_notebook()

    entry_notebook.list_notebook(notebook, scene_root, history_db, library_root, library_db, query_start, query_end, current_scene_db)
    assert len(list_notebook.list_notebook(library_db,current_scene_db, query_start, query_end)) == 3