forked from crosscompute/crosscompute-examples
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_examples.py
28 lines (22 loc) · 950 Bytes
/
test_examples.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
from crosscompute.tests import run, serve
from pandas import read_csv
def test_add_integers(tmpdir):
args = str(tmpdir), 'add-integers', {'x_integer': 2, 'y_integer': 3}
r = run(*args)
assert r['standard_output'] == '5'
s = serve(*args)[0]
assert s.find(id='standard_output-meta').text.strip() == '5'
def test_find_primes(tmpdir):
args = str(tmpdir), 'find-primes', {'x_integer': 2016}
r = run(*args)
assert r['standard_outputs']['unique_factor_count'] == 3
def test_count_words(tmpdir):
args = str(tmpdir), 'count-words', {'document_text_path': 'words.txt'}
r = run(*args)
assert r['standard_outputs']['word_count'] == 113
t = read_csv(r['standard_outputs']['word_count_table_path'])
assert t['count'].sum() == 113
args = str(tmpdir), 'count-words', {
'document_text_txt': 'curae canitiem inducunt'}
s = serve(*args)[0]
s.find(id='word_count-result').text.strip() == '3'