Spaces:
Sleeping
Sleeping
WilliamGazeley
commited on
Commit
·
1d120a6
1
Parent(s):
691fc98
Add simple QA test
Browse files- pytest.ini +1 -0
- tests/qa_questions.json +92 -0
- tests/requirements.txt +0 -0
- tests/test_quality.py +23 -0
pytest.ini
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
pythonpath=.,src
|
tests/qa_questions.json
ADDED
@@ -0,0 +1,92 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
[
|
2 |
+
{
|
3 |
+
"question": "What do you think about MSTR?",
|
4 |
+
"expecteds":
|
5 |
+
{
|
6 |
+
"includes": ["microstrategy", "bitcoin"],
|
7 |
+
"excludes": ["mastercard"],
|
8 |
+
"functions_used": ["get_analysis"]
|
9 |
+
}
|
10 |
+
},
|
11 |
+
{
|
12 |
+
"question": "How do market cycles affect cryptocurrencies and traditional investments?",
|
13 |
+
"expecteds":
|
14 |
+
{
|
15 |
+
"includes": [],
|
16 |
+
"excludes": [],
|
17 |
+
"functions_used": []
|
18 |
+
}
|
19 |
+
},
|
20 |
+
{
|
21 |
+
"question": "What is the block size debate in Bitcoin?",
|
22 |
+
"expecteds":
|
23 |
+
{
|
24 |
+
"includes": ["fork", "transactions"],
|
25 |
+
"excludes": [],
|
26 |
+
"functions_used": []
|
27 |
+
}
|
28 |
+
},
|
29 |
+
{
|
30 |
+
"question": "How has Bitcoin's protocol changed over time?",
|
31 |
+
"expecteds":
|
32 |
+
{
|
33 |
+
"includes": [],
|
34 |
+
"excludes": [],
|
35 |
+
"functions_used": []
|
36 |
+
}
|
37 |
+
},
|
38 |
+
{
|
39 |
+
"question": "Should I buy BTC or ETH?",
|
40 |
+
"expecteds":
|
41 |
+
{
|
42 |
+
"includes": [],
|
43 |
+
"excludes": [],
|
44 |
+
"functions_used": ["get_analysis"]
|
45 |
+
}
|
46 |
+
},
|
47 |
+
{
|
48 |
+
"question": "Is Bitcoin cheap?",
|
49 |
+
"expecteds":
|
50 |
+
{
|
51 |
+
"includes": ["BTC"],
|
52 |
+
"excludes": [],
|
53 |
+
"functions_used": ["get_current_stock_price"]
|
54 |
+
}
|
55 |
+
},
|
56 |
+
{
|
57 |
+
"question": "Why is Bitcoin down today?",
|
58 |
+
"expecteds":
|
59 |
+
{
|
60 |
+
"includes": ["BTC"],
|
61 |
+
"excludes": [],
|
62 |
+
"functions_used": ["get_current_stock_price", "get_analysis"]
|
63 |
+
}
|
64 |
+
},
|
65 |
+
{
|
66 |
+
"question": "Why is Bitcoin up today??",
|
67 |
+
"expecteds":
|
68 |
+
{
|
69 |
+
"includes": ["BTC"],
|
70 |
+
"excludes": [],
|
71 |
+
"functions_used": ["get_current_stock_price", "get_analysis"]
|
72 |
+
}
|
73 |
+
},
|
74 |
+
{
|
75 |
+
"question": "What is the latest news on Bitcoin?",
|
76 |
+
"expecteds":
|
77 |
+
{
|
78 |
+
"includes": ["BTC"],
|
79 |
+
"excludes": [],
|
80 |
+
"functions_used": ["get_analysis"]
|
81 |
+
}
|
82 |
+
},
|
83 |
+
{
|
84 |
+
"question": "What happened during the halvening?",
|
85 |
+
"expecteds":
|
86 |
+
{
|
87 |
+
"includes": ["mining", "BTC"],
|
88 |
+
"excludes": [],
|
89 |
+
"functions_used": ["get_analysis"]
|
90 |
+
}
|
91 |
+
}
|
92 |
+
]
|
tests/requirements.txt
ADDED
File without changes
|
tests/test_quality.py
ADDED
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import sys
|
2 |
+
import json
|
3 |
+
from io import StringIO
|
4 |
+
|
5 |
+
def test_quality():
|
6 |
+
"""Tests if the expected functions and values are used"""
|
7 |
+
with open("qa_questions.json") as f:
|
8 |
+
qs = json.load(f)
|
9 |
+
|
10 |
+
for q in qs:
|
11 |
+
# Capture stdout
|
12 |
+
stdout = StringIO()
|
13 |
+
sys.stdout = stdout
|
14 |
+
|
15 |
+
for include in q['includes']:
|
16 |
+
assert include in stdout.getvalue(), f"Expected {include} in output"
|
17 |
+
for exclude in q['excludes']:
|
18 |
+
assert exclude not in stdout.getvalue(), f"Expected {exclude} not in output"
|
19 |
+
for function in q['functions']:
|
20 |
+
assert f"Invoking function call {function}" in stdout.getvalue(), f"{function} was not invoked"
|
21 |
+
|
22 |
+
# Restore stdout
|
23 |
+
sys.stdout = sys.__stdout__
|