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

Add full mock installation and unit tests #18

Merged
merged 6 commits into from
Jan 3, 2019

Conversation

lukpueh
Copy link
Member

@lukpueh lukpueh commented Jan 3, 2019

Fixes issue #:
Mostly fixes #9

Description of the changes being introduced by the pull request:
Refactor test_intoto.py mock installation scaffolding for easier testing of different scenarios, i.e. with passing and failing (for different reasons) in-toto verification.

Add additional unit tests test_units.py to cover cases that are not feasible to be tested in the course of above mock installation.

Please verify and check that the pull request fulfills the following
requirements
:

  • The code follows the Code Style Guidelines
  • Tests have been added for the bug fix or new feature
  • Docs have been added for the bug fix or new feature

Refactor test_intoto.py to provide a better scaffolding for tests
that mock the routines triggered by `apt-get install`.

And add multiple tests that mock `apt-get install` with different
parameters and thus different results.
We can include coverage for __main__ because the intoto transport
is tested as program (in a subprocess).
Huge parts of the in-toto transport are tested in tests_intoto.py
by mocking the entire installation routines. For some special
cases, especially error handling it is not feasible to test them
in the course of an entire installation. Those are covered in
unit tests added with this commit.

This commit also adds to small fixes:
 - Error handling in message deserialization (log level)
 - Remove trailing whitespace in error message.
Add no cover pragmas to lines, where testing is not feasible and
also not relevant.
Change dummy inspection /usr/bin/true to true and hope that
the executing shell has it on the path, to fix travis error:
  In-toto verification for
  '[stripped]/final-product_0.0.0.0-0_all.deb' failed, reason was:
   [Errno 2] No such file or directory: u'/usr/bin/true'

See https://github.com/in-toto/in-toto/issues/247 for discussion
about dummy inspections.
@lukpueh lukpueh merged commit 40aeb95 into in-toto:develop Jan 3, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add more comprehensive tests that work with online and offline tests
1 participant