def test_api_local(path_to_klifs_download, path_to_klifs_metadata): """ Test Session attributes for local session. Parameters ---------- path_to_klifs_download : pathlib.Path or str Path to folder with KLIFS download files. path_to_klifs_metadata : pathlib.Path or str Path to KLIFS metadata file (default is None). Set this parameter, if you have initialized a local session before and therefore already have a KLIFS metadata file. You could pass here a filtered version of this KLIFS metadata file. """ session = setup_local(path_to_klifs_download, path_to_klifs_metadata) assert session._client is None assert isinstance(session._database, pd.DataFrame) assert isinstance(session.kinases, local.Kinases) assert isinstance(session.ligands, local.Ligands) assert isinstance(session.structures, local.Structures) assert isinstance(session.bioactivities, local.Bioactivities) assert isinstance(session.interactions, local.Interactions) assert isinstance(session.coordinates, local.Coordinates)
from pathlib import Path from bravado_core.exception import SwaggerMappingError import pandas as pd import pytest from rdkit import Chem from opencadd.databases.klifs.api import setup_local, setup_remote from opencadd.databases.klifs.schema import DATAFRAME_COLUMNS from opencadd.utils import enter_temp_directory PATH_TEST_DATA = Path(__name__).parent / "opencadd/tests/data/klifs" # Set local and remote session REMOTE = setup_remote() LOCAL = setup_local(PATH_TEST_DATA) def check_dataframe(dataframe, columns): """ Base function that tests if input is a DataFrame, if column names and index is correct. """ # Is input a DataFrame? assert isinstance(dataframe, pd.DataFrame) # Are DataFrame column names and their order correct? assert dataframe.columns.to_list() == [column[0] for column in columns] # Are DataFrame indices enumerated starting from 0 to length of DataFrame - 1? assert dataframe.index.to_list() == list(range(0, len(dataframe)))