Skip to content

Commit

Permalink
Added tests for CatalogTable.as_list_of_dicts (#1319)
Browse files Browse the repository at this point in the history
* Implemented test case with empty and standard input.
  • Loading branch information
Daud Ahmed committed Oct 23, 2024
1 parent e88559c commit a3eeb30
Show file tree
Hide file tree
Showing 2 changed files with 126 additions and 0 deletions.
102 changes: 102 additions & 0 deletions test/inputs/catalog_samples.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
[
{
"Identifier": "eos1579",
"Slug": "metabokiller",
"Title": "Carcinogenic potential of metabolites and small molecules"
},
{
"Identifier": "eos157v",
"Slug": "grover-freesolv",
"Title": "Hydration free energy of small molecules in water"
},
{
"Identifier": "eos18ie",
"Slug": "antibiotics-ai",
"Title": "Substructure-based search of novel antibiotics"
},
{
"Identifier": "eos1af5",
"Slug": "molgrad-caco2",
"Title": "Coloring molecules for Caco-2 cell permeability"
},
{
"Identifier": "eos1amn",
"Slug": null,
"Title": "3D pharmacophore descriptor"
},
{
"Identifier": "eos1amr",
"Slug": "grover-bbbp",
"Title": "Blood-brain barrier penetration"
},
{
"Identifier": "eos1bba",
"Slug": null,
"Title": "GeoGNN Molecular Representation Prediction"
},
{
"Identifier": "eos1d7r",
"Slug": "small-world-zinc",
"Title": "Small World Zinc search"
},
{
"Identifier": "eos1mxi",
"Slug": "smiles-pe",
"Title": "SmilesPE: tokenizer algorithm for SMILES, DeepSMILES, and SELFIES"
},
{
"Identifier": "eos1n4b",
"Slug": "hdac3-inh",
"Title": "Identifying HDAC3 inhibitors"
},
{
"Identifier": "eos1noy",
"Slug": "chembl-sampler",
"Title": "ChEMBL Molecular Sampler"
},
{
"Identifier": "eos1pu1",
"Slug": "cardiotox-dictrank",
"Title": "Cardiotoxicity Classifier"
},
{
"Identifier": "eos1ut3",
"Slug": "molfeat-usrcat",
"Title": "USR descriptors with pharmacophoric constraints"
},
{
"Identifier": "eos1vms",
"Slug": "chembl-multitask-descriptor",
"Title": "Multi-target prediction based on ChEMBL data"
},
{
"Identifier": "eos1xje",
"Slug": "biogpt-embeddings",
"Title": "BioGPT embeddings"
},
{
"Identifier": "eos21q7",
"Slug": "inter_dili",
"Title": "InterDILI: drug-induced injury prediction"
},
{
"Identifier": "eos22io",
"Slug": "idl-ppbopt",
"Title": "Human Plasma Protein Binding (PPB) of Compounds"
},
{
"Identifier": "eos238c",
"Slug": "mesh-therapeutic-use",
"Title": "MeSH therapeutic use based on chemical structure"
},
{
"Identifier": "eos2401",
"Slug": "scaffold-decoration",
"Title": "Scaffold decoration"
},
{
"Identifier": "eos24ci",
"Slug": "drugtax",
"Title": "DrugTax: Drug taxonomy"
}
]
24 changes: 24 additions & 0 deletions test/test_catalog.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import json
import os
import pytest
from ersilia.hub.content.catalog import CatalogTable

@pytest.fixture
def catalog_samples():
file_path = os.path.join(os.path.dirname(__file__), 'inputs', 'catalog_samples.json')
with open(file_path, 'r') as f:
samples = json.load(f)
return samples

def test_as_list_of_dicts(catalog_samples):
columns = ['Identifier', 'Slug', 'Title']

# Test with standard catalog samples
catalog_table = CatalogTable(data=[list(item.values()) for item in catalog_samples], columns=columns)
result = catalog_table.as_list_of_dicts()
assert result == catalog_samples, "The result does not match the expected catalog samples"

# Test with empty catalog data
catalog_table_empty = CatalogTable(data=[], columns=columns)
result_empty = catalog_table_empty.as_list_of_dicts()
assert result_empty == [], "The result should be an empty list for empty input data"

0 comments on commit a3eeb30

Please sign in to comment.