def test_filter_interface(core, project, tree):

    project = deepcopy(project)

    data_menu = DataMenu()
    module_menu = ModuleMenu()
    project_menu = ProjectMenu()

    tree = Tree()

    data_menu.select_database(project, "local")
    project_menu.initiate_pipeline(core, project)
    project_menu.initiate_options(core, project)

    filter_branch = tree.get_branch(core, project,
                                    'Database Filtering Interface')
    new_var = filter_branch.get_input_variable(core, project,
                                               "device.selected_name")
    new_var.set_raw_interface(core, "ExampleWaveDevice")
    new_var.read(core, project)

    module_menu.activate(core, project, "Hydrodynamics")

    project_menu.initiate_filter(core, project)

    assert True
Example #2
0
def test_DataMenu_deselect_database(mocker, tmpdir, project):

    # Make a source directory with some files
    config_tmpdir = tmpdir.mkdir("config")
    mock_dir = Directory(str(config_tmpdir))

    mocker.patch("dtocean_core.utils.database.UserDataDirectory",
                 return_value=mock_dir)

    # Create mock connection
    mocker.patch("dtocean_core.menu.check_host_port",
                 return_value=(True, "Mock connection returned"))

    data_menu = DataMenu()
    project = deepcopy(project)

    assert project.get_database_credentials() is None

    dbs = data_menu.get_available_databases()
    db_id = dbs[0]
    data_menu.select_database(project, db_id)

    assert project.get_database_credentials()

    data_menu.deselect_database(project)

    assert project.get_database_credentials() is None
Example #3
0
def database(core, project):

    project = deepcopy(project)
    data_menu = DataMenu()

    data_menu.select_database(project, "testing")
    database = get_database(project.get_database_credentials())

    return database
Example #4
0
def test_DataMenu_select_database_no_port_dbname(mocker, tmpdir, project):

    # Make a source directory with some files
    config_tmpdir = tmpdir.mkdir("config")
    mock_dir = Directory(str(config_tmpdir))

    mocker.patch("dtocean_core.utils.database.UserDataDirectory",
                 return_value=mock_dir)

    data_menu = DataMenu()
    project = deepcopy(project)

    with pytest.raises(RuntimeError):
        data_menu.select_database(project, credentials={"host": "-1.-1.-1.-1"})
Example #5
0
def test_DataMenu_select_database_bad_id(mocker, tmpdir, project):

    # Make a source directory with some files
    config_tmpdir = tmpdir.mkdir("config")
    mock_dir = Directory(str(config_tmpdir))

    mocker.patch("dtocean_core.utils.database.UserDataDirectory",
                 return_value=mock_dir)

    data_menu = DataMenu()
    project = deepcopy(project)

    with pytest.raises(ValueError):
        data_menu.select_database(project, "bad_id")
def test_connect_TableDataColumn(core, project, tree):

    var_id = "hidden.available_sites"

    project = deepcopy(project)

    data_menu = DataMenu()
    project_menu = ProjectMenu()

    data_menu.select_database(project, "local")
    project_menu.initiate_pipeline(core, project)

    proj_branch = tree.get_branch(core, project, "Site and System Options")
    var = proj_branch.get_input_variable(core, project, var_id)
    inputs = proj_branch.get_input_status(core, project)

    assert inputs[var_id] == 'satisfied'
    assert 'ExampleSite' in var.get_value(core, project)["site_name"].values
def test_get_query_interface(core, project, tree):

    mod_name = "Site and System Options"
    var_id = "hidden.available_sites"

    data_menu = DataMenu()
    project_menu = ProjectMenu()

    project = deepcopy(project)

    data_menu.select_database(project, "local")
    project_menu.initiate_pipeline(core, project)

    options_branch = tree.get_branch(core, project, mod_name)
    new_var = options_branch.get_input_variable(core, project, var_id)

    result = new_var._get_query_interface(core, project)

    assert result is not None