-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathequel-test.py
executable file
·28 lines (23 loc) · 975 Bytes
/
equel-test.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
#!/usr/bin/env python3
# EQUEL test suite
import unittest
from equel.engine import EQUELEngine
from glob import glob
import os
import json
testcasedir = "testcases"
class EQUELTest(unittest.TestCase):
def setUp(self):
self.ee = EQUELEngine()
def test_conversion(self):
"""Test conversion from EQUEL expression into Elasticsearch DSL JSON query."""
for testfile in glob(testcasedir + "/*.equel"):
expectedfile=testfile[:-len(".equel")] + ".json"
with self.subTest(testname=os.path.basename(testfile)[:-len(".equel")]):
convertedjson = self.ee.parseEQUELFile(testfile).query
jsonfile = open(expectedfile)
expectedjson = json.load(jsonfile)
jsonfile.close()
self.assertEqual(convertedjson, expectedjson, "Elasticsearch DSL JSON request generated by EQUEL doesn't matches expected result.")
if __name__ == '__main__':
unittest.main()