Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added a
sudo
argument to method cli.Client.run
to avoid boilerplate.
As part of our `less boilerplate` effort I added a new method `sudo` argument to `cli.Client.run`. In a lot of test cases there are code like: ```python sudo = () if cli.is_root(cfg) else ('sudo',) ... client.run(sudo + ('command_name', 'argument1', ...)) ``` The idea is to replace the above boilerplate with ```python client.run(('command_name', 'argument1', ...), sudo=True) ``` With this change we will be able to remove the `sudo = () if cli.is_root(cfg) else ('sudo',)` boilerplate in those Pulp-2-tests referenced: ```bash pulp_2_tests/tests/docker/utils.py: sudo = '' if cli.is_root(cfg) else 'sudo' pulp_2_tests/tests/puppet/api_v2/test_install_distributor.py: sudo = () if cli.is_root(self.cfg) else ('sudo',) pulp_2_tests/tests/rpm/api_v2/test_content_sources.py: sudo = () if cli.is_root(cls.cfg) else ('sudo',) pulp_2_tests/tests/rpm/api_v2/test_content_sources.py: sudo = () if cli.is_root(cls.cfg) else ('sudo',) pulp_2_tests/tests/rpm/api_v2/test_content_sources.py: sudo = '' if cli.is_root(cfg) else 'sudo' pulp_2_tests/tests/rpm/api_v2/test_crud.py: sudo = () if cli.is_root(self.cfg) else ('sudo',) pulp_2_tests/tests/rpm/api_v2/test_download_policies.py: sudo = '' if cli.is_root(cls.cfg) else 'sudo ' pulp_2_tests/tests/rpm/api_v2/test_errata.py: # sudo = () if cli.is_root(cfg) else ('sudo',) pulp_2_tests/tests/rpm/api_v2/test_errata.py: sudo = () if cli.is_root(cfg) else ('sudo',) pulp_2_tests/tests/rpm/api_v2/test_export.py: self.__sudo = None pulp_2_tests/tests/rpm/api_v2/test_export.py: self.__sudo = '' if cli.is_root(self.cfg) else 'sudo ' pulp_2_tests/tests/rpm/api_v2/test_iso_sync_publish.py: sudo = () if cli.is_root(self.cfg) else ('sudo',) pulp_2_tests/tests/rpm/api_v2/test_modularity.py: sudo = () if cli.is_root(cfg) else ('sudo',) pulp_2_tests/tests/rpm/api_v2/test_republish.py: sudo = () if cli.is_root(self.cfg) else ('sudo',) pulp_2_tests/tests/rpm/api_v2/test_rich_weak_dependencies.py: sudo = () if cli.is_root(cfg) else ('sudo',) pulp_2_tests/tests/rpm/api_v2/test_rsync_distributor.py: sudo = () if cli.is_root(cfg) else ('sudo',) pulp_2_tests/tests/rpm/api_v2/test_rsync_distributor.py: sudo = () if cli.is_root(cfg) else ('sudo',) pulp_2_tests/tests/rpm/api_v2/test_rsync_distributor.py: sudo = '' if cli.is_root(cfg) else 'sudo ' pulp_2_tests/tests/rpm/api_v2/test_service_resiliency.py: sudo = '' if cli.is_root(self.cfg) else 'sudo' pulp_2_tests/tests/rpm/api_v2/test_service_resiliency.py: sudo = () if cli.is_root(self.cfg) else ('sudo',) pulp_2_tests/tests/rpm/api_v2/utils.py: sudo = '' if cli.is_root(cfg) else 'sudo ' pulp_2_tests/tests/rpm/api_v2/utils.py: sudo = '' if cli.is_root(cfg) else 'sudo ' pulp_2_tests/tests/rpm/api_v2/utils.py: sudo = () if cli.is_root(cfg) else ('sudo',) pulp_2_tests/tests/rpm/api_v2/utils.py: sudo = '' if cli.is_root(cfg) else 'sudo ' pulp_2_tests/tests/rpm/api_v2/utils.py: sudo = () if cli.is_root(cfg) else ('sudo',) pulp_2_tests/tests/rpm/cli/test_copy_units.py: sudo = () if cli.is_root(cfg) else ('sudo',) pulp_2_tests/tests/rpm/cli/test_process_recycling.py: sudo = () if cli.is_root(cfg) else ('sudo',) pulp_2_tests/tests/rpm/cli/test_process_recycling.py: sudo = () if cli.is_root(cfg) else ('sudo',) ```