stdevel / katprep

Python toolkit for automating system maintenance and generating patch reports along with Foreman/Katello and Red Hat Satellite 6.x
GNU General Public License v3.0
35 stars 6 forks source link

Migrate tests to pytest #103

Closed okin closed 5 years ago

okin commented 5 years ago

This fixes #73.

The tests have been migrated to pytest. As part of the migration the travis configuration was changed so that the tests are run automatically on travis. The names of the test files has been remaned to work with pytests test discovery. The current state is that tests missing a configuration file will be skipped instead of simply failing. Since I don't have a test environment please run the tests and see if they still are all green in your test environment. I happily help fixing if I broke something.

Some tests have been grouped if they only made sense being run together. This applies to tests for handling snapshots / downtimes. This reduces the need for tests to be run in an order and now every test can be run at any time because we do not rely on specific tests with an specific ordering.

Tests for Icinga 1.x and Nagios now reside in one module and tests for both will be run by using a fixture. Since features from Icinga 2.x and the beforementioned legacy systems overlap it could be an idea to merge these together in a single test suite.

Tests for the virtualization libs make use of a shared test suite but some tests were only available for pyvmomi. Maybe they can be merged in the future aswell.

Since Python 3.4 was enabled in the travis config I fixed imports and octal values so the tests can be run. This is however not complete Python 3 support - just having the tests running (and skipping).

okin commented 5 years ago

I merged the latest master. Doing so I discovered that codecov was listed as a dependency. I took the liberty to move it to the optional dependencies since it isn't required for katprep itself but only for showing coverage.

codecov-io commented 5 years ago

Codecov Report

:exclamation: No coverage uploaded for pull request base (master@aacd331). Click here to learn what that means. The diff coverage is 55.55%.

Impacted file tree graph

@@            Coverage Diff            @@
##             master     #103   +/-   ##
=========================================
  Coverage          ?   11.07%           
=========================================
  Files             ?       16           
  Lines             ?     1969           
  Branches          ?        0           
=========================================
  Hits              ?      218           
  Misses            ?     1751           
  Partials          ?        0
Impacted Files Coverage Δ
katprep/clients/Icinga2APIClient.py 21.48% <ø> (ø)
katprep/authconfig.py 0% <0%> (ø)
katprep/clients/LibvirtClient.py 0% <0%> (ø)
katprep/maintenance.py 0% <0%> (ø)
katprep/clients/PyvmomiClient.py 17.03% <100%> (ø)
katprep/__init__.py 17.69% <50%> (ø)
katprep/clients/SpacewalkAPIClient.py 46.15% <75%> (ø)
katprep/AuthContainer.py 32.29% <80%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update aacd331...fd64012. Read the comment docs.

okin commented 5 years ago

After the merge from I made the mistake of having multiple script:lines in the travis config. This lead to only executing the last line and therefore not running any tests. This has now been fixed: tests run and then coverage reports get created. In the process some changes to the print statement has been done to properly support Python 3.

stdevel commented 5 years ago

Great job, thanks for your contribution! :)

Successfully checked the Nagios/Icinga and Icinga2 stuff - so I'm merging this. Need to find another mechanism to also check VMware, libvirt and co (see also issue #108), but this a topic for the future.