Prior to this change, CLI usage was hardcoded into the config opt
fixture used for all tests. That CLI usage described two required
positional arguments that were not actually part of the argument parser
(FOO and BAR), but were instead just made up to have a valid-looking
usage description.
The trouble is that you can't then extend that argument parser with
additional real arguments, and then test the configuration of those
arguments by inspecting the *real* usage and --help output from
argparse. For example, a unit test could not assert whether argparse was
configured correctly by oslo.config, because there's simply no way to
know when the usage was just statically set to the arbitrary values of
"FOO BAR."
This patch moves that specific unit test coverage (overriding usage with
something arbitrary) into a dedicated unit test, while removing the
arbitrary usage from all other unit tests. Instead, those unit tests now
make assertions against the argparser's real configuration, hence
options like --config-dir and --config-file now appear in those tests,
because those options are included in every instance of
cfg.ConfigOpts().
Reviewed: https:/ /review. opendev. org/451933 /git.openstack. org/cgit/ openstack/ oslo.config/ commit/ ?id=ec84eeda526 adc20dcabdf6e70 4958cc06773dd3
Committed: https:/
Submitter: Zuul
Branch: master
commit ec84eeda526adc2 0dcabdf6e704958 cc06773dd3
Author: Dolph Mathews <email address hidden>
Date: Thu Mar 30 17:56:13 2017 +0000
Refactor unit tests for CLI usage
Prior to this change, CLI usage was hardcoded into the config opt
fixture used for all tests. That CLI usage described two required
positional arguments that were not actually part of the argument parser
(FOO and BAR), but were instead just made up to have a valid-looking
usage description.
The trouble is that you can't then extend that argument parser with
additional real arguments, and then test the configuration of those
arguments by inspecting the *real* usage and --help output from
argparse. For example, a unit test could not assert whether argparse was
configured correctly by oslo.config, because there's simply no way to
know when the usage was just statically set to the arbitrary values of
"FOO BAR."
This patch moves that specific unit test coverage (overriding usage with ConfigOpts( ).
something arbitrary) into a dedicated unit test, while removing the
arbitrary usage from all other unit tests. Instead, those unit tests now
make assertions against the argparser's real configuration, hence
options like --config-dir and --config-file now appear in those tests,
because those options are included in every instance of
cfg.
Change-Id: I54ba989768d074 a5f24897299c85b d35fa1cbd1a
Related-Bug: 1676989