Skip to content

Commit

Permalink
Merge pull request #13 from majensen/master
Browse files Browse the repository at this point in the history
feat(tests): test SCENARIO.md
  • Loading branch information
sap218 authored Jun 26, 2020
2 parents d64128a + 9f79c34 commit 28bafc5
Show file tree
Hide file tree
Showing 5 changed files with 69 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "tests/jabberwocky-tests"]
path = tests/jabberwocky-tests
url = https://github.com/sap218/jabberwocky-tests
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ BeautifulSoup4
scikit-learn
pandas
lxml
pytest
1 change: 1 addition & 0 deletions tests/jabberwocky-tests
Submodule jabberwocky-tests added at d19ae1
54 changes: 54 additions & 0 deletions tests/test_scenario.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import sys
sys.path.extend(['.','..'])
from pdb import set_trace
# see https://click.palletsprojects.com/en/7.x/testing/
from click.testing import CliRunner
from catch.catch import main as catch
from bite.bite import main as bite
from arise.arise import main as arise

# commands in order from SCENARIO.md:
commands = [
[catch, '-o {pocketmonsters} -k {listofwords} -t {public_forum} -p post'],
[bite, '-t {public_forum} -p post'],
[arise, '-o {pocketmonsters} -f {new_synonyms_tfidf}'],
[bite, '-o {updated-ontology} -t {public_forum} -p post'],
[catch, '-o {updated-ontology} -k {listofwords} -t {public_forum} -p post']
]

# actual locations (in the jabberwocky-tests submodule) of the
# files in commands
test_files = {
'pocketmonsters':'tests/jabberwocky-tests/ontology/pocketmonsters.owl',
'listofwords':'tests/jabberwocky-tests/process/listofwords.txt',
'updated-ontology':'tests/jabberwocky-tests/process/updated-ontology.owl',
'public_forum':'tests/jabberwocky-tests/process/public_forum.json',
'bite_01_tfidf_results':'tests/jabberwocky-tests/process/bite_01_tfidf_results.csv',
'new_synonyms_tfidf':'tests/jabberwocky-tests/process/new_synonyms_tfidf.csv'
}

out_files = [
'catch_01_output.txt',
'catch_01_ontology_dict_class_synonyms.json',
'updated-ontology.owl',
'bite_02_tfidf_results.csv',
'bite_02_ontology_all_terms.txt',
'catch_02_output.txt'
]

def test_import():
# everything's cool so far
pass

def test_scenario():
runner = CliRunner()
# test each command run in SCENARIO.md:
for cmd in commands:
(script, arg) = cmd
interp = arg.format(**test_files) # interpolate the actual file paths
arglist = interp.split(' ') # CliRunner needs a list, not a string
result = runner.invoke(script,arglist) # Run it!
assert result.exit_code == 0 # sucessful run
# additional tests might be
# examine result.output (a str) in each case, to confirm expected output

10 changes: 10 additions & 0 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[tox]
envlist = py3

[testenv]
deps =
pytest
-r requirements.txt
commands =
pytest

0 comments on commit 28bafc5

Please # to comment.