Browse Source

Merge "Deprecated assertEquals replaced"

changes/31/794731/1
Zuul 1 week ago
committed by Gerrit Code Review
parent
commit
a3959e7e59
6 changed files with 109 additions and 104 deletions
  1. +6
    -6
      validations_libs/tests/cli/test_colors.py
  2. +10
    -10
      validations_libs/tests/test_ansible.py
  3. +3
    -3
      validations_libs/tests/test_group.py
  4. +10
    -10
      validations_libs/tests/test_validation.py
  5. +34
    -33
      validations_libs/tests/test_validation_log.py
  6. +46
    -42
      validations_libs/tests/test_validation_logs.py

+ 6
- 6
validations_libs/tests/cli/test_colors.py View File

@ -50,19 +50,19 @@ class TestColors(TestCase):
color = self.status_color[status]
colored_output = colors.color_output("fizz", status=status)
#Checking reset color
self.assertEquals(colored_output[-6:], '\033[0;0m')
self.assertEqual(colored_output[-6:], '\033[0;0m')
#Checking output color
self.assertEquals(colored_output[:len(color)], color)
self.assertEqual(colored_output[:len(color)], color)
#Checking output string
self.assertEquals(colored_output[len(color):][:4], "fizz")
self.assertEqual(colored_output[len(color):][:4], "fizz")
def test_format_unknown_status(self):
color = self.status_color['UNKNOWN']
colored_output = colors.color_output("buzz")
#Checking reset color
self.assertEquals(colored_output[-6:], '\033[0;0m')
self.assertEqual(colored_output[-6:], '\033[0;0m')
#Checking output color
self.assertEquals(colored_output[:len(color)], color)
self.assertEqual(colored_output[:len(color)], color)
#Checking output string
self.assertEquals(colored_output[len(color):][:4], "buzz")
self.assertEqual(colored_output[len(color):][:4], "buzz")

+ 10
- 10
validations_libs/tests/test_ansible.py View File

@ -216,8 +216,8 @@ class TestAnsible(TestCase):
_playbook, _rc, _status = self.run.run('existing.yaml',
'localhost,',
'/tmp')
self.assertEquals((_playbook, _rc, _status),
('existing.yaml', 1, 'failed'))
self.assertEqual((_playbook, _rc, _status),
('existing.yaml', 1, 'failed'))
@mock.patch('six.moves.builtins.open')
@mock.patch('os.path.exists', return_value=True)
@ -235,8 +235,8 @@ class TestAnsible(TestCase):
inventory='localhost,',
workdir='/tmp'
)
self.assertEquals((_playbook, _rc, _status),
('existing.yaml', 0, 'successful'))
self.assertEqual((_playbook, _rc, _status),
('existing.yaml', 0, 'successful'))
@mock.patch('six.moves.builtins.open')
@mock.patch('os.path.exists', return_value=True)
@ -257,8 +257,8 @@ class TestAnsible(TestCase):
connection='local',
gathering_policy='smart'
)
self.assertEquals((_playbook, _rc, _status),
('existing.yaml', 0, 'successful'))
self.assertEqual((_playbook, _rc, _status),
('existing.yaml', 0, 'successful'))
@mock.patch('os.path.exists', return_value=True)
@mock.patch('os.makedirs')
@ -278,8 +278,8 @@ class TestAnsible(TestCase):
workdir='/tmp',
connection='local'
)
self.assertEquals((_playbook, _rc, _status),
('existing.yaml', 0, 'successful'))
self.assertEqual((_playbook, _rc, _status),
('existing.yaml', 0, 'successful'))
@mock.patch('os.path.exists', return_value=True)
@mock.patch('os.makedirs')
@ -300,8 +300,8 @@ class TestAnsible(TestCase):
connection='local',
run_async=True
)
self.assertEquals((_playbook, _rc, _status),
('existing.yaml', None, 'unstarted'))
self.assertEqual((_playbook, _rc, _status),
('existing.yaml', None, 'unstarted'))
@mock.patch('six.moves.builtins.open')
@mock.patch('os.path.exists', return_value=True)


+ 3
- 3
validations_libs/tests/test_group.py View File

@ -33,7 +33,7 @@ class TestGroup(TestCase):
def test_get_data(self, mock_open, mock_yaml):
grp = Group('/tmp/foo')
data = grp.get_data
self.assertEquals(data, fakes.GROUP)
self.assertEqual(data, fakes.GROUP)
@mock.patch('yaml.safe_load', return_value=fakes.GROUP)
@mock.patch('six.moves.builtins.open')
@ -41,7 +41,7 @@ class TestGroup(TestCase):
grp = Group('/tmp/foo')
ret = [('no-op', 'noop-foo'), ('post', 'post-foo'), ('pre', 'pre-foo')]
data = grp.get_formated_group
self.assertEquals(data, ret)
self.assertEqual(data, ret)
@mock.patch('yaml.safe_load', return_value=fakes.GROUP)
@mock.patch('six.moves.builtins.open')
@ -49,7 +49,7 @@ class TestGroup(TestCase):
grp = Group('/tmp/foo')
ret = ['no-op', 'post', 'pre']
data = grp.get_groups_keys_list
self.assertEquals(data, ret)
self.assertEqual(data, ret)
@mock.patch('six.moves.builtins.open')
def test_group_file_not_found(self, mock_open):


+ 10
- 10
validations_libs/tests/test_validation.py View File

@ -33,14 +33,14 @@ class TestValidation(TestCase):
def test_get_data(self, mock_open, mock_yaml):
val = Validation('/tmp/foo')
data = val.get_data
self.assertEquals(data, fakes.FAKE_PLAYBOOK[0])
self.assertEqual(data, fakes.FAKE_PLAYBOOK[0])
@mock.patch('yaml.safe_load', return_value=fakes.FAKE_PLAYBOOK)
@mock.patch('six.moves.builtins.open')
def test_get_metadata(self, mock_open, mock_yaml):
val = Validation('/tmp/foo')
data = val.get_metadata
self.assertEquals(data, fakes.FAKE_METADATA)
self.assertEqual(data, fakes.FAKE_METADATA)
@mock.patch('yaml.safe_load', return_value=fakes.FAKE_WRONG_PLAYBOOK)
@mock.patch('six.moves.builtins.open')
@ -55,14 +55,14 @@ class TestValidation(TestCase):
def test_get_vars(self, mock_open, mock_yaml):
val = Validation('/tmp/foo')
data = val.get_vars
self.assertEquals(data, fakes.FAKE_VARS)
self.assertEqual(data, fakes.FAKE_VARS)
@mock.patch('yaml.safe_load', return_value=fakes.FAKE_PLAYBOOK)
@mock.patch('six.moves.builtins.open')
def test_get_vars_no_vars(self, mock_open, mock_yaml):
val = Validation('/tmp/foo')
data = val.get_vars
self.assertEquals(data, {})
self.assertEqual(data, {})
@mock.patch('yaml.safe_load', return_value=fakes.FAKE_WRONG_PLAYBOOK)
@mock.patch('six.moves.builtins.open')
@ -78,15 +78,15 @@ class TestValidation(TestCase):
val = Validation('/tmp/foo')
id = val.id
get_id = val.get_id
self.assertEquals(id, 'foo')
self.assertEquals(get_id, 'foo')
self.assertEqual(id, 'foo')
self.assertEqual(get_id, 'foo')
@mock.patch('yaml.safe_load', return_value=fakes.FAKE_PLAYBOOK)
@mock.patch('six.moves.builtins.open')
def test_groups(self, mock_open, mock_yaml):
val = Validation('/tmp/foo')
groups = val.groups
self.assertEquals(groups, ['prep', 'pre-deployment'])
self.assertEqual(groups, ['prep', 'pre-deployment'])
@mock.patch('yaml.safe_load', return_value=fakes.FAKE_WRONG_PLAYBOOK)
@mock.patch('six.moves.builtins.open')
@ -101,21 +101,21 @@ class TestValidation(TestCase):
def test_groups_with_no_existing_groups(self, mock_open, mock_yaml):
val = Validation('/tmp/foo')
groups = val.groups
self.assertEquals(groups, [])
self.assertEqual(groups, [])
@mock.patch('yaml.safe_load', return_value=fakes.FAKE_PLAYBOOK)
@mock.patch('six.moves.builtins.open')
def test_get_ordered_dict(self, mock_open, mock_yaml):
val = Validation('/tmp/foo')
data = val.get_ordered_dict
self.assertEquals(data, fakes.FAKE_PLAYBOOK[0])
self.assertEqual(data, fakes.FAKE_PLAYBOOK[0])
@mock.patch('yaml.safe_load', return_value=fakes.FAKE_PLAYBOOK)
@mock.patch('six.moves.builtins.open')
def test_get_formated_data(self, mock_open, mock_yaml):
val = Validation('/tmp/foo')
data = val.get_formated_data
self.assertEquals(data, fakes.FORMATED_DATA)
self.assertEqual(data, fakes.FORMATED_DATA)
@mock.patch('yaml.safe_load', return_value=fakes.FAKE_WRONG_PLAYBOOK)
@mock.patch('six.moves.builtins.open')


+ 34
- 33
validations_libs/tests/test_validation_log.py View File

@ -33,9 +33,9 @@ class TestValidationLog(TestCase):
def test_validation_log_file(self, mock_open, mock_json):
val = ValidationLog(
logfile='/tmp/123_foo_2020-03-30T13:17:22.447857Z.json')
self.assertEquals(val.uuid, '123')
self.assertEquals(val.validation_id, 'foo')
self.assertEquals(val.datetime, '2020-03-30T13:17:22.447857Z')
self.assertEqual(val.uuid, '123')
self.assertEqual(val.validation_id, 'foo')
self.assertEqual(val.datetime, '2020-03-30T13:17:22.447857Z')
@mock.patch('json.load')
@mock.patch('six.moves.builtins.open')
@ -60,9 +60,9 @@ class TestValidationLog(TestCase):
def test_validation_underscore_validation_id(self, mock_open, mock_json):
val = ValidationLog(
logfile='/tmp/123_foo_bar_2020-03-30T13:17:22.447857Z.json')
self.assertEquals(val.uuid, '123')
self.assertEquals(val.validation_id, 'foo_bar')
self.assertEquals(val.datetime, '2020-03-30T13:17:22.447857Z')
self.assertEqual(val.uuid, '123')
self.assertEqual(val.validation_id, 'foo_bar')
self.assertEqual(val.datetime, '2020-03-30T13:17:22.447857Z')
@mock.patch('json.load')
@mock.patch('six.moves.builtins.open')
@ -83,8 +83,8 @@ class TestValidationLog(TestCase):
['/tmp/123_foo_2020-03-30T13:17:22.447857Z.json']
val = ValidationLog(uuid='123', validation_id='foo', log_path='/tmp')
path = val.get_log_path()
self.assertEquals(path,
'/tmp/123_foo_2020-03-30T13:17:22.447857Z.json')
self.assertEqual(path,
'/tmp/123_foo_2020-03-30T13:17:22.447857Z.json')
@mock.patch('glob.glob')
@mock.patch('json.load')
@ -94,8 +94,8 @@ class TestValidationLog(TestCase):
['/tmp/123_foo_2020-03-30T13:17:22.447857Z.json']
val = ValidationLog(uuid='123', validation_id='foo', log_path='/tmp')
log_info = val.get_logfile_infos
self.assertEquals(log_info,
['123', 'foo', '2020-03-30T13:17:22.447857Z'])
self.assertEqual(log_info,
['123', 'foo', '2020-03-30T13:17:22.447857Z'])
@mock.patch('glob.glob')
@mock.patch('json.load')
@ -105,7 +105,7 @@ class TestValidationLog(TestCase):
['/tmp/123_foo_2020-03-30T13:17:22.447857Z.json']
val = ValidationLog(uuid='123', validation_id='foo', log_path='/tmp')
datetime = val.get_logfile_datetime
self.assertEquals(datetime, '2020-03-30T13:17:22.447857Z')
self.assertEqual(datetime, '2020-03-30T13:17:22.447857Z')
@mock.patch('json.load', return_value=fakes.VALIDATIONS_LOGS_CONTENTS_LIST)
@mock.patch('six.moves.builtins.open')
@ -113,7 +113,7 @@ class TestValidationLog(TestCase):
val = ValidationLog(
logfile='/tmp/123_foo_2020-03-30T13:17:22.447857Z.json')
content = val.get_logfile_content
self.assertEquals(content, fakes.VALIDATIONS_LOGS_CONTENTS_LIST)
self.assertEqual(content, fakes.VALIDATIONS_LOGS_CONTENTS_LIST)
@mock.patch('json.load',
return_value=fakes.VALIDATIONS_LOGS_CONTENTS_LIST[0])
@ -122,8 +122,8 @@ class TestValidationLog(TestCase):
val = ValidationLog(
logfile='/tmp/123_foo_2020-03-30T13:17:22.447857Z.json')
uuid = val.get_uuid
self.assertEquals(uuid, '123')
self.assertEquals(val.uuid, '123')
self.assertEqual(uuid, '123')
self.assertEqual(val.uuid, '123')
@mock.patch('json.load',
return_value=fakes.VALIDATIONS_LOGS_CONTENTS_LIST[0])
@ -132,8 +132,8 @@ class TestValidationLog(TestCase):
val = ValidationLog(
logfile='/tmp/123_foo_2020-03-30T13:17:22.447857Z.json')
validation_id = val.get_validation_id
self.assertEquals(validation_id, 'foo')
self.assertEquals(val.validation_id, 'foo')
self.assertEqual(validation_id, 'foo')
self.assertEqual(val.validation_id, 'foo')
@mock.patch('json.load',
return_value=fakes.VALIDATIONS_LOGS_CONTENTS_LIST[0])
@ -142,7 +142,7 @@ class TestValidationLog(TestCase):
val = ValidationLog(
logfile='/tmp/123_foo_2020-03-30T13:17:22.447857Z.json')
status = val.get_status
self.assertEquals(status, 'PASSED')
self.assertEqual(status, 'PASSED')
@mock.patch('json.load',
return_value=fakes.FAILED_VALIDATIONS_LOGS_CONTENTS_LIST[0])
@ -151,7 +151,7 @@ class TestValidationLog(TestCase):
val = ValidationLog(
logfile='/tmp/123_foo_2020-03-30T13:17:22.447857Z.json')
status = val.get_status
self.assertEquals(status, 'FAILED')
self.assertEqual(status, 'FAILED')
@mock.patch('json.load',
return_value=fakes.BAD_VALIDATIONS_LOGS_CONTENTS_LIST[0])
@ -160,7 +160,7 @@ class TestValidationLog(TestCase):
val = ValidationLog(
logfile='/tmp/123_foo_2020-03-30T13:17:22.447857Z.json')
status = val.get_status
self.assertEquals(status, 'FAILED')
self.assertEqual(status, 'FAILED')
@mock.patch('json.load',
return_value=fakes.VALIDATIONS_LOGS_CONTENTS_LIST[0])
@ -169,7 +169,7 @@ class TestValidationLog(TestCase):
val = ValidationLog(
logfile='/tmp/123_foo_2020-03-30T13:17:22.447857Z.json')
host_group = val.get_host_group
self.assertEquals(host_group, 'undercloud')
self.assertEqual(host_group, 'undercloud')
@mock.patch('json.load',
return_value=fakes.VALIDATIONS_LOGS_CONTENTS_LIST[0])
@ -178,7 +178,7 @@ class TestValidationLog(TestCase):
val = ValidationLog(
logfile='/tmp/123_foo_2020-03-30T13:17:22.447857Z.json')
host_group = val.get_hosts_status
self.assertEquals(host_group, 'undercloud,PASSED')
self.assertEqual(host_group, 'undercloud,PASSED')
@mock.patch('json.load',
return_value=fakes.FAILED_VALIDATIONS_LOGS_CONTENTS_LIST[0])
@ -187,7 +187,7 @@ class TestValidationLog(TestCase):
val = ValidationLog(
logfile='/tmp/123_foo_2020-03-30T13:17:22.447857Z.json')
host_group = val.get_hosts_status
self.assertEquals(host_group, 'undercloud,FAILED')
self.assertEqual(host_group, 'undercloud,FAILED')
@mock.patch('json.load',
return_value=fakes.BAD_VALIDATIONS_LOGS_CONTENTS_LIST[0])
@ -196,7 +196,7 @@ class TestValidationLog(TestCase):
val = ValidationLog(
logfile='/tmp/123_foo_2020-03-30T13:17:22.447857Z.json')
host_group = val.get_hosts_status
self.assertEquals(host_group, 'undercloud,UNREACHABLE')
self.assertEqual(host_group, 'undercloud,UNREACHABLE')
@mock.patch('json.load',
return_value=fakes.VALIDATIONS_LOGS_CONTENTS_LIST[0])
@ -205,7 +205,7 @@ class TestValidationLog(TestCase):
val = ValidationLog(
logfile='/tmp/123_foo_2020-03-30T13:17:22.447857Z.json')
unreachable = val.get_unreachable_hosts
self.assertEquals(unreachable, '')
self.assertEqual(unreachable, '')
@mock.patch('json.load',
return_value=fakes.BAD_VALIDATIONS_LOGS_CONTENTS_LIST[0])
@ -214,7 +214,7 @@ class TestValidationLog(TestCase):
val = ValidationLog(
logfile='/tmp/123_foo_2020-03-30T13:17:22.447857Z.json')
unreachable = val.get_unreachable_hosts
self.assertEquals(unreachable, 'undercloud')
self.assertEqual(unreachable, 'undercloud')
@mock.patch('json.load',
return_value=fakes.VALIDATIONS_LOGS_CONTENTS_LIST[0])
@ -223,7 +223,7 @@ class TestValidationLog(TestCase):
val = ValidationLog(
logfile='/tmp/123_foo_2020-03-30T13:17:22.447857Z.json')
duration = val.get_duration
self.assertEquals(duration, '0:00:03.753')
self.assertEqual(duration, '0:00:03.753')
@mock.patch('json.load',
return_value=fakes.BAD_VALIDATIONS_LOGS_CONTENTS_LIST[0])
@ -232,7 +232,7 @@ class TestValidationLog(TestCase):
val = ValidationLog(
logfile='/tmp/123_foo_2020-03-30T13:17:22.447857Z.json')
duration = val.get_duration
self.assertEquals(duration, '')
self.assertEqual(duration, '')
@mock.patch('json.load',
return_value=fakes.VALIDATIONS_LOGS_CONTENTS_LIST[0])
@ -241,7 +241,7 @@ class TestValidationLog(TestCase):
val = ValidationLog(
logfile='/tmp/123_foo_2020-03-30T13:17:22.447857Z.json')
start_time = val.get_start_time
self.assertEquals(start_time, '2019-11-25T13:40:14.404623Z')
self.assertEqual(start_time, '2019-11-25T13:40:14.404623Z')
@mock.patch('json.load',
return_value=fakes.BAD_VALIDATIONS_LOGS_CONTENTS_LIST[0])
@ -250,7 +250,7 @@ class TestValidationLog(TestCase):
val = ValidationLog(
logfile='/tmp/123_foo_2020-03-30T13:17:22.447857Z.json')
start_time = val.get_start_time
self.assertEquals(start_time, '')
self.assertEqual(start_time, '')
@mock.patch('six.moves.builtins.open')
def test_log_not_found(self, mock_open):
@ -286,7 +286,7 @@ class TestValidationLog(TestCase):
val = ValidationLog(
logfile='/tmp/123_foo_2020-03-30T13:17:22.447857Z.json')
plays = val.get_plays
self.assertEquals(
self.assertEqual(
plays,
[fakes.VALIDATIONS_LOGS_CONTENTS_LIST[0]['plays'][0]['play']])
@ -297,7 +297,8 @@ class TestValidationLog(TestCase):
val = ValidationLog(
logfile='/tmp/123_foo_2020-03-30T13:17:22.447857Z.json')
tasks_data = val.get_tasks_data
self.assertEquals(
self.assertEqual(
tasks_data,
[fakes.VALIDATIONS_LOGS_CONTENTS_LIST[0]
['validation_output'][0]['task']])
[
fakes.VALIDATIONS_LOGS_CONTENTS_LIST[0]
['validation_output'][0]['task']])

+ 46
- 42
validations_libs/tests/test_validation_logs.py View File

@ -33,7 +33,7 @@ class TestValidationLogs(TestCase):
def test_validation_log_file(self, mock_open, mock_json):
vlogs = ValidationLogs('/tmp/foo')
content = vlogs._get_content('/tmp/foo/bar.json')
self.assertEquals(content, fakes.VALIDATIONS_LOGS_CONTENTS_LIST)
self.assertEqual(content, fakes.VALIDATIONS_LOGS_CONTENTS_LIST)
@mock.patch('six.moves.builtins.open')
def test_log_not_found(self, mock_open):
@ -53,8 +53,8 @@ class TestValidationLogs(TestCase):
['/tmp/123_foo_2020-03-30T13:17:22.447857Z.json']
vlogs = ValidationLogs('/tmp/foo')
log = vlogs.get_logfile_by_validation('foo')
self.assertEquals(log,
['/tmp/123_foo_2020-03-30T13:17:22.447857Z.json'])
self.assertEqual(log,
['/tmp/123_foo_2020-03-30T13:17:22.447857Z.json'])
@mock.patch('glob.glob')
@mock.patch('json.load',
@ -66,7 +66,7 @@ class TestValidationLogs(TestCase):
['/tmp/123_foo_2020-03-30T13:17:22.447857Z.json']
vlogs = ValidationLogs('/tmp/foo')
content = vlogs.get_logfile_content_by_validation('foo')
self.assertEquals(content, fakes.VALIDATIONS_LOGS_CONTENTS_LIST)
self.assertEqual(content, fakes.VALIDATIONS_LOGS_CONTENTS_LIST)
@mock.patch('glob.glob')
@mock.patch('json.load')
@ -76,8 +76,8 @@ class TestValidationLogs(TestCase):
['/tmp/123_foo_2020-03-30T13:17:22.447857Z.json']
vlogs = ValidationLogs('/tmp/foo')
log = vlogs.get_logfile_by_uuid('123')
self.assertEquals(log,
['/tmp/123_foo_2020-03-30T13:17:22.447857Z.json'])
self.assertEqual(log,
['/tmp/123_foo_2020-03-30T13:17:22.447857Z.json'])
@mock.patch('glob.glob')
@mock.patch('json.load',
@ -89,7 +89,7 @@ class TestValidationLogs(TestCase):
['/tmp/123_foo_2020-03-30T13:17:22.447857Z.json']
vlogs = ValidationLogs('/tmp/foo')
content = vlogs.get_logfile_content_by_uuid('123')
self.assertEquals(content, fakes.VALIDATIONS_LOGS_CONTENTS_LIST)
self.assertEqual(content, fakes.VALIDATIONS_LOGS_CONTENTS_LIST)
@mock.patch('glob.glob')
@mock.patch('json.load')
@ -100,8 +100,8 @@ class TestValidationLogs(TestCase):
['/tmp/123_foo_2020-03-30T13:17:22.447857Z.json']
vlogs = ValidationLogs('/tmp/foo')
log = vlogs.get_logfile_by_uuid_validation_id('123', 'foo')
self.assertEquals(log,
['/tmp/123_foo_2020-03-30T13:17:22.447857Z.json'])
self.assertEqual(log,
['/tmp/123_foo_2020-03-30T13:17:22.447857Z.json'])
@mock.patch('glob.glob')
@mock.patch('json.load',
@ -114,7 +114,7 @@ class TestValidationLogs(TestCase):
['/tmp/123_foo_2020-03-30T13:17:22.447857Z.json']
vlogs = ValidationLogs('/tmp/foo')
content = vlogs.get_logfile_content_by_uuid_validation_id('123', 'foo')
self.assertEquals(content, fakes.VALIDATIONS_LOGS_CONTENTS_LIST)
self.assertEqual(content, fakes.VALIDATIONS_LOGS_CONTENTS_LIST)
@mock.patch('os.path.isfile')
@mock.patch('os.listdir')
@ -128,8 +128,8 @@ class TestValidationLogs(TestCase):
mock_isfile.return_value = True
vlogs = ValidationLogs('/tmp/foo')
log = vlogs.get_all_logfiles()
self.assertEquals(log,
['/tmp/123_foo_2020-03-30T13:17:22.447857Z.json'])
self.assertEqual(log,
['/tmp/123_foo_2020-03-30T13:17:22.447857Z.json'])
@mock.patch('os.path.isfile')
@mock.patch('os.listdir')
@ -144,8 +144,8 @@ class TestValidationLogs(TestCase):
mock_isfile.return_value = True
vlogs = ValidationLogs('/tmp/foo')
log = vlogs.get_all_logfiles(extension='yaml')
self.assertEquals(log,
['/tmp/123_foo_2020-03-30T13:17:22.447857Z.yaml'])
self.assertEqual(log,
['/tmp/123_foo_2020-03-30T13:17:22.447857Z.yaml'])
@mock.patch('os.path.isfile')
@mock.patch('os.listdir')
@ -160,8 +160,8 @@ class TestValidationLogs(TestCase):
mock_isfile.return_value = True
vlogs = ValidationLogs('/tmp/foo')
log = vlogs.get_all_logfiles()
self.assertEquals(log,
['/tmp/123_foo_2020-03-30T13:17:22.447857Z.json'])
self.assertEqual(log,
['/tmp/123_foo_2020-03-30T13:17:22.447857Z.json'])
@mock.patch('os.path.isfile')
@mock.patch('os.listdir')
@ -175,7 +175,7 @@ class TestValidationLogs(TestCase):
mock_isfile.return_value = True
vlogs = ValidationLogs('/tmp/foo')
content = vlogs.get_all_logfiles_content()
self.assertEquals(content, fakes.VALIDATIONS_LOGS_CONTENTS_LIST)
self.assertEqual(content, fakes.VALIDATIONS_LOGS_CONTENTS_LIST)
@mock.patch('json.load',
return_value=fakes.VALIDATIONS_LOGS_CONTENTS_LIST[0])
@ -184,7 +184,7 @@ class TestValidationLogs(TestCase):
vlogs = ValidationLogs('/tmp/foo')
content = vlogs.get_validations_stats(
fakes.VALIDATIONS_LOGS_CONTENTS_LIST)
self.assertEquals(content, fakes.VALIDATIONS_STATS)
self.assertEqual(content, fakes.VALIDATIONS_STATS)
@mock.patch('validations_libs.validation_logs.ValidationLogs.'
'get_logfile_by_uuid_validation_id')
@ -196,14 +196,15 @@ class TestValidationLogs(TestCase):
['/tmp/123_foo_2020-03-30T13:17:22.447857Z.json']
vlogs = ValidationLogs('/tmp/foo')
content = vlogs.get_results(uuid='123', validation_id='foo')
self.assertEquals(content, [{'UUID': '123',
'Validations': 'foo',
'Status': 'PASSED',
'Status_by_Host': 'undercloud,PASSED',
'Host_Group': 'undercloud',
'Unreachable_Hosts': '',
'Duration': '0:00:03.753',
'Validations': 'foo'}])
self.assertEqual(content, [{
'UUID': '123',
'Validations': 'foo',
'Status': 'PASSED',
'Status_by_Host': 'undercloud,PASSED',
'Host_Group': 'undercloud',
'Unreachable_Hosts': '',
'Duration': '0:00:03.753',
'Validations': 'foo'}])
def test_get_results_none(self):
vlogs = ValidationLogs('/tmp/foo')
@ -219,19 +220,22 @@ class TestValidationLogs(TestCase):
['/tmp/123_foo_2020-03-30T13:17:22.447857Z.json']
vlogs = ValidationLogs('/tmp/foo')
content = vlogs.get_results(uuid=['123', '123'], validation_id='foo')
self.assertEquals(content, [{'UUID': '123',
'Validations': 'foo',
'Status': 'PASSED',
'Status_by_Host': 'undercloud,PASSED',
'Host_Group': 'undercloud',
'Unreachable_Hosts': '',
'Duration': '0:00:03.753',
'Validations': 'foo'},
{'UUID': '123',
'Validations': 'foo',
'Status': 'PASSED',
'Status_by_Host': 'undercloud,PASSED',
'Host_Group': 'undercloud',
'Unreachable_Hosts': '',
'Duration': '0:00:03.753',
'Validations': 'foo'}])
self.assertEqual(content, [
{
'UUID': '123',
'Validations': 'foo',
'Status': 'PASSED',
'Status_by_Host': 'undercloud,PASSED',
'Host_Group': 'undercloud',
'Unreachable_Hosts': '',
'Duration': '0:00:03.753',
'Validations': 'foo'},
{
'UUID': '123',
'Validations': 'foo',
'Status': 'PASSED',
'Status_by_Host': 'undercloud,PASSED',
'Host_Group': 'undercloud',
'Unreachable_Hosts': '',
'Duration': '0:00:03.753',
'Validations': 'foo'}])

Loading…
Cancel
Save