Skip to content

Commit

Permalink
Fixed from branch tests
Browse files Browse the repository at this point in the history
  • Loading branch information
e100 committed Jun 20, 2024
1 parent 5b2ead9 commit 2379a14
Show file tree
Hide file tree
Showing 9 changed files with 53 additions and 14 deletions.
2 changes: 0 additions & 2 deletions src/pyefis/instruments/altimeter/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -381,8 +381,6 @@ def setUnitSwitching(self):
hmi.actions.setInstUnits.connect(self.setUnits)
if self.isVisible():
self.update()
else: # pragma: no cover
pass

def setUnits(self, args):
x = args.split(":")
Expand Down
6 changes: 2 additions & 4 deletions src/pyefis/instruments/gauges/arc.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,6 @@ def resizeEvent(self, event):
if self.width() < self.height():
self.r_height = self.get_height(self.width())
self.r_width = self.width()
if self.height() < self.r_height:
self.r_height = self.height()
self.r_width = self.get_width(self.height())
else:
self.r_width = self.get_width(self.height())
self.r_height = self.height()
Expand Down Expand Up @@ -245,7 +242,8 @@ def paintEvent(self, e):
#p.drawText(QPointF( self.lrcx - x, self.lrcy - (y/1.2) ), self.name)
else:
p.drawText(QPointF( self.lrcx - x, self.lrcy - (y/1.1) ), self.name)

else: # pragma: no cover
pass
# Main value text
if self.font_mask:
opt = QTextOption(Qt.AlignRight)
Expand Down
2 changes: 0 additions & 2 deletions src/pyefis/instruments/gauges/numeric.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,5 +92,3 @@ def paintEvent(self, event):
pen.setColor(self.textColor)
p.setPen(pen)
p.drawText(self.unitsTextRect, self.units, opt)
else: # pragma: no cover
pass
2 changes: 0 additions & 2 deletions src/pyefis/instruments/misc/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,8 +172,6 @@ def setValue(self, value):
self._value = cvalue
self.setColors()
self.update()
else: # pragma: no cover
pass

value = property(getValue, setValue)

Expand Down
4 changes: 2 additions & 2 deletions tests/instruments/altimeter/test_altimeter.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,6 @@ def test_altimeter_tape(fix,qtbot):
qtbot.waitExposed(widget)
widget.font_mask = None
widget.resize(90,200)

#widget.paintEvent(None)


Expand Down Expand Up @@ -127,4 +126,5 @@ def test_altimeter_tape_unit_switching(fix,qtbot):
widget.setUnitSwitching()
widget.keyPressEvent(None)
widget.wheelEvent(None)

widget.hide()
widget.setUnitSwitching()
18 changes: 17 additions & 1 deletion tests/instruments/gauges/test_arc.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def app(qtbot):


def test_arc_gauge(fix,qtbot):
widget = gauges.ArcGauge()
widget = gauges.ArcGauge(min_size=True)
assert widget.getRatio() == 2

# Test with no aux data first
Expand Down Expand Up @@ -96,3 +96,19 @@ def test_arc_gauge(fix,qtbot):
widget.font_ghost_mask = "0000"
widget.paintEvent(None)
assert tracker2.was_called_with("setAlpha", widget.font_ghost_alpha)


def test_arc_gauge_branches(fix,qtbot):
widget = gauges.ArcGauge(min_size=False)
assert widget.getRatio() == 2

# Test with no aux data first
widget.setDbkey("NUM")
widget.setupGauge()
qtbot.addWidget(widget)
widget.name_location = 'top'
widget.name_font_mask = 'XXXX'
widget.resize(100, 101)
widget.show()
qtbot.waitExposed(widget)
qtbot.wait(2000)
3 changes: 3 additions & 0 deletions tests/instruments/gauges/test_numeric.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,6 @@ def test_numeric_gauge(fix,qtbot):
widget.units_font_ghost_mask = "0000"
widget.paintEvent(None)
assert tracker.was_called_with("setAlpha", widget.font_ghost_alpha)
widget.show_units = False
widget.paintEvent(None)

17 changes: 17 additions & 0 deletions tests/instruments/gauges/test_verticalBar.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,3 +121,20 @@ def test_vertical_bar_gauge(fix,qtbot):
widget.paintEvent(None)
widget.normalize_range = 400
widget.paintEvent(None)

def test_vertical_bar_gauge_min_size_false(fix,qtbot):
widget = gauges.VerticalBar(min_size=False)
assert widget.getRatio() == 0.35
widget.setDbkey("NUM")
widget.setupGauge()
qtbot.addWidget(widget)
widget.resize(300, 200)
widget.show()
qtbot.waitExposed(widget)
widget.resizeEvent(None)
widget.show_value = False
widget.resizeEvent(None)
widget.show_units = False
widget.resizeEvent(None)
widget.paintEvent(None)

13 changes: 12 additions & 1 deletion tests/instruments/misc/test_misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,18 @@ def test_value_display_set_value(fix, qtbot):

fix.db.set_value("TEST",3.14)
assert widget.getValue() == 3.14

widget.setValue(20)
assert widget._value == 20
widget.conversionFunction = lambda x: x*2
widget.setValue(10)
assert widget._value == 20
widget.font_ghost_mask = None
widget.resize(100,100)
widget.show()
widget.paintEvent(None)
widget.font_ghost_mask = "XXXX"
widget.paintEvent(None)
qtbot.waitExposed(widget)

#@mock.patch("pyefis.instruments.misc.fix")
#def test_value_display_flags(mock_fix, qtbot):
Expand Down

0 comments on commit 2379a14

Please sign in to comment.