Skip to content

Commit d46841f

Browse files
committed
first-shot test for jqlcomposer
first try with first file - there needs to be much more
1 parent 7188eac commit d46841f

File tree

4 files changed

+30
-1
lines changed

4 files changed

+30
-1
lines changed

.github/workflows/python-package.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,4 +37,4 @@ jobs:
3737
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
3838
- name: Test with pytest
3939
run: |
40-
pytest
40+
pytest test

test/expect1.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
("month IN (June, July, August)") AND (temperature > 20)

test/test1.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"summer": "{month_in_long_day_territory} AND {temperature_above_lukewarm}",
3+
"month_in_long_day_territory": "month IN (June, July, August)",
4+
"temperature_above_lukewarm": "temperature > 20"
5+
}

test/test_jqlcomposer.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import jqlcomposer.jqlcomposer
2+
import subprocess
3+
import filecmp
4+
5+
TEST_TERMS=["summer"]
6+
7+
test_jqlcomposer_main_asfile():
8+
for i in xrange(len(TEST_TERMS)):
9+
idx = i+1
10+
with open(f"testout{idx}.txt", "w") as outfile
11+
subprocess.run(["python", "jqlcomposer.py", TEST_TERMS[i], "--filename", f"test{idx}.json"], stdout=outfile)
12+
assert 0 == filecmp.cmp(f"testout{idx}.txt", f"expect{idx}.txt")
13+
14+
test_jqlcomposer_main_astext():
15+
for i in xrange(len(TEST_TERMS)):
16+
idx = i+1
17+
json_contents = ""
18+
with open(f"test{idx}.json", "r") as infile:
19+
json_contents = infile.read()
20+
with open(f"testout{idx}.txt", "w") as outfile
21+
subprocess.run(["python", "jqlcomposer.py", TEST_TERMS[i], f'"{json_contents}"'], stdout=outfile)
22+
assert 0 == filecmp.cmp(f"testout{idx}.txt", f"expect{idx}.txt")
23+

0 commit comments

Comments
 (0)