示例#1
0
    def test_initial_state(self, main_window):
        assert_that(main_window.windowTitle(), is_("pyOffer"))
        assert_that(main_window.offer, is_(none()))
        assert_that(main_window.user, is_(not_none()))

        assert_that(main_window.ui.menu_offer, is_(enabled()))
        assert_that(main_window.ui.action_new, is_(enabled()))
        assert_that(main_window.ui.action_exit, is_(enabled()))
        assert_that(main_window.ui.menu_database, is_(enabled()))
        assert_that(main_window.ui.menu_help, is_(enabled()))

        self._check_offer_ui(main_window, disabled())
示例#2
0
    def test_inquiry_number_enabled(self, active_window):
        assert_that(active_window.ui.line_edit_query_number, is_(disabled()))
        assert_that(active_window.ui.line_edit_query_number.text(),
                    is_(empty()))

        active_window.inquiry_number_toggled(Qt.Checked)  # enable
        assert_that(active_window.ui.line_edit_query_number, is_(enabled()))
示例#3
0
    def test_inquiry_date_enabled(self, mocker, active_window):
        mock_date = mocker.patch("src.main_window.date", autospec=True)
        expected_date = date(2020, 12, 30)
        mock_date.today.return_value = expected_date

        assert_that(active_window.ui.line_edit_query_date, is_(disabled()))
        assert_that(active_window.ui.line_edit_query_date.text(), is_(empty()))

        active_window.inquiry_date_toggled(Qt.Checked)  # enable
        assert_that(active_window.ui.line_edit_query_date, is_(enabled()))
        assert_that(active_window.ui.line_edit_query_date.text(),
                    is_("30.12.2020"))
示例#4
0
    def test_inquiry_date_toggled(self, active_window):
        expected_date = f"{date.today():%d.%m.%Y}"

        assert_that(active_window.offer.inquiry_date, is_(none()))
        assert_that(active_window.ui.line_edit_query_date, is_(disabled()))
        assert_that(active_window.ui.line_edit_query_date.text(), is_(empty()))

        active_window.inquiry_date_toggled(Qt.Checked)  # enable
        assert_that(active_window.ui.line_edit_query_date, is_(enabled()))
        assert_that(active_window.ui.line_edit_query_date.text(),
                    is_(expected_date))
        assert_that(active_window.offer.inquiry_date, is_(expected_date))

        active_window.inquiry_date_toggled(Qt.Unchecked)  # disable
        assert_that(active_window.ui.line_edit_query_date, is_(disabled()))
        assert_that(active_window.ui.line_edit_query_date.text(), is_(""))
        assert_that(active_window.offer.inquiry_date, is_(empty()))
示例#5
0
    def test_inquiry_number_toggled(self, qtbot, active_window):
        expected_query_number = "Lorem ipsum"
        assert_that(active_window.offer.inquiry_number, is_(none()))
        assert_that(active_window.ui.line_edit_query_number, is_(disabled()))

        active_window.inquiry_number_toggled(Qt.Checked)  # enable
        assert_that(active_window.ui.line_edit_query_number, is_(enabled()))

        # fill with anything
        qtbot.keyClicks(active_window.ui.line_edit_query_number,
                        expected_query_number)
        assert_that(active_window.offer.inquiry_number,
                    is_(expected_query_number))

        active_window.inquiry_number_toggled(Qt.Unchecked)  # disable
        assert_that(active_window.ui.line_edit_query_number, is_(disabled()))
        assert_that(active_window.ui.line_edit_query_number.text(), is_(""))
        assert_that(active_window.offer.inquiry_number, is_(empty()))
示例#6
0
    def test_new_offer(self, mocker, main_window, expected_symbol,
                       mock_new_offer, expected_inquiry_text):
        set_model = mocker.patch.object(main_window.ui.tableView,
                                        "setModel",
                                        autospec=True)
        assert_that(main_window.offer, is_(none()))
        self._check_offer_ui(main_window, disabled())

        main_window.new_offer()
        mock_new_offer.create_empty.assert_called_once_with(
            main_window.user, main_window)
        set_model.assert_called_once_with(main_window.offer.merchandise_list)

        assert_that(main_window.windowTitle(),
                    is_(f"pyOffer - {expected_symbol}"))
        assert_that(main_window.ui.plain_text_edit_query.toPlainText(),
                    is_(expected_inquiry_text))
        assert_that(main_window.offer, is_(not_none()))
        assert_that(main_window.offer.author, is_(main_window.user))
        self._check_offer_ui(main_window, enabled())