12ba1306a7
Til now, the main() function of the script did all the input/output logic of reading in the openstack_inventory.json file and creating the backup files after multiple runs. While this is functional, it makes elements of the script hard to test. Either files have to be written to the file system during tests, which means they must be cleaned up correctly, or very invasive mocking has to be done at a high level to test other interactions. This change moves the creation of the tar backup and the loading of the openstack_inventory.json file into their own functions that can be mocked in future tests. Because of their nature, testing of these two functions is being done with invasive mocks to provide a starting point in extracting actual filesystem I/O from happening unless explicitly planned for. With this, future tests could provide mocked versions of make_backup that are essentially no-ops, and provide smaller, more customized structures via a mocked get_inventory. Such future changes could then remove the manipulation of symlinks to etc/openstack_deploy/openstack_user_config.yml. Also, this extraction means the implementations could be overriden to provide different sources and storage, though this is not as robust as a fully extensible system such as plugins. The get_backup_name function was created as an easier mocking point, since the mock module does not allow for replacing builtin Python types, which include datetime. While specific datetime manipulation libraries do exist, they were not included here in order to reduce the scope of changes and external dependencies. Change-Id: I4bd2a0d06366844b2a60e29cc9c5481903ada4e2
17 lines
376 B
Plaintext
17 lines
376 B
Plaintext
ansible>1.9,<2.0,!=1.9.6
|
|
ansible-lint>=2.0.3,<=2.3.6
|
|
bashate==0.5.0 # Apache-2.0
|
|
coverage<=4.0.3 # Apache-2.0
|
|
flake8==2.2.4
|
|
hacking>=0.10.0,<0.11
|
|
mccabe==0.2.1 # capped for flake8
|
|
mock == 2.0.0
|
|
pep8==1.5.7
|
|
pyflakes==0.8.1
|
|
virtualenv>=14.0.0
|
|
|
|
# this is required for the docs build jobs
|
|
sphinx!=1.2.0,!=1.3b1,<1.3,>=1.1.2
|
|
oslosphinx>=2.5.0 # Apache-2.0
|
|
reno>=0.1.1 # Apache-2.0
|