Commit Graph
5 Commits
Author SHA1 Message Date
William Douglas 54636b48dd Refactor the config into a class
The config module had a large amount of globals that were being
touched across many modules that would import. This made changes to
config very fragile as figuring out what would be modified in any
given call chain was difficult to diagnose.

It also made testing fragile as one would need to reset a given
module's config import to the best of their knowledge before rerunning
another test.

To get away from that (and to try and reduce the number of globally
modified variablies in autospec as a whole), refactor the config
module to provide its state as part config class. The long running
goal of changes like this is to better track what content can be
updated by a particular function (if a function would have access
to the config instance is now the hint rather than the config module
getting imported).
2020-03-24 18:05:27 -07:00
Patrick McCarty e5bf1b99b7 tests: fix up mocks for open_auto() use
Signed-off-by: Patrick McCarty <patrick.mccarty@intel.com>
2019-06-24 13:08:39 -07:00
Matthew Johnson f8eb22b8f1 Update unit tests for latest changes
Some changes have recently been pushed to autospec sources without
updating the unit tests. This patch brings the unit tests up-to-date
again.

test_build.py: Remove go buildtool bits (was deprecated)
test_specdescription.py: Newline added to post-scripts
test_specfile.py: Reset license_translations dict
files.py: Check dict with get() in case of missing key
2017-07-12 08:46:47 -07:00
Matthew Johnson a1f13af7ab Clean up specdescription module
Clean up the specdescription module, including resolving two bugs and
making the code more readable and more robust.

BUGS:

- description_from_pkginfo

  A string was checked for a substring using the string.find() method
  but was treated as a boolean, assuming that find() returned 0 when the
  substring was not found. This was causing a section end to be
  immediately detected and the section was not parsed. The call was
  replaced with the `in` keyword.

- description_from_spec

  The default description was overwritten regardless of whether the
  detected description had any content. A check was added to only
  overwrite the default if there was a detected description.

Other general cleanup:

- Remove unused default_group global
- Remove unused argument in summary_from_R
- Add assign_summary/description methods to reduce global usage and
  reduce code repetition
- Add function docstrings
- Convert to `with open()` blocks when working with files instead of
  explicitly handling closing the files
- Wrap open() calls in try...catch blocks
2017-07-07 14:54:42 -07:00
Matthew Johnson e8efee61dc Add unit tests for the specdescription module
Unit tests added for the specdescription module. At the time of this
commit, there are two failing tests due to bugs in the module.

Failures:

- test_description_from_pkginfo

  This test fails because a string.find() method is checked as a boolean
  as if find returned 0 if the substring was not present. find()
  actually returns -1 in this case. Because find() was being used as a
  guard to find the end of a section, the end was found immediately and
  the section was not parsed.

- test_description_from_spec_no_info

  This test fails due to the default description being overridden, even
  when the override is just an empty string.
2017-07-07 12:34:30 -07:00