craigerl / aprsd

Amateur radio APRS daemon which listens for messages and responds. By KM6LYW.
Apache License 2.0
124 stars 19 forks source link

add unit tests for utils and small refactor of utils #28

Closed johng42 closed 11 months ago

johng42 commented 3 years ago

Add very basic unit tests for utils.

I had to make one small change to get_config - return an error rather than exit to make this function unit testable. There may be some pytest command the check for an override a sys.exit() call, but I don't know how to do that.

Tested on windows and whatever linux flavor used in the pipeline

hemna commented 3 years ago

Should run tox locally through tox -efmt to reformat the code.

Also you can look into mock to fake the sys.exit() call.

hemna commented 3 years ago

fwiw, I created some unit tests for the plugin objects in my PR branch called threads here: https://github.com/craigerl/aprsd/pull/26

You can @mock.patch("sys.exit") as a decorator to your unit test method.