Spaces:
Sleeping
Sleeping
IliaLarchenko
commited on
Commit
•
a49fb5a
1
Parent(s):
9f4cedf
Modes e2e tests
Browse files- tests/test_e2e.py +14 -6
tests/test_e2e.py
CHANGED
@@ -1,32 +1,40 @@
|
|
1 |
from tests.candidate import complete_interview
|
2 |
from tests.grader import grade
|
3 |
from concurrent.futures import ThreadPoolExecutor
|
4 |
-
|
5 |
from typing import List
|
6 |
|
7 |
|
8 |
-
def complete_and_grade_interview(interview_type: str) -> float:
|
9 |
"""
|
10 |
Complete an interview and return the overall score.
|
11 |
|
12 |
:param interview_type: Type of the interview.
|
|
|
13 |
:return: Overall score of the interview.
|
14 |
"""
|
15 |
-
file_path, _ = complete_interview(interview_type, "test", model="gpt-3.5-turbo")
|
16 |
-
feedback = grade(file_path, model="gpt-
|
17 |
-
assert feedback["overall_score"] >
|
18 |
return feedback["overall_score"]
|
19 |
|
20 |
|
21 |
def test_complete_interview() -> None:
|
22 |
"""
|
23 |
-
Test the complete interview process for various interview types.
|
24 |
"""
|
25 |
interview_types = ["ml_design", "math", "ml_theory", "system_design", "sql", "coding"]
|
26 |
scores: List[float] = []
|
27 |
|
28 |
with ThreadPoolExecutor(max_workers=3) as executor:
|
|
|
29 |
futures = [executor.submit(complete_and_grade_interview, it) for it in interview_types]
|
|
|
|
|
|
|
|
|
|
|
|
|
30 |
for future in futures:
|
31 |
score = future.result()
|
32 |
scores.append(score)
|
|
|
1 |
from tests.candidate import complete_interview
|
2 |
from tests.grader import grade
|
3 |
from concurrent.futures import ThreadPoolExecutor
|
4 |
+
import random
|
5 |
from typing import List
|
6 |
|
7 |
|
8 |
+
def complete_and_grade_interview(interview_type: str, mode: str = "normal", min_score=0.4) -> float:
|
9 |
"""
|
10 |
Complete an interview and return the overall score.
|
11 |
|
12 |
:param interview_type: Type of the interview.
|
13 |
+
:param mode: Mode of the interview ("normal", "empty", "gibberish", "repeat").
|
14 |
:return: Overall score of the interview.
|
15 |
"""
|
16 |
+
file_path, _ = complete_interview(interview_type, "test", model="gpt-3.5-turbo", mode=mode)
|
17 |
+
feedback = grade(file_path, model="gpt-4-turbo")
|
18 |
+
assert feedback["overall_score"] > min_score
|
19 |
return feedback["overall_score"]
|
20 |
|
21 |
|
22 |
def test_complete_interview() -> None:
|
23 |
"""
|
24 |
+
Test the complete interview process for various interview types, including edge cases.
|
25 |
"""
|
26 |
interview_types = ["ml_design", "math", "ml_theory", "system_design", "sql", "coding"]
|
27 |
scores: List[float] = []
|
28 |
|
29 |
with ThreadPoolExecutor(max_workers=3) as executor:
|
30 |
+
# Test normal interviews
|
31 |
futures = [executor.submit(complete_and_grade_interview, it) for it in interview_types]
|
32 |
+
|
33 |
+
# Test edge cases: empty, gibberish, repeat for one random interview type each
|
34 |
+
futures.append(executor.submit(complete_and_grade_interview, random.choice(interview_types), mode="empty", min_score=0.0))
|
35 |
+
futures.append(executor.submit(complete_and_grade_interview, random.choice(interview_types), mode="gibberish", min_score=0.0))
|
36 |
+
futures.append(executor.submit(complete_and_grade_interview, random.choice(interview_types), mode="repeat", min_score=0.0))
|
37 |
+
|
38 |
for future in futures:
|
39 |
score = future.result()
|
40 |
scores.append(score)
|