1
0
Fork 0
forked from Fuji/Fuji

Add Prometheus interface test script and update .gitignore

This commit is contained in:
Maarceeli 2025-02-08 11:01:59 +01:00
parent 7d65086225
commit d38f1d298b
No known key found for this signature in database
GPG key ID: 9AAC4EB2A4F969EB
2 changed files with 45 additions and 2 deletions

4
.gitignore vendored
View file

@ -1,3 +1,3 @@
src/impl/hebece/src/__pycache__
*.db
__pycache__
__pycache__
*.temp

43
src/test.py Normal file
View file

@ -0,0 +1,43 @@
from sdk.src.interfaces.prometheus.context import (
PrometheusAuthContext,
PrometheusWebCredentials,
)
from sdk.src.interfaces.prometheus.interface import PrometheusInterface
import os
import pickle
# NOT SAFE, DO NOT USE IN PRODUCTION
if os.path.exists('data.temp'):
with open('data.temp', 'rb') as file:
auth_context = pickle.load(file)
interface = PrometheusInterface(
auth_context=auth_context,
student_context=None,
)
interface.login()
else:
interface = PrometheusInterface(
auth_context=PrometheusAuthContext(
prometheus_web_credentials=PrometheusWebCredentials(
username=input("Login: "), password=input("Hasło: ")
)
),
student_context=None,
)
interface.login()
auth_context = interface.get_auth_context()
with open('data.temp', 'wb') as file:
pickle.dump(auth_context, file)
students = interface.get_students()
# Select the first student and fetch grades
if students:
interface.select_student(students[0].context)
grades = interface.get_grades(2)
print(grades)
else:
print("No students found.")