Ejemplo n.º 1
0
    def setUp(self):
        """
        Create the UI and setup necessary options

        :return: None
        """
        self.build_settings()
        self.setup_application()
        Registry.create()
        with patch('openlp.core.lib.projector.db.init_url') as mocked_init_url:
            mocked_init_url.return_value = 'sqlite://'
            self.projectordb = ProjectorDB()
            self.projector_form = ProjectorEditForm(
                projectordb=self.projectordb)
Ejemplo n.º 2
0
    def setUp(self):
        """
        Create the UI and setup necessary options

        :return: None
        """
        self.build_settings()
        self.setup_application()
        Registry.create()
        with patch("openlp.core.lib.projector.db.init_url") as mocked_init_url:
            mocked_init_url.return_value = "sqlite://"
            self.projectordb = ProjectorDB()
            self.projector_form = ProjectorEditForm(projectordb=self.projectordb)
Ejemplo n.º 3
0
    def setUp(self):
        """
        Create the UI and setup necessary options

        :return: None
        """
        self.build_settings()
        self.setup_application()
        Registry.create()
        with patch('openlp.core.lib.projector.db.init_url') as mocked_init_url:
            if os.path.exists(TEST_DB):
                os.unlink(TEST_DB)
            mocked_init_url.return_value = 'sqlite:///' + TEST_DB
            self.projectordb = ProjectorDB()
            self.projector_form = ProjectorEditForm(projectordb=self.projectordb)
Ejemplo n.º 4
0
class TestProjectorEditForm(TestCase, TestMixin):
    """
    Test the methods in the ProjectorEditForm class
    """
    def setUp(self):
        """
        Create the UI and setup necessary options

        :return: None
        """
        self.build_settings()
        self.setup_application()
        Registry.create()
        with patch('openlp.core.lib.projector.db.init_url') as mocked_init_url:
            if os.path.exists(TEST_DB):
                os.unlink(TEST_DB)
            mocked_init_url.return_value = 'sqlite:///' + TEST_DB
            self.projectordb = ProjectorDB()
            self.projector_form = ProjectorEditForm(projectordb=self.projectordb)

    def tearDown(self):
        """
        Close database session.
        Delete all C++ objects at end so we don't segfault.

        :return: None
        """
        self.projectordb.session.close()
        del self.projector_form
        self.destroy_settings()

    @patch('openlp.core.ui.projector.editform.QtWidgets.QDialog.exec')
    def test_edit_form_add_projector(self, mocked_exec):
        """
        Test projector edit form with no parameters creates a new entry.

        :return: None
        """
        # GIVEN: Mocked setup
        # WHEN: Calling edit form with no parameters
        self.projector_form.exec()
        item = self.projector_form.projector

        # THEN: Should be creating a new instance
        self.assertTrue(self.projector_form.new_projector,
                        'Projector edit form should be marked as a new entry')
        self.assertTrue((item.ip is None and item.name is None),
                        'Projector edit form should have a new Projector() instance to edit')

    @patch('openlp.core.ui.projector.editform.QtWidgets.QDialog.exec')
    def test_edit_form_edit_projector(self, mocked_exec):
        """
        Test projector edit form with existing projector entry

        :return:
        """
        # GIVEN: Mocked setup
        # WHEN: Calling edit form with existing projector instance
        self.projector_form.exec(projector=Projector(**TEST1_DATA))
        item = self.projector_form.projector

        # THEN: Should be editing an existing entry
        self.assertFalse(self.projector_form.new_projector,
                         'Projector edit form should be marked as existing entry')
        self.assertTrue((item.ip is TEST1_DATA['ip'] and item.name is TEST1_DATA['name']),
                        'Projector edit form should have TEST1_DATA() instance to edit')
Ejemplo n.º 5
0
class TestProjectorEditForm(TestCase, TestMixin):
    """
    Test the methods in the ProjectorEditForm class
    """
    def setUp(self):
        """
        Create the UI and setup necessary options

        :return: None
        """
        self.build_settings()
        self.setup_application()
        Registry.create()
        with patch('openlp.core.lib.projector.db.init_url') as mocked_init_url:
            mocked_init_url.return_value = 'sqlite://'
            self.projectordb = ProjectorDB()
            self.projector_form = ProjectorEditForm(
                projectordb=self.projectordb)

    def tearDown(self):
        """
        Close database session.
        Delete all C++ objects at end so we don't segfault.

        :return: None
        """
        self.projectordb.session.close()
        del (self.projector_form)
        self.destroy_settings()

    def edit_form_add_projector_test(self):
        """
        Test projector edit form with no parameters creates a new entry.

        :return: None
        """
        # GIVEN: Mocked setup
        with patch('openlp.core.ui.projector.editform.QDialog.exec_'):

            # WHEN: Calling edit form with no parameters
            self.projector_form.exec_()
            item = self.projector_form.projector

            # THEN: Should be creating a new instance
            self.assertTrue(
                self.projector_form.new_projector,
                'Projector edit form should be marked as a new entry')
            self.assertTrue((
                item.ip is None and item.name is None
            ), 'Projector edit form should have a new Projector() instance to edit'
                            )

    def edit_form_edit_projector_test(self):
        """
        Test projector edit form with existing projector entry

        :return:
        """
        # GIVEN: Mocked setup
        with patch('openlp.core.ui.projector.editform.QDialog.exec_'):

            # WHEN: Calling edit form with existing projector instance
            self.projector_form.exec_(projector=TEST1_DATA)
            item = self.projector_form.projector

            # THEN: Should be editing an existing entry
            self.assertFalse(
                self.projector_form.new_projector,
                'Projector edit form should be marked as existing entry')
            self.assertTrue(
                (item.ip is TEST1_DATA.ip and item.name is TEST1_DATA.name),
                'Projector edit form should have TEST1_DATA() instance to edit'
            )
Ejemplo n.º 6
0
class TestProjectorEditForm(TestCase, TestMixin):
    """
    Test the methods in the ProjectorEditForm class
    """

    def setUp(self):
        """
        Create the UI and setup necessary options

        :return: None
        """
        self.build_settings()
        self.setup_application()
        Registry.create()
        with patch("openlp.core.lib.projector.db.init_url") as mocked_init_url:
            mocked_init_url.return_value = "sqlite://"
            self.projectordb = ProjectorDB()
            self.projector_form = ProjectorEditForm(projectordb=self.projectordb)

    def tearDown(self):
        """
        Close database session.
        Delete all C++ objects at end so we don't segfault.

        :return: None
        """
        self.projectordb.session.close()
        del (self.projector_form)
        self.destroy_settings()

    def edit_form_add_projector_test(self):
        """
        Test projector edit form with no parameters creates a new entry.

        :return: None
        """
        # GIVEN: Mocked setup
        with patch("openlp.core.ui.projector.editform.QDialog.exec_"):

            # WHEN: Calling edit form with no parameters
            self.projector_form.exec_()
            item = self.projector_form.projector

            # THEN: Should be creating a new instance
            self.assertTrue(self.projector_form.new_projector, "Projector edit form should be marked as a new entry")
            self.assertTrue(
                (item.ip is None and item.name is None),
                "Projector edit form should have a new Projector() instance to edit",
            )

    def edit_form_edit_projector_test(self):
        """
        Test projector edit form with existing projector entry

        :return:
        """
        # GIVEN: Mocked setup
        with patch("openlp.core.ui.projector.editform.QDialog.exec_"):

            # WHEN: Calling edit form with existing projector instance
            self.projector_form.exec_(projector=TEST1_DATA)
            item = self.projector_form.projector

            # THEN: Should be editing an existing entry
            self.assertFalse(
                self.projector_form.new_projector, "Projector edit form should be marked as existing entry"
            )
            self.assertTrue(
                (item.ip is TEST1_DATA.ip and item.name is TEST1_DATA.name),
                "Projector edit form should have TEST1_DATA() instance to edit",
            )