From c3daa9228084a6508f6e3315095eacdf8a5612e3 Mon Sep 17 00:00:00 2001 From: Ad5001 Date: Thu, 19 Sep 2024 02:34:49 +0200 Subject: [PATCH] Testing for modules existance in globals. --- LogarithmPlotter/util/js.py | 5 ++--- tests/python/test_main.py | 13 ++++++++++++- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/LogarithmPlotter/util/js.py b/LogarithmPlotter/util/js.py index ffdab5c..dbe60bc 100644 --- a/LogarithmPlotter/util/js.py +++ b/LogarithmPlotter/util/js.py @@ -16,14 +16,13 @@ * along with this program. If not, see . """ from re import Pattern -from PySide6.QtCore import QMetaObject, QObject +from PySide6.QtCore import QMetaObject, QObject, QDateTime from PySide6.QtQml import QJSValue class InvalidAttributeValueException(Exception): pass class NotAPrimitiveException(Exception): pass class Function: pass -class Date: pass class URL: pass class PyJSValue: @@ -80,7 +79,7 @@ class PyJSValue: (lambda: self.qjs_value.isArray(), list), (lambda: self.qjs_value.isBool(), bool), (lambda: self.qjs_value.isCallable(), Function), - (lambda: self.qjs_value.isDate(), Date), + (lambda: self.qjs_value.isDate(), QDateTime), (lambda: self.qjs_value.isError(), Exception), (lambda: self.qjs_value.isNull(), None), (lambda: self.qjs_value.isNumber(), float), diff --git a/tests/python/test_main.py b/tests/python/test_main.py index d96bb4a..b15ee02 100644 --- a/tests/python/test_main.py +++ b/tests/python/test_main.py @@ -95,4 +95,15 @@ class TestMain: engine, js_globals = create_engine(helper, latex, 0) assert len(engine.rootObjects()) > 0 # QML File loaded. assert type(engine.rootContext().contextProperty("TestBuild")) is bool - assert engine.rootContext().contextProperty("StartTime") == 0 \ No newline at end of file + assert engine.rootContext().contextProperty("StartTime") == 0 + assert js_globals.Latex.type() is not None + assert js_globals.Helper.type() is not None + assert js_globals.Modules.type() is not None + # Check if modules have loaded + assert js_globals.Modules.History.type() is not None + assert js_globals.Modules.Latex.type() is not None + assert js_globals.Modules.ObjectsCommon.type() is not None + assert js_globals.Modules.Canvas.type() is not None + assert js_globals.Modules.IO.type() is not None + assert js_globals.Modules.Objects.type() is not None + assert js_globals.Modules.Preferences.type() is not None \ No newline at end of file