Skip to content

Commit

Permalink
tests various gv files with problems
Browse files Browse the repository at this point in the history
  • Loading branch information
pmendes committed May 21, 2024
1 parent d997f70 commit 943ec75
Show file tree
Hide file tree
Showing 2 changed files with 76 additions and 0 deletions.
12 changes: 12 additions & 0 deletions tests/0503_GvIssues/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# 0503_GvIssues

tests various graphviz network files that should raise warnings or errors

## tests

- 1D, network, transport
- appropriate warning for an empty network file
- appropriate warning for a network file without edges
- appropriate warning for test a network file with repeated edges
- ensure that repeated edges are added exactly once to model
- appropriate warning for a network file with non-numeric nodes
64 changes: 64 additions & 0 deletions tests/0503_GvIssues/run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
#!/bin/bash

# work out our folder name
test=${PWD##*/} # to assign to a variable
test=${test:-/} # to correct for the case where PWD=/

fail=0

# test an empty network file
../../sbmodelr -t G -n ../sources/empty.gv -o t.cps ../sources/GeneExpressionUnit.cps 2 > output

# check that the correct warning is issued
if ! grep -q " Warning: ../sources/empty.gv did not contain any valid edges, no connections added" output; then
printf 'FAIL %s\n' "${test}"
let "fail = 1"
fi

# test a network file without edges
../../sbmodelr -t G -n ../sources/no-edges.gv -o t.cps ../sources/GeneExpressionUnit.cps 2 > output

# check that the correct warning is issued
if ! grep -q " Warning: ../sources/no-edges.gv did not contain any valid edges, no connections added" output; then
printf 'FAIL %s\n' "${test}"
let "fail = $fail + 2"
fi

# test a network file with repeated edges
../../sbmodelr -t G -n ../sources/duplicates.gv -o t.cps ../sources/GeneExpressionUnit.cps 4 > output

# check that the correct warning is issued
if ! grep -q " Warning: duplicate entry for connection 1 to 3, ignored" output; then
printf 'FAIL %s\n' "${test}"
let "fail = $fail + 4"
fi

# create model summary
../model_report.py t.cps >/dev/null
if ! [[ $? = 0 ]]; then
printf 'FAIL %s\n' "${test}"
exit -1
fi

# check that there is exactly one transport reaction 1->3 (the duplicate)
n=$(grep -Pc "^t_G_1-3\s+G_1 = G_3\s+Mass action" t.summary.txt )
if ((n != 1)) ; then
printf 'FAIL %s\n' "${test}"
let "fail = $fail + 8"
fi

# test a network file with non-numeric nodes
../../sbmodelr -t G -n ../sources/non-numeric-nodes.gv -o t.cps ../sources/GeneExpressionUnit.cps 3 > output

# check that the correct warning is issued
if ! grep -q " Warning: ../sources/non-numeric-nodes.gv did not contain any valid edges, no connections added" output; then
printf 'FAIL %s\n' "${test}"
let "fail = $fail + 16"
fi

if [ "$fail" = 0 ] ; then
printf 'PASS %s\n' "${test}"
rm t.summary.txt output *.cps
fi

exit $fail

0 comments on commit 943ec75

Please sign in to comment.