Skip to content

Commit

Permalink
Merge pull request #234 from e100/more_tests_and_ci_fixes
Browse files Browse the repository at this point in the history
Adding more tests
  • Loading branch information
e100 authored Jun 16, 2024
2 parents 30d76de + 18fb119 commit 1176a8c
Show file tree
Hide file tree
Showing 19 changed files with 659 additions and 12 deletions.
159 changes: 158 additions & 1 deletion conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,163 @@ def create_numbers(key, value, old=False, bad=False, fail=False, annunciate=Fals
""
)
fix.db.set_value("ALT", 0)
fix.db.get_item("ALT").bad = False
fix.db.get_item("ALT").fail = False

return fix

fix.db.define_item(
"LAT",
"Latitude",
"float",
-90.0,
90.0,
"deg",
50000,
""
)
fix.db.set_value("LAT", 0)
fix.db.get_item("LAT").bad = False
fix.db.get_item("LAT").fail = False

fix.db.define_item(
"LONG",
"Longitude",
"float",
-180.0,
180.0,
"deg",
50000,
""
)
fix.db.set_value("LONG", 0)
fix.db.get_item("LONG").bad = False
fix.db.get_item("LONG").fail = False

fix.db.define_item(
"PITCH",
"Pitch Angle",
"float",
-90.0,
90.0,
"deg",
50000,
""
)
fix.db.set_value("PITCH", 0)
fix.db.get_item("PITCH").bad = False
fix.db.get_item("PITCH").fail = False

fix.db.define_item(
"ROLL",
"Roll Angle",
"float",
-180.0,
180.0,
"deg",
50000,
""
)
fix.db.set_value("ROLL", 0)
fix.db.get_item("ROLL").bad = False
fix.db.get_item("ROLL").fail = False

fix.db.define_item(
"ALAT",
"Lateral Acceleration",
"float",
-30.0,
30.0,
"g",
50000,
""
)
fix.db.set_value("ALAT", 0)
fix.db.get_item("ALAT").bad = False
fix.db.get_item("ALAT").fail = False

fix.db.define_item(
"HEAD",
"Current Aircraft Magnetic Heading",
"float",
0.0,
359.9,
"deg",
50000,
""
)
fix.db.set_value("HEAD", 0)
fix.db.get_item("HEAD").bad = False
fix.db.get_item("HEAD").fail = False

fix.db.define_item(
"GSI",
"Glideslope Indicator",
"float",
-1.0,
1.0,
"",
50000,
""
)
fix.db.set_value("GSI", 0)
fix.db.get_item("GSI").bad = False
fix.db.get_item("GSI").fail = False

fix.db.define_item(
"CDI",
"Course Deviation Indicator",
"float",
-1.0,
1.0,
"",
50000,
""
)
fix.db.set_value("GSI", 0)
fix.db.get_item("GSI").bad = False
fix.db.get_item("GSI").fail = False

fix.db.define_item(
"COURSE",
"Selected Course",
"float",
0.0,
359.9,
"deg",
50000,
""
)
fix.db.set_value("COURSE", 0)
fix.db.get_item("COURSE").bad = False
fix.db.get_item("COURSE").fail = False

fix.db.define_item(
"ROT",
"Rate of Turn",
"float",
-3000,
3000,
"Deg/sec",
50000,
""
)
fix.db.set_value("ROT", 0)
fix.db.get_item("ROT").bad = False
fix.db.get_item("ROT").fail = False

fix.db.define_item(
"VS",
"Vertical Speed",
"float",
-30000,
30000,
"ft/min",
50000,
"Min,Max"
)
fix.db.set_value("ROT", 0)
fix.db.get_item("ROT").bad = False
fix.db.get_item("ROT").fail = False


return fix
9 changes: 6 additions & 3 deletions src/pyefis/instruments/altimeter/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,14 +67,14 @@ def paintEvent(self, event):

# Draw the Black Background
dial.fillRect(0, 0, w, h, QColor(self.bg_color))

dialPen = QPen()
# Setup Pens
if self.item.old or self.item.bad:
warn_font = QFont(self.font_family, 30, QFont.Bold)
dialPen = QPen(QColor(Qt.gray))
dialPen.setColor(QColor(Qt.gray))
dialBrush = QBrush(QColor(Qt.gray))
else:
dialPen = QPen(QColor(Qt.white))
dialPen.setColor(QColor(Qt.white))
dialBrush = QBrush(QColor(Qt.white))
dialPen.setWidth(2)

Expand Down Expand Up @@ -105,6 +105,9 @@ def paintEvent(self, event):
)
altimeter_numbers += 1
else:
# Do not think this code is needed
# count starts at 0, increments by 36
# The if would never be false to get here
dial.drawLine(0, -(radius), 0, -(radius - 10))

dial.rotate(36)
Expand Down
12 changes: 6 additions & 6 deletions src/pyefis/instruments/tc/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -276,8 +276,8 @@ def resizeEvent(self, event):
self.boxHalfWidth = (self.r - length) * math.cos(math.radians(30))
self.boxTop = self.center.y() + (self.r - length) * math.sin(
math.radians(30)) + thickness
rect = QRectF(QPoint(self.center.x() - self.boxHalfWidth, self.boxTop),
QPoint(self.center.x() + self.boxHalfWidth,
rect = QRectF(QPointF(self.center.x() - self.boxHalfWidth, self.boxTop),
QPointF(self.center.x() + self.boxHalfWidth,
self.boxTop + length))
p.drawRect(rect)
# Draw the little airplane center
Expand All @@ -286,10 +286,10 @@ def resizeEvent(self, event):
pen.setColor(QColor(Qt.black))
pen.setWidth(4)
p.setPen(pen)
p.drawLine(self.center.x() - 30, self.boxTop,
self.center.x() - 30, self.boxTop + length + 2)
p.drawLine(self.center.x() + 30, self.boxTop,
self.center.x() + 30, self.boxTop + length + 2)
p.drawLine(qRound(self.center.x() - 30), qRound(self.boxTop),
qRound(self.center.x() - 30), qRound(self.boxTop + length + 2))
p.drawLine(qRound(self.center.x() + 30), qRound(self.boxTop),
qRound(self.center.x() + 30), qRound(self.boxTop + length + 2))

def paintEvent(self, event):

Expand Down
76 changes: 76 additions & 0 deletions tests/data/listbox/list1.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
display:
# The column names must be single word
# The exact name defined here is used for the key names
# in the list below
columns:
- name: Name
size: 15
sort: true
- name: Identifier
size: 4
sort: true
- name: Frequency
size: 11
sort: false #False is the default
# Enables nearest selector where it will
# sort by distance from your current location
# Requires LONG and LAT keys on each entry to work.

location: true
list:
- Name: Akron-Canton Reg Tower
Identifier: KCAK
Frequency: 134.750 Mhz
lat: 40.9150556
long: -81.4436389
set:
COMACTFREQSET{radio_id}: 134750
COMACTNAMESET{radio_id}: "{Name}"
- Name: Akron-Canton Reg ATIS
Identifier: KCAK
Frequency: 121.050 Mhz
lat: 40.9150556
long: -81.4436389
set:
COMACTFREQSET{radio_id}: 121050
COMACTNAMESET{radio_id}: "{Name}"
- Name: Cleveland-Hopkins Int Tower
Identifier: KCLE
Frequency: 124.500 Mhz
set:
COMACTFREQSET{radio_id}: 124500
COMACTNAMESET{radio_id}: "{Name}"
lat: 41.4094069
long: -81.8546911
- Name: Cleveland-Hopkins Int ATIS
Identifier: KCLE
Frequency: 127.850 Mhz
set:
COMACTFREQSET{radio_id}: 127850
COMACTNAMESET{radio_id}: "{Name}"
lat: 41.4094069
long: -81.8546911

- Name: John Glenn Int. Tower
Identifier: KCMH
Frequency: 132.700 Mhz
lat: 39.9969467
long: -82.8921592
set:
COMACTFREQSET{radio_id}: 132700
COMACTNAMESET{radio_id}: "{Name}"
- Name: John Glenn Int. Ground
Identifier: KCMH
Frequency: 121.900 Mhz
set:
COMACTFREQSET{radio_id}: 121900
COMACTNAMESET{radio_id}: "{Name}"
lat: 39.9969467
long: -82.8921592
- Name: John Glenn Int. ASOS
Identifier: KCMH
Frequency: 124.600 Mhz
set:
COMACTFREQSET{radio_id}: 124600
COMACTNAMESET{radio_id}: "{Name}"

49 changes: 49 additions & 0 deletions tests/data/listbox/list2.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
display:
# The column names must be single word
# The exact name defined here is used for the key names
# in the list below
columns:
- name: Name
size: 15
sort: true
- name: Identifier
size: 4
sort: true
- name: Frequency
size: 11
sort: false #False is the default
# Enables nearest selector where it will
# sort by distance from your current location
# Requires LONG and LAT keys on each entry to work.

location: true
list:
- Name: Rickenbacker Int Tower
Identifier: KLCK
Frequency: 120.050 Mhz
lat: 39.8137881
long: -82.9278164
set:
COMACTFREQSET{radio_id}: 12050
COMACTNAMESET{radio_id}: "{Name}"
- Name: Rickenbacker Int ASOS
Identifier: KLCK
Frequency: 132.75 Mhz
lat: 39.8137881
long: -82.9278164
set:
COMACTFREQSET{radio_id}: 132750
COMACTNAMESET{radio_id}: "{Name}"
- Name: Chapman Memorial
Identifier: K6CM
Frequency: 122.900 Mhz
set:
COMACTFREQSET{radio_id}: 122.900
COMACTNAMESET{radio_id}: "{Name}"
- Name: Marion Municipal
Identifier: KMNN
Frequency: 122.800 Mhz
set:
COMACTFREQSET{radio_id}: 122.800
COMACTNAMESET{radio_id}: "{Name}"

Empty file.
25 changes: 25 additions & 0 deletions tests/instruments/ai/test_ai.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import pytest
from unittest import mock
from PyQt5.QtWidgets import QApplication
from PyQt5.QtCore import Qt, qRound
from PyQt5.QtGui import QColor, QBrush, QPen, QFont, QPainter, QPaintEvent, QFontMetrics
from PyQt5 import QtGui
from pyefis.instruments import ai
import pyefis.hmi as hmi
from tests.utils import track_calls

@pytest.fixture
def app(qtbot):
test_app = QApplication.instance()
if test_app is None:
test_app = QApplication([])
return test_app


def test_ai(fix,qtbot):
widget = ai.AI()
qtbot.addWidget(widget)
widget.resize(200,200)
widget.show()
qtbot.waitExposed(widget)
qtbot.wait(3000)
Loading

0 comments on commit 1176a8c

Please sign in to comment.