Improve tests and other refactorings - #369
Merged
Merged
Conversation
* format and streamline test code * move all used test files to /testdata/test_util dir * add more tests for loading mappings * update util code accordingly Signed-off-by: Philippe Ombredanne <pombredanne@nexb.com>
Signed-off-by: Philippe Ombredanne <pombredanne@nexb.com>
Signed-off-by: Philippe Ombredanne <pombredanne@nexb.com>
* add docstrings * mionr variable renaming * split tests finctions Signed-off-by: Philippe Ombredanne <pombredanne@nexb.com>
* add more template tests for corner cases * add validation for all builtin templates Signed-off-by: Philippe Ombredanne <pombredanne@nexb.com>
Signed-off-by: Philippe Ombredanne <pombredanne@nexb.com>
Signed-off-by: Philippe Ombredanne <pombredanne@nexb.com>
* remove unused test files * move test files under tesdata/test_attrib streamline test code Signed-off-by: Philippe Ombredanne <pombredanne@nexb.com>
* and other minor formattings Signed-off-by: Philippe Ombredanne <pombredanne@nexb.com>
Also do some minor cosmetic refactoring Signed-off-by: Philippe Ombredanne <pombredanne@nexb.com>
* this may not get the right results on Windows * also improve the usage of default_template Signed-off-by: Philippe Ombredanne <pombredanne@nexb.com>
Signed-off-by: Philippe Ombredanne <pombredanne@nexb.com>
Signed-off-by: Philippe Ombredanne <pombredanne@nexb.com>
Signed-off-by: Philippe Ombredanne <pombredanne@nexb.com>
Signed-off-by: Philippe Ombredanne <pombredanne@nexb.com>
Signed-off-by: Philippe Ombredanne <pombredanne@nexb.com>
Signed-off-by: Philippe Ombredanne <pombredanne@nexb.com>
Mapping can now only be used when using a CSV as an input. Signed-off-by: Philippe Ombredanne <pombredanne@nexb.com>
* Review and edit all command line option definitions * Remove AboutCommand since Click bug is now fixed * Implement cnsistently --quiet contract * Update and rename common error and error logging functions * Return proper exit code on errors #362 * Rename attrib --vartext option to --variable and add validation callback and parsing function * Add validation callback to inventory --filter option Signed-off-by: Philippe Ombredanne <pombredanne@nexb.com>
* Update attrib.generate function to return an Error and the generated text to simplify error handling in the cmd module * Rename attrib.generate function args template_string to template and vartest to variables. Use variables everywhere too. * Move variables parsing and validatio to the cmd module * Remove any reference to mapping_output: Mapping can now only be used when using a CSV input. * JSON outputs can no longer use mappings * Remove use_mapping everywhere and use only mapping_file instead. mapping_file is either a builtin or custom mapping file. * add validation to every commands to avoid the combo of --mapping and --mapping-file that are mutually exclusive. * use click.UsageError for cmd validation * DEFAULT_MAPPING is now top level constant for the default mapping config file location * Improve docstrings * validate template early in cmd.attrib Signed-off-by: Philippe Ombredanne <pombredanne@nexb.com>
Signed-off-by: Philippe Ombredanne <pombredanne@nexb.com>
Signed-off-by: Philippe Ombredanne <pombredanne@nexb.com>
* also streamine test code for testing errors Signed-off-by: Philippe Ombredanne <pombredanne@nexb.com>
Signed-off-by: Philippe Ombredanne <pombredanne@nexb.com>
Signed-off-by: Philippe Ombredanne <pombredanne@nexb.com>
* Also add todo and remove dead code Signed-off-by: Philippe Ombredanne <pombredanne@nexb.com>
* remove unused test files and functions * update or remove failing tests * move test files under their own dir for each test_XXX module * update and correct all expectedFailure Signed-off-by: Philippe Ombredanne <pombredanne@nexb.com>
Signed-off-by: Philippe Ombredanne <pombredanne@nexb.com>
Signed-off-by: Philippe Ombredanne <pombredanne@nexb.com>
Signed-off-by: Philippe Ombredanne <pombredanne@nexb.com>
Signed-off-by: Philippe Ombredanne <pombredanne@nexb.com>
Signed-off-by: Philippe Ombredanne <pombredanne@nexb.com>
This is to avoid CRLF issues difference on multiple OSes Signed-off-by: Philippe Ombredanne <pombredanne@nexb.com>
Signed-off-by: Philippe Ombredanne <pombredanne@nexb.com>
Signed-off-by: Philippe Ombredanne <pombredanne@nexb.com>
* minimal tests for attrib, inventory and gen * update the code accordingly Signed-off-by: Philippe Ombredanne <pombredanne@nexb.com>
* Rename gen --license-notice-text-location to --reference * Renamere license_notice_text_location arg and variable name to reference_dir everywhere. * Update and refine the command help help for the gen subcommand. Signed-off-by: Philippe Ombredanne <pombredanne@nexb.com>
* rename cmd.cli() to cmd.about() * Use a common validation callback function for --mapping and --mapping-file options * Streamline and standardize help text and METAVAR usage * Standardize option definitions in particular for Path options Signed-off-by: Philippe Ombredanne <pombredanne@nexb.com>
Signed-off-by: Philippe Ombredanne <pombredanne@nexb.com>
Signed-off-by: Philippe Ombredanne <pombredanne@nexb.com>
Signed-off-by: Philippe Ombredanne <pombredanne@nexb.com>
* The goal of this would be to replace entirely the mapping feature and options. Signed-off-by: Philippe Ombredanne <pombredanne@nexb.com>
Signed-off-by: Philippe Ombredanne <pombredanne@nexb.com>
Signed-off-by: Philippe Ombredanne <pombredanne@nexb.com>
Use new saneyaml library
Add new CSV transform subcommand #361
Signed-off-by: Philippe Ombredanne <pombredanne@nexb.com>
Signed-off-by: Philippe Ombredanne <pombredanne@nexb.com>
Signed-off-by: Philippe Ombredanne <pombredanne@nexb.com>
Signed-off-by: Philippe Ombredanne <pombredanne@nexb.com>
* Monkey patch backports.csv to use OrderedDict and remove OrderedDictReader * Remove unused funtion check_duplicate_keys_about_file Signed-off-by: Philippe Ombredanne <pombredanne@nexb.com>
pombredanne
force-pushed
the
test-cleanup
branch
from
November 21, 2018 11:25
3d6be17 to
49d82f6
Compare
* These unused methods and functions have been removed and their tests updated or removed accordingly: - AboutResourceField.resolve() - About.attribution_fields() - About.same_attribution() - About.resolved_resources_paths() - parse() and its pre-compiled regex - by_license() - by_name() - by_license_content() - verify_license_files_in_location() Signed-off-by: Philippe Ombredanne <pombredanne@nexb.com>
Signed-off-by: Philippe Ombredanne <pombredanne@nexb.com>
Signed-off-by: Philippe Ombredanne <pombredanne@nexb.com>
pombredanne
force-pushed
the
test-cleanup
branch
from
November 21, 2018 11:32
49d82f6 to
b3ed23f
Compare
Member
Author
|
All green and merging in develop after a chat with @chinyeungli |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR started with a focus on tests enhancements but does a few more things.
The test code has been streamlined and updated. In particular:
testdata/test_xxxdirectory.expectedFailureandFAILING_test_xxxtests have been either removed or updates except for one test that does live API call and is marked as skipped for now.Command line module has been streamlined and updated:
cmd.cli()has been renamed tocmd.about()<OUTPUT>-error.logsuch that each command creates a mostly unique error log filename.parse_key_valuesfunction is used to parse options that contain key=value such as --filteruse_mappingandmapping_filevariables and processing code common to many functions has been updated. Early in subcommands, the--mappingand--mapping-fileoptions are evaluated. They are mutually exclusive options and a check is now done early and an error is returned if both options are used. Then the proper mapping file is used and passed around to functions as a single and optionalmapping_fileargument.inventorysubcommand:--filteroption parsing has been streamlined and this option is now validated early.attribsubcommand:Errorobjects on failure like other functions elsewhere.--mapping-outputoption has been removed. Mapping cannot be applied on outputs Using mapping of keys should be limited only to CSV #361--vartextoption code has been streamlined and this option is now validated early. Internally it has been renamed to variable. How to make the Title of a generated Attribution file a variable #332gen subcommand:
--license-notice-text-locationoption has been renamed to--referenceRename gen --license-notice-text-location #367Other:
u''unicodestring prefixes have been removed when not needed.TODO:andFIXME:comments have been added as reminders.utilmodule has been refactored and updated. Some shared functions have been moved there and non-shared functions moved out where they are used.NOQAandpragma: nocovercomment tags have been added toward future coverage and code style validation