Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Code tests, update standards #229

Merged
merged 61 commits into from
Jun 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
61 commits
Select commit Hold shift + click to select a range
e7e0f49
Update project layout closer to current standards
e100 Jun 7, 2024
f071607
Change pyavtools dep to use latest github revision since PyPy is outd…
e100 Jun 7, 2024
5b35889
Fixed version and snap build
e100 Jun 7, 2024
3ff1b44
Added first unit test, still need a little work
e100 Jun 8, 2024
f5d1314
Updated Makefile with new options and fixes, added test that takes sc…
e100 Jun 8, 2024
97977ef
Added coverage report
e100 Jun 8, 2024
9dce59c
Merged changes from master
e100 Jun 8, 2024
0882630
Updated build dependency version to latest
e100 Jun 8, 2024
e60f483
Updated readme with new Makefile commands
e100 Jun 8, 2024
7578914
Require user confirmation in make clean when deleting files in bulk
e100 Jun 8, 2024
8f2fb76
Added necessary setting for CI coverage comment
e100 Jun 8, 2024
4dd93ef
Added options needed for github action comment to work
e100 Jun 8, 2024
deddb59
Still trying to fix relative_files
e100 Jun 8, 2024
18d1eb7
See if chaning --cov=src resolves the issue
e100 Jun 8, 2024
938afa7
Added unit test for pyefis.common, formatted with black
e100 Jun 8, 2024
29ad093
Added unit tests for hmi.actionclass and formatted actionclass with b…
e100 Jun 9, 2024
d0c62a0
Added test for pyefis.version and formatted with black
e100 Jun 9, 2024
d553f8a
Added tests for pyefis.hmi.functions and formatted with black
e100 Jun 9, 2024
ced73d6
saving progress creating tests for pyefis.cfg
e100 Jun 9, 2024
3574d05
Created unit tests for test_cfg.py
e100 Jun 9, 2024
a98ffe5
Updated pyefis.cfg with better exceptions, fixed nested list bug
e100 Jun 9, 2024
b4cea80
ran black on tests, added missing test files
e100 Jun 9, 2024
cfb4445
100% coverage for pyefis.cfg, removed unneeded code
e100 Jun 9, 2024
e88e10b
Added tst for pyefis.hmi init
e100 Jun 9, 2024
7f17f33
Formatted pyefis.hmi init test with black
e100 Jun 9, 2024
5d3ec9b
instruments.misc now has 100% test coverage except for the try except…
e100 Jun 10, 2024
c5db815
Added mock_db that allows running the fix db without a six gateway, t…
e100 Jun 11, 2024
eece5d8
updated mock_db and instruments.misc tests
e100 Jun 11, 2024
c5f0f77
Adding framework to automate screenshots of each widget
e100 Jun 12, 2024
6477d5f
Progress on screenshots
e100 Jun 12, 2024
465b852
Added some code so we can use screenbuilder to create the displays fo…
e100 Jun 12, 2024
e0cedb2
Updated gauges to return padded number from getValueText if font_mask…
e100 Jun 13, 2024
beac3c0
Added missing units ghost font to numerical_display
e100 Jun 13, 2024
2e3c5df
first screenshot capture setup and working
e100 Jun 13, 2024
3e78cfc
Updated fit_to_mask so it remdered closer to the largest size possibl…
e100 Jun 13, 2024
617810b
Added missing unit_font_mask to numerical_display screenshot
e100 Jun 13, 2024
0127f1e
Adjusted position of units in numberical_display
e100 Jun 13, 2024
71e6c0f
Updated gauges to return xxx on fail in same number of characters as …
e100 Jun 13, 2024
6274fd1
Added tests for instruments.NumericalDiplay
e100 Jun 14, 2024
d10a167
Fixed airspeed dial to set initial value properly
e100 Jun 14, 2024
2a795dc
formatted airspeed and numericalDisplay with black
e100 Jun 14, 2024
ca9716f
Added tests for airspeed
e100 Jun 14, 2024
2fae2d9
Formatted airspeed test with black
e100 Jun 14, 2024
fd024c7
Added airspeed fix keys to conftest.py
e100 Jun 14, 2024
b553eb4
Formatted conftest.py with black
e100 Jun 14, 2024
1aa5e67
Changed size of virtual screen when running tests
e100 Jun 14, 2024
b604993
Updated screen builder grid overlay so the lines are semi-transparent
e100 Jun 14, 2024
7ff6877
Removed unneeded imports on instruments.misc
e100 Jun 14, 2024
57937de
Removed wait at end of airspeed test
e100 Jun 14, 2024
bdd5a1c
Removed unneeded code
e100 Jun 14, 2024
4940cec
Saving progress on arc gauge test
e100 Jun 14, 2024
503ce64
Tests for arc gauge but lacking assertions, likely need to add some m…
e100 Jun 14, 2024
d170d97
Added utility function to tests that can wrap functions and track wha…
e100 Jun 14, 2024
6f1360a
Finished arc gauge tests
e100 Jun 14, 2024
06f4905
Fixed wrong type in arc gauge
e100 Jun 14, 2024
e4a9cd6
Added tests for gauges.numeric
e100 Jun 14, 2024
6cb46c3
Added more compare options to the tracker utility
e100 Jun 14, 2024
3bf05ed
Added tests for horizontal bar gauge
e100 Jun 14, 2024
68e91e5
added test for vertical bar gauge
e100 Jun 14, 2024
c342e92
Changed the fix db in conftest.py into a fix fixture to ensure each t…
e100 Jun 14, 2024
a836d6a
Prevent divide by zero in verticalBar gauge when normalized mode is e…
e100 Jun 15, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ Phil Birkelbach
Neil Domalik
Jean-Manuel Gagnon
Garrett Herschleb
Eric Blevins
37 changes: 31 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,48 @@ SHELL := /bin/bash


##################################### I N I T T A R G E T S #####################################
venv:
venv.marker:
python3 -m venv venv
source venv/bin/activate ; pip install --upgrade pip
source venv/bin/activate ; pip install black
source venv/bin/activate ; pip install pytest
source venv/bin/activate ; pip install pytest-qt
source venv/bin/activate ; pip install pytest-env
source venv/bin/activate ; pip install pytest-cov
touch venv.marker
echo -e "\nRun:\nsource venv/bin/activate"
venv: venv.marker
.PHONY: venv

init.marker: setup.py
pip install -e .[install]
init.marker: pyproject.toml
source venv/bin/activate ; pip install -e .[install]
touch init.marker
init: init.marker
init: venv.marker init.marker
.PHONY: init

#################################### W H E E L T A R G E T S ####################################
init-build.marker: init
pip install -e .[build]
source venv/bin/activate ; pip install -e .[build]
touch init-build.marker

init-build: init-build.marker
.PHONY: init-build

wheel: init-build
python -m build --wheel
source venv/bin/activate ; python -m build --wheel


test: init
source venv/bin/activate ; pytest

.PHONY: test

clean:
rm -rfI venv
rm -fI extras/extras/test_results/*.html
rm -fI extras/extras/test_results/*.png
rm -rfI extras/extras/test_results/htmlcov/
rm -f init-build.marker
rm -f init.marker
rm -f venv.marker
.PHONY: clean
19 changes: 19 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,15 @@ This creates an index.bin file in CIFP directory
Update the config file [Screen.PFD] section dbpath and indexpath
with the path names of the FAACIFP18 and index.bin files respectively.

Testing
------------
To run all of the automated tests and code covreage.

::

$ make test


Distribution
------------

Expand Down Expand Up @@ -114,3 +123,13 @@ All CLI options work as defined.
--log-config LOG_CONFIG
Alternate logger configuration file


Cleanup
------------

To cleanup all of the test files, virtual environemnt and other changes made by the makefile. This is a destructive command, you may want to review what it does before running it.

::

$ make clean

99 changes: 99 additions & 0 deletions conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
import pytest
# Patch pyavtools.fix so it can run in memory without a fix server
import sys
import tests.mock_db.client
import tests.mock_db.scheduler

sys.modules["pyavtools.fix.client"] = tests.mock_db.client
sys.modules["pyavtools.scheduler"] = tests.mock_db.scheduler



@pytest.fixture
def fix():
# import fix
import pyavtools.fix as fix

# Init database
fix.initialize({"main": {"FixServer": "localhost", "FixPort": "3490"}})

# TODO Add example setting aux values since needed on many tests
# Define some fix db items we can use in tests
# Define a key:
# key,desc, dtype(as a string), min, max, units, tol, aux
fix.db.define_item("TEST", "Testing key", "float", 0, 100, "", 50000, "")
# Set initial Value
fix.db.set_value("TEST", 50.19)
# Bad and fail are true by default to set them False
fix.db.get_item("TEST").bad = False
fix.db.get_item("TEST").fail = False


def create_numbers(key, value, old=False, bad=False, fail=False, annunciate=False):
fix.db.define_item(
key,
"Number",
"float",
0,
100,
"degC",
50000,
"Min,Max,highWarn,highAlarm,lowWarn,lowAlarm",
)
fix.db.set_value(key, value)
fix.db.get_item(key).old = old
fix.db.get_item(key).bad = bad
fix.db.get_item(key).fail = fail
fix.db.get_item(key).annunciate = annunciate
fix.db.get_item(key).set_aux_value("Min", 0)
fix.db.get_item(key).set_aux_value("lowAlarm", 10)
fix.db.get_item(key).set_aux_value("lowWarn", 20)
fix.db.get_item(key).set_aux_value("highWarn", 80)
fix.db.get_item(key).set_aux_value("highAlarm", 90)
fix.db.get_item(key).set_aux_value("Max", 100)


create_numbers("NUMOK", 50.91)
create_numbers("NUMOLD", 51.82, old=True)
create_numbers("NUMBAD", 48.73, bad=True)
create_numbers("NUMFAIL", 65.64, fail=True)
create_numbers("NUMANNUNCIATE", 62.55, annunciate=True)
create_numbers("NUMLOWWARN", 18.46)
create_numbers("NUMLOWALARM", 5.37)
create_numbers("NUMHIGHWARN", 81.28)
create_numbers("NUMHIGHALARM", 95.19)

# Number with no Aux
fix.db.define_item("NUM", "NUM", "float", 0.0, 100.0, "degC", 50000, "")

fix.db.define_item("GS", "GS", "float", 0.0, 2000.0, "knots", 50000, "")
fix.db.set_value("GS", 100)
fix.db.get_item("GS").bad = False
fix.db.get_item("GS").fail = False

fix.db.define_item("TAS", "TAS", "float", 0.0, 2000.0, "knots", 50000, "")
fix.db.set_value("TAS", 105)
fix.db.get_item("TAS").bad = False
fix.db.get_item("TAS").fail = False

fix.db.define_item(
"IAS",
"Number",
"float",
0,
2000.0,
"knots",
50000,
"Min,Max,V1,V2,Vne,Vfe,Vmc,Va,Vno,Vs,Vs0,Vx,Vy",
)
fix.db.set_value("IAS", "110")
fix.db.get_item("IAS").bad = False
fix.db.get_item("IAS").fail = False
fix.db.get_item("IAS").set_aux_value("Vs", 45.0)
fix.db.get_item("IAS").set_aux_value("Vs0", 40.0)
fix.db.get_item("IAS").set_aux_value("Vno", 125.0)
fix.db.get_item("IAS").set_aux_value("Vne", 140.0)
fix.db.get_item("IAS").set_aux_value("Vfe", 70.0)

return fix

File renamed without changes.
92 changes: 0 additions & 92 deletions pyefis/cfg.py

This file was deleted.

57 changes: 0 additions & 57 deletions pyefis/instruments/helpers/__init__.py

This file was deleted.

3 changes: 0 additions & 3 deletions pyefis/version.py

This file was deleted.

Loading
Loading