Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

feat(tests): test SCENARIO.md #13

Merged
merged 1 commit into from
Jun 26, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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