Skip to content

Commit

Permalink
Merge pull request #87 from Josh-Voyles/radial-downpayment
Browse files Browse the repository at this point in the history
Resolved: #85 #81 #71, remove radial button, display downpayment head…
  • Loading branch information
YouKnowJoey authored Jun 13, 2024
2 parents 9b7a06c + 1807157 commit b0f5e8c
Show file tree
Hide file tree
Showing 4 changed files with 169 additions and 133 deletions.
64 changes: 36 additions & 28 deletions home-choice-pro/resources/main_window.ui
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ QPushButton:hover {
<string/>
</property>
<property name="pixmap">
<pixmap>:/images/Gemini_Generated_Image_njly4xnjly4xnjly.jpeg</pixmap>
<pixmap resource="resources.qrc">:/images/Gemini_Generated_Image_njly4xnjly4xnjly.jpeg</pixmap>
</property>
<property name="scaledContents">
<bool>true</bool>
Expand Down Expand Up @@ -327,9 +327,12 @@ QPushButton:hover {
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<width>100</width>
<height>20</height>
</size>
</property>
Expand Down Expand Up @@ -391,6 +394,28 @@ QPushButton:hover {
</item>
<item>
<layout class="QVBoxLayout" name="headerThirdColumnLayoutV">
<property name="sizeConstraint">
<enum>QLayout::SetNoConstraint</enum>
</property>
<property name="leftMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<item>
<widget class="QLabel" name="downPaymentHeaderLabel">
<property name="styleSheet">
<string notr="true">font: 0 italic 11pt &quot;Ubuntu Sans&quot;;</string>
</property>
<property name="text">
<string>-</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item>
<spacer name="headerThirdColumnSpacer">
<property name="orientation">
Expand Down Expand Up @@ -419,6 +444,9 @@ QPushButton:hover {
<property name="text">
<string>$0</string>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
</property>
</widget>
</item>
</layout>
Expand Down Expand Up @@ -492,7 +520,7 @@ QPushButton:hover {
<property name="geometry">
<rect>
<x>0</x>
<y>-151</y>
<y>0</y>
<width>625</width>
<height>600</height>
</rect>
Expand Down Expand Up @@ -763,31 +791,11 @@ QPushButton:hover {
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="dpRadioButtonLayout">
<item>
<widget class="QRadioButton" name="radioButtonDollar">
<property name="minimumSize">
<size>
<width>33</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>$</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="radioButtonPercent">
<property name="text">
<string>%</string>
</property>
</widget>
</item>
</layout>
<widget class="QLabel" name="dpDollarLabel">
<property name="text">
<string>$</string>
</property>
</widget>
</item>
<item>
<spacer name="dpSpacerH3">
Expand Down
126 changes: 66 additions & 60 deletions home-choice-pro/tests/test_views/test_main_window.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,13 @@
Main Window Test Cases Below
"""

import pytest
from PyQt5 import QtCore
from views.main_window import MainWindow
from views.main_window import MainWindow
from views.pop_up_error_window import ErrorWindow


# main window
@pytest.fixture
def main_window(qtbot):
Expand All @@ -26,129 +28,133 @@ def main_window(qtbot):
qtbot.addWidget(main_window)
yield main_window


def test_main_window(main_window):
assert isinstance(main_window, MainWindow)


# make sure we title our app
def test_window_title(main_window):
assert main_window.windowTitle() == 'Home Choice Pro'
assert main_window.windowTitle() == "Home Choice Pro"


# Side Panel
def test_logo(main_window):
assert main_window.ui.Logo.isVisible()


# Calc button
def test_calculator_button(main_window):
assert main_window.ui.calculatorButton.isChecked()


# verify starting values for each edit box
def test_empty_edit_boxes(main_window):
assert main_window.ui.monthlyPaymentEdit.text() == '0'
assert main_window.ui.dpEdit.text() == '0'
assert main_window.ui.interestRateEdit.text() == '0'
assert main_window.ui.monthlyPaymentEdit.text() == "0"
assert main_window.ui.dpEdit.text() == "0"
assert main_window.ui.interestRateEdit.text() == "0"


def test_verify_digits(main_window):
main_window.ui.monthlyPaymentEdit.setText('1')
main_window.ui.dpEdit.setText('1')
main_window.ui.interestRateEdit.setText('1')
main_window.ui.monthlyPaymentEdit.setText("1")
main_window.ui.dpEdit.setText("1")
main_window.ui.interestRateEdit.setText("1")
assert main_window.verify_digits() == True
main_window.ui.monthlyPaymentEdit.setText('a')
main_window.ui.dpEdit.setText('1')
main_window.ui.interestRateEdit.setText('1')
main_window.ui.monthlyPaymentEdit.setText("a")
main_window.ui.dpEdit.setText("1")
main_window.ui.interestRateEdit.setText("1")
assert main_window.verify_digits() == False
main_window.ui.monthlyPaymentEdit.setText('1')
main_window.ui.dpEdit.setText('b')
main_window.ui.interestRateEdit.setText('1')
main_window.ui.monthlyPaymentEdit.setText("1")
main_window.ui.dpEdit.setText("b")
main_window.ui.interestRateEdit.setText("1")
assert main_window.verify_digits() == False
main_window.ui.monthlyPaymentEdit.setText('1')
main_window.ui.dpEdit.setText('1')
main_window.ui.interestRateEdit.setText('c')
main_window.ui.monthlyPaymentEdit.setText("1")
main_window.ui.dpEdit.setText("1")
main_window.ui.interestRateEdit.setText("c")
assert main_window.verify_digits() == False
main_window.ui.monthlyPaymentEdit.setText('')
main_window.ui.dpEdit.setText('1')
main_window.ui.interestRateEdit.setText('1')
main_window.ui.monthlyPaymentEdit.setText("")
main_window.ui.dpEdit.setText("1")
main_window.ui.interestRateEdit.setText("1")
assert main_window.verify_digits() == False
main_window.ui.monthlyPaymentEdit.setText('1')
main_window.ui.dpEdit.setText('1')
main_window.ui.interestRateEdit.setText(' ')
main_window.ui.monthlyPaymentEdit.setText("1")
main_window.ui.dpEdit.setText("1")
main_window.ui.interestRateEdit.setText(" ")
assert main_window.verify_digits() == False


def test_display_error(main_window, qtbot):
main_window.display_error()
assert isinstance(main_window.error, ErrorWindow)
assert main_window.error.isVisible()
assert main_window.error.windowTitle() == 'Home Choice Pro'
assert main_window.error.windowTitle() == "Home Choice Pro"
# had trouble with error window message, will come back since changing anway
qtbot.mouseClick(main_window.error.ui.closeButton, QtCore.Qt.LeftButton)
assert not main_window.error.isVisible()


def test_monthly_payment_edit(main_window, qtbot):
main_window.ui.monthlyPaymentEdit.clear()
qtbot.keyClicks(main_window.ui.monthlyPaymentEdit, '12345')
assert main_window.ui.monthlyPaymentEdit.text() == '12345'
qtbot.keyClicks(main_window.ui.monthlyPaymentEdit, "12345")
assert main_window.ui.monthlyPaymentEdit.text() == "12345"


def test_dpEdit(main_window, qtbot):
main_window.ui.dpEdit.clear()
qtbot.keyClicks(main_window.ui.dpEdit, '12345')
assert main_window.ui.dpEdit.text() == '12345'
qtbot.keyClicks(main_window.ui.dpEdit, "12345")
assert main_window.ui.dpEdit.text() == "12345"


def test_interest_rate_edit(main_window, qtbot):
main_window.ui.interestRateEdit.clear()
qtbot.keyClicks(main_window.ui.interestRateEdit, '12345')
assert main_window.ui.interestRateEdit.text() == '12345'
qtbot.keyClicks(main_window.ui.interestRateEdit, "12345")
assert main_window.ui.interestRateEdit.text() == "12345"

def test_radial_buttons(main_window, qtbot):
assert main_window.ui.radioButtonDollar.isChecked()
qtbot.mouseClick(main_window.ui.radioButtonPercent, QtCore.Qt.LeftButton)
assert main_window.ui.radioButtonPercent.isChecked()

def test_loan_term_box(main_window, qtbot):
assert main_window.ui.termComboBox.currentText() == '30'
assert main_window.ui.termComboBox.currentText() == "30"
qtbot.mouseClick(main_window.ui.termComboBox, QtCore.Qt.LeftButton)
qtbot.keyClicks(main_window.ui.termComboBox, '15')
assert main_window.ui.termComboBox.currentText() == '15'
qtbot.keyClicks(main_window.ui.termComboBox, "15")
assert main_window.ui.termComboBox.currentText() == "15"


def test_calculate_house(main_window, qtbot):
main_window.ui.monthlyPaymentEdit.clear()
qtbot.keyClicks(main_window.ui.monthlyPaymentEdit, '1000')
qtbot.keyClicks(main_window.ui.monthlyPaymentEdit, "1000")
main_window.ui.dpEdit.clear()
qtbot.keyClicks(main_window.ui.dpEdit, '1')
qtbot.keyClicks(main_window.ui.dpEdit, "1")
main_window.ui.interestRateEdit.clear()
qtbot.keyClicks(main_window.ui.interestRateEdit, '1')
qtbot.keyClicks(main_window.ui.interestRateEdit, "1")
qtbot.mouseClick(main_window.ui.calcPushButton, QtCore.Qt.LeftButton)
assert main_window.ui.homeAffordabilityLabelNumber.text() == '$310908'
assert main_window.ui.totalCostLabelNumber.text() == '$360000'
assert main_window.ui.principalLabelNumber.text() == '$310907'
assert main_window.ui.interestLabelNumber.text() == '$49093'
assert main_window.ui.homeAffordabilityLabelNumber.text() == "$310908"
assert main_window.ui.totalCostLabelNumber.text() == "$360000"
assert main_window.ui.principalLabelNumber.text() == "$310907"
assert main_window.ui.interestLabelNumber.text() == "$49093"
assert main_window.ui.downPaymentHeaderLabel.text() == "Down Payment: 0%"


def test_reset(main_window, qtbot):
main_window.ui.monthlyPaymentEdit.clear()
qtbot.keyClicks(main_window.ui.monthlyPaymentEdit, '12345')
qtbot.keyClicks(main_window.ui.monthlyPaymentEdit, "12345")
main_window.ui.dpEdit.clear()
qtbot.keyClicks(main_window.ui.dpEdit, '12345')
qtbot.keyClicks(main_window.ui.dpEdit, "12345")
main_window.ui.interestRateEdit.clear()
qtbot.keyClicks(main_window.ui.interestRateEdit, '12345')
qtbot.mouseClick(main_window.ui.radioButtonPercent, QtCore.Qt.LeftButton)
qtbot.keyClicks(main_window.ui.interestRateEdit, "12345")
qtbot.mouseClick(main_window.ui.termComboBox, QtCore.Qt.LeftButton)
qtbot.keyClicks(main_window.ui.termComboBox, '15')
qtbot.keyClicks(main_window.ui.termComboBox, "15")
qtbot.mouseClick(main_window.ui.resetPushButton, QtCore.Qt.LeftButton)
assert main_window.ui.monthlyPaymentEdit.text() == '0'
assert main_window.ui.dpEdit.text() == '0'
assert main_window.ui.interestRateEdit.text() == '0'
assert main_window.ui.termComboBox.currentText() == '30'
assert main_window.ui.radioButtonDollar.isChecked()
assert main_window.ui.homeAffordabilityLabelNumber.text() == '$0'
assert main_window.ui.totalCostLabelNumber.text() == '$0'
assert main_window.ui.principalLabelNumber.text() == '$0'
assert main_window.ui.interestLabelNumber.text() == '$0'
assert main_window.ui.monthlyPaymentEdit.text() == "0"
assert main_window.ui.dpEdit.text() == "0"
assert main_window.ui.interestRateEdit.text() == "0"
assert main_window.ui.termComboBox.currentText() == "30"
assert main_window.ui.homeAffordabilityLabelNumber.text() == "$0"
assert main_window.ui.totalCostLabelNumber.text() == "$0"
assert main_window.ui.principalLabelNumber.text() == "$0"
assert main_window.ui.interestLabelNumber.text() == "$0"
assert main_window.ui.downPaymentHeaderLabel.text() == "-"


# this should be the last thing
def test_quit(main_window, qtbot):
assert main_window.isVisible()
qtbot.mouseClick(main_window.ui.quitButton, QtCore.Qt.LeftButton)
assert not main_window.isVisible()

Loading

0 comments on commit b0f5e8c

Please sign in to comment.