|
|
import sys |
|
|
import json |
|
|
from io import StringIO |
|
|
from app import get_response |
|
|
|
|
|
def test_quality(): |
|
|
"""Tests if the expected functions and values are used""" |
|
|
with open("tests/qa_questions.json") as f: |
|
|
qs = json.load(f) |
|
|
|
|
|
for q in qs: |
|
|
|
|
|
stdout = StringIO() |
|
|
sys.stdout = stdout |
|
|
|
|
|
get_response(q["question"]) |
|
|
|
|
|
for include in q["expecteds"]["includes"]: |
|
|
assert include in stdout.getvalue(), f"Expected {include} in output" |
|
|
for exclude in q["expecteds"]["excludes"]: |
|
|
assert exclude not in stdout.getvalue(), f"Expected {exclude} not in output" |
|
|
for function in q["expecteds"]["functions"]: |
|
|
assert f"Invoking function call {function}" in stdout.getvalue(), f"{function} was not invoked" |
|
|
|
|
|
|
|
|
sys.stdout = sys.__stdout__ |
|
|
|