ProjectDjango/DjangoTestDataDialog.py

Fri, 27 Dec 2024 14:17:37 +0100

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Fri, 27 Dec 2024 14:17:37 +0100
branch
eric7
changeset 202
b06794ae2a92
parent 197
2667e16a3379
permissions
-rw-r--r--

Added the capability to select from various template types when creating a new view template.

# -*- coding: utf-8 -*-

# Copyright (c) 2017 - 2025 Detlev Offenbach <detlev@die-offenbachs.de>
#

"""
Module implementing a dialog to enter some data for running tests.
"""

from PyQt6.QtWidgets import QDialog

from .Ui_DjangoTestDataDialog import Ui_DjangoTestDataDialog


class DjangoTestDataDialog(QDialog, Ui_DjangoTestDataDialog):
    """
    Class implementing a dialog to enter some data for running tests.
    """

    def __init__(self, project, keepDatabases, parent=None):
        """
        Constructor

        @param project reference to the Django project object
        @type Project
        @param keepDatabases flag indicating to set the keep databases
            check box
        @type bool
        @param parent reference to the parent widget
        @type QWidget
        """
        super().__init__(parent)
        self.setupUi(self)

        self.__project = project

        self.labelsComboBox.addItems(
            self.__project.getRecentTestData("RecentTestLabels")
        )
        self.tagsComboBox.addItems(self.__project.getRecentTestData("RecentTestTags"))
        self.excludeTagsComboBox.addItems(
            self.__project.getRecentTestData("RecentTestExcludeTags")
        )

        self.keepCheckBox.setChecked(keepDatabases)

        msh = self.minimumSizeHint()
        self.resize(max(self.width(), msh.width()), msh.height())

    def getData(self):
        """
        Public method to get the entered data.

        @return tuple containing a list of test labels, a test file pattern,
            a list of test tags, a list of test tags to be skipped, a flag
            indicating to keep the test database and a flag indicating to run
            the tests in reverse order
        @rtype tuple of
            (list of str, str, list of str, list of str, bool, bool)
        """
        labelsStr = self.labelsComboBox.currentText()
        self.__project.setMostRecentTestData("RecentTestLabels", labelsStr)
        labels = labelsStr.split() if labelsStr else []

        tagsStr = self.tagsComboBox.currentText()
        self.__project.setMostRecentTestData("RecentTestTags", tagsStr)
        tags = tagsStr.split() if tagsStr else []

        excludeTagsStr = self.excludeTagsComboBox.currentText()
        self.__project.setMostRecentTestData("RecentTestExcludeTags", excludeTagsStr)
        excludeTags = excludeTagsStr.split() if excludeTagsStr else []

        return (
            labels,
            self.testFilePatternsEdit.text(),
            tags,
            excludeTags,
            self.keepCheckBox.isChecked(),
            self.reverseCheckBox.isChecked(),
        )

eric ide

mercurial