From 2379a14b0099194ef118a321c7ccb0586af09eb8 Mon Sep 17 00:00:00 2001 From: Eric Blevins Date: Thu, 20 Jun 2024 19:21:24 -0400 Subject: [PATCH] Fixed from branch tests --- src/pyefis/instruments/altimeter/__init__.py | 2 -- src/pyefis/instruments/gauges/arc.py | 6 ++---- src/pyefis/instruments/gauges/numeric.py | 2 -- src/pyefis/instruments/misc/__init__.py | 2 -- tests/instruments/altimeter/test_altimeter.py | 4 ++-- tests/instruments/gauges/test_arc.py | 18 +++++++++++++++++- tests/instruments/gauges/test_numeric.py | 3 +++ tests/instruments/gauges/test_verticalBar.py | 17 +++++++++++++++++ tests/instruments/misc/test_misc.py | 13 ++++++++++++- 9 files changed, 53 insertions(+), 14 deletions(-) diff --git a/src/pyefis/instruments/altimeter/__init__.py b/src/pyefis/instruments/altimeter/__init__.py index 568289d7..4399b136 100644 --- a/src/pyefis/instruments/altimeter/__init__.py +++ b/src/pyefis/instruments/altimeter/__init__.py @@ -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(":") diff --git a/src/pyefis/instruments/gauges/arc.py b/src/pyefis/instruments/gauges/arc.py index e12abae6..c5b9b8a6 100644 --- a/src/pyefis/instruments/gauges/arc.py +++ b/src/pyefis/instruments/gauges/arc.py @@ -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() @@ -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) diff --git a/src/pyefis/instruments/gauges/numeric.py b/src/pyefis/instruments/gauges/numeric.py index 0a05481b..1deb0ecb 100644 --- a/src/pyefis/instruments/gauges/numeric.py +++ b/src/pyefis/instruments/gauges/numeric.py @@ -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 diff --git a/src/pyefis/instruments/misc/__init__.py b/src/pyefis/instruments/misc/__init__.py index bcaf5bc4..1de2ca73 100644 --- a/src/pyefis/instruments/misc/__init__.py +++ b/src/pyefis/instruments/misc/__init__.py @@ -172,8 +172,6 @@ def setValue(self, value): self._value = cvalue self.setColors() self.update() - else: # pragma: no cover - pass value = property(getValue, setValue) diff --git a/tests/instruments/altimeter/test_altimeter.py b/tests/instruments/altimeter/test_altimeter.py index e490f4e6..61f4b0fd 100644 --- a/tests/instruments/altimeter/test_altimeter.py +++ b/tests/instruments/altimeter/test_altimeter.py @@ -89,7 +89,6 @@ def test_altimeter_tape(fix,qtbot): qtbot.waitExposed(widget) widget.font_mask = None widget.resize(90,200) - #widget.paintEvent(None) @@ -127,4 +126,5 @@ def test_altimeter_tape_unit_switching(fix,qtbot): widget.setUnitSwitching() widget.keyPressEvent(None) widget.wheelEvent(None) - + widget.hide() + widget.setUnitSwitching() diff --git a/tests/instruments/gauges/test_arc.py b/tests/instruments/gauges/test_arc.py index af8bfad1..21504a54 100644 --- a/tests/instruments/gauges/test_arc.py +++ b/tests/instruments/gauges/test_arc.py @@ -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 @@ -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) diff --git a/tests/instruments/gauges/test_numeric.py b/tests/instruments/gauges/test_numeric.py index 62ab4fed..51b0e32a 100644 --- a/tests/instruments/gauges/test_numeric.py +++ b/tests/instruments/gauges/test_numeric.py @@ -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) + diff --git a/tests/instruments/gauges/test_verticalBar.py b/tests/instruments/gauges/test_verticalBar.py index 49716078..1832fb66 100644 --- a/tests/instruments/gauges/test_verticalBar.py +++ b/tests/instruments/gauges/test_verticalBar.py @@ -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) + diff --git a/tests/instruments/misc/test_misc.py b/tests/instruments/misc/test_misc.py index 5b9eaba3..6fce76ff 100644 --- a/tests/instruments/misc/test_misc.py +++ b/tests/instruments/misc/test_misc.py @@ -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):