From d38f1d298bcd408904cc080b245b6bbaab0f0a80 Mon Sep 17 00:00:00 2001 From: Maarceeli Date: Sat, 8 Feb 2025 11:01:59 +0100 Subject: [PATCH] Add Prometheus interface test script and update .gitignore --- .gitignore | 4 ++-- src/test.py | 43 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 45 insertions(+), 2 deletions(-) create mode 100644 src/test.py diff --git a/.gitignore b/.gitignore index aa644ac..af754d5 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,3 @@ -src/impl/hebece/src/__pycache__ *.db -__pycache__ \ No newline at end of file +__pycache__ +*.temp \ No newline at end of file diff --git a/src/test.py b/src/test.py new file mode 100644 index 0000000..de96c0f --- /dev/null +++ b/src/test.py @@ -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.") \ No newline at end of file