# -*- coding: utf-8 -*-
# -----------------------------------------------------------------------------
# Copyright 2016 Continuum Analytics, Inc.
#
# May be copied and distributed freely only as part of an Anaconda or
# Miniconda installation.
# -----------------------------------------------------------------------------
"""
Tests for update dialog.
"""

# Third party imports
from qtpy.QtCore import Qt  # analysis:ignore
import pytest
import pytestqt.qtbot as qtbot  # analysis:ignore

# Local imports
from anaconda_navigator.widgets.dialogs.update import DialogUpdateApplication


@pytest.fixture
def updatedialog(qtbot):
    widget = DialogUpdateApplication("1.0")
    widget.show()
    qtbot.addWidget(widget)
    return qtbot, widget


class TestUpdateDialog:
    def test_yes(self, updatedialog):
        qtbot, widget = updatedialog
        with qtbot.waitSignal(widget.accepted, 1000, True):
            qtbot.mouseClick(widget.button_yes, Qt.LeftButton)

    def test_no(self, updatedialog):
        qtbot, widget = updatedialog
        with qtbot.waitSignal(widget.rejected, 1000, True):
            qtbot.mouseClick(widget.button_no, Qt.LeftButton)
