Browse Source

Fix pep8 lint for unit tests

changes/53/712253/1
Mathieu Bultel 2 years ago
parent
commit
f8874cdd5f
  1. 21
      validations_libs/tests/test_ansible.py
  2. 14
      validations_libs/tests/test_validations_run.py

21
validations_libs/tests/test_ansible.py

@ -24,7 +24,6 @@ from validations_libs import utils
class TestAnsible(TestCase):
def setUp(self):
super(TestAnsible, self).setUp()
self.unlink_patch = mock.patch('os.unlink')
@ -45,7 +44,6 @@ class TestAnsible(TestCase):
)
mock_exists.assert_called_with('/tmp/non-existing.yaml')
@mock.patch('tempfile.mkdtemp', return_value='/tmp/')
@mock.patch('os.path.exists', return_value=True)
@mock.patch('os.makedirs')
@ -64,17 +62,16 @@ class TestAnsible(TestCase):
mock_mkdtemp):
stdout_file, _playbook, _rc, _status = self.run.run('existing.yaml',
'localhost,',
'/tmp')
'localhost,',
'/tmp')
self.assertEquals((_playbook, _rc, _status),
('existing.yaml', 1, 'failed'))
@mock.patch('tempfile.mkdtemp', return_value='/tmp/')
@mock.patch('os.path.exists', return_value=True)
@mock.patch('os.makedirs')
@mock.patch.object(Runner,'run',
return_value=fakes.fake_ansible_runner_run_return(rc=0)
@mock.patch.object(Runner, 'run',
return_value=fakes.fake_ansible_runner_run_return(rc=0)
)
@mock.patch('ansible_runner.utils.dump_artifact', autospec=True,
return_value="/foo/inventory.yaml")
@ -91,12 +88,11 @@ class TestAnsible(TestCase):
self.assertEquals((_playbook, _rc, _status),
('existing.yaml', 0, 'successful'))
@mock.patch('tempfile.mkdtemp', return_value='/tmp/')
@mock.patch('os.path.exists', return_value=True)
@mock.patch('os.makedirs')
@mock.patch.object(Runner,'run',
return_value=fakes.fake_ansible_runner_run_return(rc=0)
@mock.patch.object(Runner, 'run',
return_value=fakes.fake_ansible_runner_run_return(rc=0)
)
@mock.patch('ansible_runner.utils.dump_artifact', autospec=True,
return_value="/foo/inventory.yaml")
@ -116,12 +112,11 @@ class TestAnsible(TestCase):
self.assertEquals((_playbook, _rc, _status),
('existing.yaml', 0, 'successful'))
@mock.patch('tempfile.mkdtemp', return_value='/tmp/')
@mock.patch('os.path.exists', return_value=True)
@mock.patch('os.makedirs')
@mock.patch.object(Runner,'run',
return_value=fakes.fake_ansible_runner_run_return(rc=0)
@mock.patch.object(Runner, 'run',
return_value=fakes.fake_ansible_runner_run_return(rc=0)
)
@mock.patch('ansible_runner.utils.dump_artifact', autospec=True,
return_value="/foo/inventory.yaml")

14
validations_libs/tests/test_validations_run.py

@ -40,9 +40,9 @@ class TestValidatorRun(TestCase):
expected_run_return = [
{'validation': {'playbook': 'foo.yaml',
'rc_code': 0,
'status': 'successful',
'stdout_file': '/tmp/validation/stdout.log'}}]
'rc_code': 0,
'status': 'successful',
'stdout_file': '/tmp/validation/stdout.log'}}]
playbook = ['fake.yaml']
inventory = 'tmp/inventory.yaml'
@ -56,7 +56,7 @@ class TestValidatorRun(TestCase):
@mock.patch('validations_libs.utils.parse_all_validations_on_disk')
@mock.patch('validations_libs.ansible.Ansible.run')
def test_validation_run_failed(self, mock_ansible_run,
mock_validation_dir):
mock_validation_dir):
mock_validation_dir.return_value = [{
'description': 'My Validation One Description',
'groups': ['prep', 'pre-deployment'],
@ -68,9 +68,9 @@ class TestValidatorRun(TestCase):
expected_run_return = [
{'validation': {'playbook': 'foo.yaml',
'rc_code': 0,
'status': 'failed',
'stdout_file': '/tmp/validation/stdout.log'}}]
'rc_code': 0,
'status': 'failed',
'stdout_file': '/tmp/validation/stdout.log'}}]
playbook = ['fake.yaml']
inventory = 'tmp/inventory.yaml'

Loading…
Cancel
Save