Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(ontology): added tests for the ontology editor #23

Merged
merged 82 commits into from
Sep 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
82 commits
Select commit Hold shift + click to select a range
e4382a1
Added a test function to test the launch of GUI window and other mino…
jmurugan-fzj Aug 11, 2023
b3b7074
-Code Cleanup
jmurugan-fzj Aug 11, 2023
759f1f5
-Code Cleanup
jmurugan-fzj Aug 11, 2023
8aa0b8d
-Corrected the package references
jmurugan-fzj Aug 11, 2023
5d50494
- Added coverage and a sample report to the project
jmurugan-fzj Aug 11, 2023
81b1b0d
- Code Cleanup
jmurugan-fzj Aug 11, 2023
8f36c00
- Code Cleanup
jmurugan-fzj Aug 14, 2023
2ab5b4a
- Code Reformatting
jmurugan-fzj Aug 14, 2023
bff7d7e
- Corrected the pytest path (Only included app-tests and excluded the…
jmurugan-fzj Aug 14, 2023
439c57e
- Added copyright information
jmurugan-fzj Aug 14, 2023
2028892
- Added basic window for the Ontology editor
jmurugan-fzj Aug 14, 2023
0555bbc
- Added logic to load the data from database
jmurugan-fzj Aug 15, 2023
42842ae
- Added data model to populate the table view in the ontology editor
jmurugan-fzj Aug 17, 2023
8130ca6
- Corrected the issues with the properties table data load and displa…
jmurugan-fzj Aug 17, 2023
5342c81
- Added the buttons for the deleting, reordering the properties table
jmurugan-fzj Aug 18, 2023
3454a28
- Added logic to insert a new property row to the table view
jmurugan-fzj Aug 18, 2023
c554ef6
- Added a separate table for the attachments
jmurugan-fzj Aug 21, 2023
6ff7627
- Removed the unwanted scrollArea and added a few modifications in th…
jmurugan-fzj Aug 21, 2023
570418f
- Added logic to enter new type (structural and normal ones), delete …
jmurugan-fzj Aug 22, 2023
bef2376
- Added message for save callback
jmurugan-fzj Aug 22, 2023
b85405c
- Quick code refactorings
jmurugan-fzj Aug 22, 2023
1e95e2f
- Added link line edit for the type level also with logic to modify t…
jmurugan-fzj Aug 23, 2023
ca77bd7
- Added ontology_attachments_tableview_data_model.py to display the a…
jmurugan-fzj Aug 23, 2023
b08a7a8
- Refactored the modules and added necessary comments and documentation
jmurugan-fzj Aug 23, 2023
98df1cf
- Modified the OntologyConfigurationForm to take ontology document di…
jmurugan-fzj Aug 24, 2023
b6dc2cb
- Modified the OntologyConfigurationForm to take ontology document di…
jmurugan-fzj Aug 24, 2023
e46de1e
- Corrected the test_form_launch for the modified UI elements
jmurugan-fzj Aug 24, 2023
f313a0b
- Restructured the tests folder and files
jmurugan-fzj Aug 24, 2023
da91574
- Corrected the column name for the attachment table
jmurugan-fzj Aug 24, 2023
8d1931b
- Corrected the default ontology in the fixedStringsJson.py
jmurugan-fzj Aug 24, 2023
72f4fc8
- Added mock document method to be used for the component testing
jmurugan-fzj Aug 24, 2023
b5e8d3a
- Reformatted the tests and fixtures
jmurugan-fzj Aug 25, 2023
db215e1
- Added tests for utility functions
jmurugan-fzj Aug 29, 2023
34c7157
- Minor refactoring
jmurugan-fzj Aug 29, 2023
cfeb66d
- Added basic tests for the table models
jmurugan-fzj Aug 29, 2023
e063953
- Added unit tests for delegates
jmurugan-fzj Aug 29, 2023
0af20fe
- Added unit tests for delegates
jmurugan-fzj Aug 29, 2023
5e343c7
- Updated the coverage
jmurugan-fzj Aug 29, 2023
f474d70
- Updated the delegate tests
jmurugan-fzj Aug 30, 2023
a257af7
- Added more tests for data model and improved the coverage
jmurugan-fzj Aug 30, 2023
a1d185b
- Finalized tests for data model
jmurugan-fzj Aug 31, 2023
3087a75
- Added tests for create_type_dialog_extended.py and document_null_ex…
jmurugan-fzj Aug 31, 2023
947f205
- Updated coverage
jmurugan-fzj Aug 31, 2023
56ef3c5
- Added tests for create_type_dialog_extended.py and updated coverage
jmurugan-fzj Aug 31, 2023
29a63d5
- Added tests for create_type_dialog_extended.py and updated coverage
jmurugan-fzj Sep 1, 2023
b712652
- Added tests for create_type_dialog_extended.py and updated coverage
jmurugan-fzj Sep 1, 2023
8bd3e32
- Added tests for create_type_dialog_extended.py and updated coverage
jmurugan-fzj Sep 4, 2023
c9af207
Merge remote-tracking branch 'origin/main' into feature/ontology_edit…
jmurugan-fzj Sep 4, 2023
2a0934c
- Merged the changes from main branch and modified the tests for the …
jmurugan-fzj Sep 4, 2023
358b01d
- Corrected some warnings
jmurugan-fzj Sep 4, 2023
7d54c7b
- Added component test to load the data when load button clicked
jmurugan-fzj Sep 4, 2023
1e7fd3a
- Reverting the changes done for the ontology data format changed in …
jmurugan-fzj Sep 5, 2023
1ae2958
- Added a few more UI tests for the ontology configuration element
jmurugan-fzj Sep 5, 2023
a0976d3
- Added a null check for the model row update
jmurugan-fzj Sep 5, 2023
1c24c46
- Minor corrections with the new label creation and few other adaptat…
jmurugan-fzj Sep 6, 2023
c742ce2
- Minor null check correction
jmurugan-fzj Sep 6, 2023
99077cf
- Corrected PyLint and MyPy errors
jmurugan-fzj Sep 7, 2023
8f424c3
- Corrected PyLint and MyPy errors
jmurugan-fzj Sep 7, 2023
3b326a5
- Corrected PyLint, added new lines to the end of files
jmurugan-fzj Sep 7, 2023
bd852af
- Corrected MyPy error
jmurugan-fzj Sep 7, 2023
2ec6195
- Reverted fixedStringsJson.py to the old version
jmurugan-fzj Sep 7, 2023
19992fb
- Enabled test_99_3Projects.py also for improved coverage
jmurugan-fzj Sep 8, 2023
320cd0e
- Enabled re-enabled failing tests test_01_demoIndentation.py & test_…
jmurugan-fzj Sep 8, 2023
b376e45
- Committed the missing test data document
jmurugan-fzj Sep 8, 2023
d47f534
-Removed test user credentials from the ontology_configuration_extend…
jmurugan-fzj Sep 8, 2023
9c78ec5
- Moved ontology-configuration into GUI and all the imports are now r…
SteffenBrinckmann Sep 8, 2023
4920b93
-Modified the tests and corrected linting errors as per the changes f…
jmurugan-fzj Sep 8, 2023
61313e0
- Modifications done as per the pyLint and myPy errors
jmurugan-fzj Sep 8, 2023
fc55353
- Modifications done for the tests as per the pyLint and myPy errors
jmurugan-fzj Sep 8, 2023
af80ab2
- Code cleanup
jmurugan-fzj Sep 8, 2023
fecc83f
- Added type-ignored for pyside ItemDataRole and int compatibility my…
jmurugan-fzj Sep 11, 2023
d8e088d
- Added type-ignore for pyside types, return type compatibility error…
jmurugan-fzj Sep 11, 2023
1cb6537
Merge remote-tracking branch 'origin/main' into feature/ontology_edit…
jmurugan-fzj Sep 11, 2023
e3f4638
- Formatted the test file test_ontology_configuration_extended.py
jmurugan-fzj Sep 11, 2023
e7cef29
Merge remote-tracking branch 'origin/main' into feature/ontology_edit…
jmurugan-fzj Sep 11, 2023
eea42f7
- Added follow-import:skip for the ontology configuration folder, sin…
jmurugan-fzj Sep 11, 2023
375717b
Merge remote-tracking branch 'origin/main' into feature/ontology_edit…
jmurugan-fzj Sep 11, 2023
8a4d592
- Deleted the coverage output files
jmurugan-fzj Sep 11, 2023
6bbbdfe
- Flattened the files inside ontology_configuration folder
jmurugan-fzj Sep 11, 2023
5e82cf9
- Corrected the path of the excluded files in setup.cfg
jmurugan-fzj Sep 11, 2023
78294a4
- Corrected the path of the excluded files in setup.cfg
jmurugan-fzj Sep 11, 2023
9ffe2c9
- Updated version number in test data
jmurugan-fzj Sep 11, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
# A comma-separated list of package or module names from where C extensions may
# be loaded. Extensions are loading into the active Python interpreter and may
# run arbitrary code
extension-pkg-whitelist=
extension-pkg-whitelist=PySide6

# Add files or directories to the blacklist. They should be base names, not
# paths.
ignore=CVS

# Add files or directories matching the regex patterns to the blacklist. The
# regex matches against base names, not paths.
ignore-patterns=
ignore-patterns=ontology_configuration.py,create_type_dialog.py

# Python code to execute, usually for sys.path manipulation such as
# pygtk.require().
Expand Down
8 changes: 8 additions & 0 deletions pasta_eln/GUI/ontology_configuration/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# PASTA-ELN and all its sub-parts are covered by the MIT license.
#
# Copyright (c) 2023
#
# Author: Jithu Murugan
# Filename: __init__.py
#
# You should have received a copy of the license with this file. Please refer the license file for more information.
80 changes: 80 additions & 0 deletions pasta_eln/GUI/ontology_configuration/create_type_dialog.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
# Form implementation generated from reading ui file 'create_type_dialog.ui'
#
# Created by: PyQt6 UI code generator 6.4.2
#
# WARNING: Any manual changes made to this file will be lost when pyuic6 is
# run again. Do not edit this file unless you know what you are doing.


from PySide6 import QtCore, QtGui, QtWidgets


class Ui_CreateTypeDialog(object):
def setupUi(self, CreateTypeDialog):
CreateTypeDialog.setObjectName("CreateTypeDialog")
CreateTypeDialog.resize(459, 301)
self.buttonBox = QtWidgets.QDialogButtonBox(parent=CreateTypeDialog)
self.buttonBox.setGeometry(QtCore.QRect(30, 240, 341, 32))
self.buttonBox.setOrientation(QtCore.Qt.Orientation.Horizontal)
self.buttonBox.setStandardButtons(QtWidgets.QDialogButtonBox.StandardButton.Cancel|QtWidgets.QDialogButtonBox.StandardButton.Ok)
self.buttonBox.setObjectName("buttonBox")
self.verticalLayoutWidget = QtWidgets.QWidget(parent=CreateTypeDialog)
self.verticalLayoutWidget.setGeometry(QtCore.QRect(-1, -1, 461, 221))
self.verticalLayoutWidget.setObjectName("verticalLayoutWidget")
self.mainVerticalLayout = QtWidgets.QVBoxLayout(self.verticalLayoutWidget)
self.mainVerticalLayout.setContentsMargins(20, 0, 20, 0)
self.mainVerticalLayout.setObjectName("mainVerticalLayout")
self.tileHorizontalLayout = QtWidgets.QHBoxLayout()
self.tileHorizontalLayout.setObjectName("tileHorizontalLayout")
self.titleLabel = QtWidgets.QLabel(parent=self.verticalLayoutWidget)
self.titleLabel.setObjectName("titleLabel")
self.tileHorizontalLayout.addWidget(self.titleLabel)
spacerItem = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Policy.Minimum, QtWidgets.QSizePolicy.Policy.Minimum)
self.tileHorizontalLayout.addItem(spacerItem)
self.titleLineEdit = QtWidgets.QLineEdit(parent=self.verticalLayoutWidget)
self.titleLineEdit.setToolTip("")
self.titleLineEdit.setObjectName("titleLineEdit")
self.tileHorizontalLayout.addWidget(self.titleLineEdit)
self.mainVerticalLayout.addLayout(self.tileHorizontalLayout)
self.horizontalLayout = QtWidgets.QHBoxLayout()
self.horizontalLayout.setObjectName("horizontalLayout")
self.typeLabel = QtWidgets.QLabel(parent=self.verticalLayoutWidget)
self.typeLabel.setObjectName("typeLabel")
self.horizontalLayout.addWidget(self.typeLabel)
spacerItem1 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Policy.Minimum, QtWidgets.QSizePolicy.Policy.Minimum)
self.horizontalLayout.addItem(spacerItem1)
self.labelLineEdit = QtWidgets.QLineEdit(parent=self.verticalLayoutWidget)
self.labelLineEdit.setObjectName("labelLineEdit")
self.horizontalLayout.addWidget(self.labelLineEdit)
self.mainVerticalLayout.addLayout(self.horizontalLayout)
self.horizontalLayout_2 = QtWidgets.QHBoxLayout()
self.horizontalLayout_2.setObjectName("horizontalLayout_2")
self.structuralLevelCheckBox = QtWidgets.QCheckBox(parent=self.verticalLayoutWidget)
self.structuralLevelCheckBox.setObjectName("structuralLevelCheckBox")
self.horizontalLayout_2.addWidget(self.structuralLevelCheckBox)
self.mainVerticalLayout.addLayout(self.horizontalLayout_2)

self.retranslateUi(CreateTypeDialog)
self.buttonBox.accepted.connect(CreateTypeDialog.accept) # type: ignore
self.buttonBox.rejected.connect(CreateTypeDialog.reject) # type: ignore
QtCore.QMetaObject.connectSlotsByName(CreateTypeDialog)

def retranslateUi(self, CreateTypeDialog):
_translate = QtCore.QCoreApplication.translate
CreateTypeDialog.setWindowTitle(_translate("CreateTypeDialog", "Create New Type"))
self.titleLabel.setText(_translate("CreateTypeDialog", "Enter Type title"))
self.titleLineEdit.setPlaceholderText(_translate("CreateTypeDialog", "Enter the title for the new type"))
self.typeLabel.setText(_translate("CreateTypeDialog", "Enter Type Label"))
self.labelLineEdit.setPlaceholderText(_translate("CreateTypeDialog", "Enter the label for the new type"))
self.structuralLevelCheckBox.setToolTip(_translate("CreateTypeDialog", "If this is a structural type, then title will be automatically populated as (x0, x1...xn). Next number will be chosen for xn from the existing list of structural items."))
self.structuralLevelCheckBox.setText(_translate("CreateTypeDialog", "Is this a structural Type?"))


if __name__ == "__main__":
import sys
app = QtWidgets.QApplication(sys.argv)
CreateTypeDialog = QtWidgets.QDialog()
ui = Ui_CreateTypeDialog()
ui.setupUi(CreateTypeDialog)
CreateTypeDialog.show()
sys.exit(app.exec())
171 changes: 171 additions & 0 deletions pasta_eln/GUI/ontology_configuration/create_type_dialog.ui
Original file line number Diff line number Diff line change
@@ -0,0 +1,171 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>CreateTypeDialog</class>
<widget class="QDialog" name="CreateTypeDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>459</width>
<height>301</height>
</rect>
</property>
<property name="windowTitle">
<string>Create New Type</string>
</property>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="geometry">
<rect>
<x>30</x>
<y>240</y>
<width>341</width>
<height>32</height>
</rect>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
<widget class="QWidget" name="verticalLayoutWidget">
<property name="geometry">
<rect>
<x>-1</x>
<y>-1</y>
<width>461</width>
<height>221</height>
</rect>
</property>
<layout class="QVBoxLayout" name="mainVerticalLayout">
<property name="leftMargin">
<number>20</number>
</property>
<property name="rightMargin">
<number>20</number>
</property>
<item>
<layout class="QHBoxLayout" name="tileHorizontalLayout">
<item>
<widget class="QLabel" name="titleLabel">
<property name="text">
<string>Enter Type title</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Minimum</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QLineEdit" name="titleLineEdit">
<property name="toolTip">
<string/>
</property>
<property name="placeholderText">
<string>Enter the title for the new type</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLabel" name="typeLabel">
<property name="text">
<string>Enter Type Label</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Minimum</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QLineEdit" name="labelLineEdit">
<property name="placeholderText">
<string>Enter the label for the new type</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QCheckBox" name="structuralLevelCheckBox">
<property name="toolTip">
<string>If this is a structural type, then title will be automatically populated as (x0, x1...xn). Next number will be chosen for xn from the existing list of structural items.</string>
</property>
<property name="text">
<string>Is this a structural Type?</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</widget>
<resources/>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>CreateTypeDialog</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>248</x>
<y>254</y>
</hint>
<hint type="destinationlabel">
<x>157</x>
<y>274</y>
</hint>
</hints>
</connection>
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
<receiver>CreateTypeDialog</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>316</x>
<y>260</y>
</hint>
<hint type="destinationlabel">
<x>286</x>
<y>274</y>
</hint>
</hints>
</connection>
</connections>
</ui>
116 changes: 116 additions & 0 deletions pasta_eln/GUI/ontology_configuration/create_type_dialog_extended.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
""" CreateTypeDialog used for the create type dialog """
# PASTA-ELN and all its sub-parts are covered by the MIT license.
#
# Copyright (c) 2023.
#
# Author: Jithu Murugan
# Filename: create_type_dialog_extended.py
#
# You should have received a copy of the license with this file. Please refer the license file for more information.

# PASTA-ELN and all its sub-parts are covered by the MIT license.
#
#
# Author: Jithu Murugan
# Filename: create_type_dialog_extended.py
#
# You should have received a copy of the license with this file. Please refer the license file for more information.
import logging
from collections.abc import Callable
from typing import Any

from PySide6 import QtCore
from PySide6.QtWidgets import QDialog

from pasta_eln.GUI.ontology_configuration.create_type_dialog import Ui_CreateTypeDialog


class CreateTypeDialog(Ui_CreateTypeDialog):
"""
Abstracted dialog for the create type
"""

def __new__(cls, *_: Any, **__: Any) -> Any:
"""
Instantiates the create type dialog
"""
return super(CreateTypeDialog, cls).__new__(cls)

def __init__(self,
accepted_callback: Callable[[], None],
rejected_callback: Callable[[], None]) -> None:
"""
Initializes the create type dialog
Args:
accepted_callback (Callable): Accepted button parent callback.
rejected_callback (Callable): Rejected button parent callback.
"""
self.logger = logging.getLogger(__name__ + "." + self.__class__.__name__)
self.next_struct_level: str | None = ""
self.instance = QDialog()
super().setupUi(self.instance)
self.setup_slots(accepted_callback, rejected_callback)

def setup_slots(self,
accepted_callback: Callable[[], None],
rejected_callback: Callable[[], None]) -> None:
"""
Sets up the slots for the dialog
Args:
accepted_callback (Callable): Accepted button parent callback.
rejected_callback (Callable): Rejected button parent callback.

Returns: None

"""
self.buttonBox.accepted.connect(accepted_callback)
self.buttonBox.rejected.connect(rejected_callback)
self.structuralLevelCheckBox.stateChanged.connect(self.structural_level_checkbox_callback)

def structural_level_checkbox_callback(self) -> None:
"""
Callback invoked when the state changes for structuralLevelCheckBox

Returns: Nothing
"""
if self.structuralLevelCheckBox.isChecked():
self.titleLineEdit.setText(self.next_struct_level if self.next_struct_level else "")
self.titleLineEdit.setDisabled(True)
else:
self.titleLineEdit.clear()
self.titleLineEdit.setDisabled(False)

def show(self) -> None:
"""
Displays the dialog

Returns: None

"""
self.instance.setWindowModality(QtCore.Qt.ApplicationModal)
self.instance.show()

def clear_ui(self) -> None:
"""
Clear the Dialog UI

Returns: Nothing

"""
self.labelLineEdit.clear()
self.titleLineEdit.clear()
self.structuralLevelCheckBox.setChecked(False)

def set_structural_level_title(self,
structural_level: str | None) -> None:
"""
Set the next possible structural type level title

Args:
structural_level (str): Passed in structural level of the format (x0, x1, x2 ...)

Returns: Nothing

"""
self.logger.info("Next structural level set: {%s}...", structural_level)
self.next_struct_level = structural_level
Loading