-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_exec.py
26 lines (22 loc) · 1.11 KB
/
test_exec.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
import os
import pytest
import unittest
from executor import Executor
localities = [os.path.join("localities", f) for f in os.listdir('./localities') if f.endswith('yml')]
localities.sort()
templates = [os.path.join("test_templates", f) for f in os.listdir('./test_templates') if f.endswith('yml')]
templates.sort()
test_cases = [(l, t) for l in localities for t in templates]
class TestExecutor:
@pytest.mark.parametrize("locality,template", test_cases)
def test_response(self, locality, template):
print (os.environ["PYTEST_CURRENT_TEST"])
executor = Executor(locality)
artifacts = executor.exec(template)
assert len(artifacts['expected']) <= len(artifacts['actual']), "response contains too many people"
assert len(artifacts['expected']) >= len(artifacts['actual']), "response contains too few people"
expected = {}
for expectation in artifacts['expected']:
expected[expectation['person_id']] = expectation
for result in artifacts['actual']:
assert expected[result['person_id']]['is_eligible'] == result['is_eligible'], result['reasons']