Skip to content

Commit

Permalink
Test validate_selection; if fail, print logs in CI
Browse files Browse the repository at this point in the history
  • Loading branch information
hooveran committed Oct 30, 2023
1 parent 21a03cf commit 278dfd2
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 7 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/matcher_ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,11 @@ jobs:
# Tests succeed iff containers exit 0
run: |
errors=0
container_ids=$(sudo sh -c "docker ps | grep -E 'matcher-backend|matcher_backend' | awk '{ print \$1 }'")
container_ids=$(docker ps | grep -E 'matcher-backend|matcher_backend' | awk '{ print $1 }')
for container_id in $container_ids; do
if [ $(docker wait $container_id) -ne 0 ]; then
errors=$((errors+1))
docker logs $container_id
fi
done
if [ $errors -ne 0 ]; then
Expand Down
2 changes: 1 addition & 1 deletion backend/initialize_db/test_start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ metadata=$INITIALIZE_DIR/test_metadata.csv
example_queries=$INITIALIZE_DIR/example_queries.json

if [[ "$RUN_TESTS" == "true" ]]; then
conda run --no-capture-output -n matcher-api pytest -s ./backend/tests/unit_tests || exit 1
conda run --no-capture-output -n matcher-api pytest -s -v ./backend/tests/unit_tests || exit 1
# Only run unit tests for now
exit 0
fi
Expand Down
28 changes: 23 additions & 5 deletions backend/tests/unit_tests/test_validate_selection.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,27 @@
"""Test validate_selection function."""
import sys

from backend.ss_select import validate_selection
from backend.models import SketchedContent

def test_hello_world():
print("Test validate_selection")
#assert 1 == 0
return None
def test_validate_selection():

mol1_molfile = """
Ketcher 103023 8282D 1 1.00000 0.00000 0
2 1 0 0 0 0 999 V2000
4.9167 -5.8333 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
5.7827 -5.3333 0.0000 O 0 0 0 0 0 0 0 0 0 0 0 0
1 2 1 0 0 0
M END
"""
selection_type = 'variable'
sketched_content = SketchedContent.parse_obj({'mol1_molfile': mol1_molfile})
mol1_selected_atoms = '1'
mol1_selected_bonds = ''
mol2_selected_atoms = ''
mol2_selected_bonds = ''

result = validate_selection(selection_type, sketched_content, mol1_selected_atoms,
mol1_selected_bonds, mol2_selected_atoms, mol2_selected_bonds)

assert result == ([1], [], [0], [], 'False', [], [], [], [], 'False')

0 comments on commit 278dfd2

Please sign in to comment.