generated from nyuoss/sylveon-python-template-repository
-
Notifications
You must be signed in to change notification settings - Fork 4
/
conftest.py
36 lines (29 loc) · 1.18 KB
/
conftest.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
29
30
31
32
33
34
35
36
import pytest
from gradescopeapi.classes.connection import GSConnection
from dotenv import load_dotenv
import os
load_dotenv()
GRADESCOPE_CI_STUDENT_EMAIL = os.getenv("GRADESCOPE_CI_STUDENT_EMAIL")
GRADESCOPE_CI_STUDENT_PASSWORD = os.getenv("GRADESCOPE_CI_STUDENT_PASSWORD")
GRADESCOPE_CI_INSTRUCTOR_EMAIL = os.getenv("GRADESCOPE_CI_INSTRUCTOR_EMAIL")
GRADESCOPE_CI_INSTRUCTOR_PASSWORD = os.getenv("GRADESCOPE_CI_INSTRUCTOR_PASSWORD")
@pytest.fixture
def create_session():
def _create_session(account_type: str = "student"):
"""Creates and returns a session for testing"""
connection = GSConnection()
match account_type.lower():
case "student":
connection.login(
GRADESCOPE_CI_STUDENT_EMAIL, GRADESCOPE_CI_STUDENT_PASSWORD
)
case "instructor":
connection.login(
GRADESCOPE_CI_INSTRUCTOR_EMAIL, GRADESCOPE_CI_INSTRUCTOR_PASSWORD
)
case _:
raise ValueError(
"Invalid account type: must be 'student' or 'instructor'"
)
return connection.session
return _create_session