Commit ed0ae681 by Thomas Gambier

CLENUP: use assertEqual instead of assertEquals

assertEquals is deprecated, see https://docs.python.org/2.7/library/unittest.html#deprecated-aliases
parent e1281991
......@@ -119,13 +119,13 @@ echo "htpasswd $@" > %s/monitor-htpasswd
command = 'htpasswd -cb %s admin %s%s' % (http_passwd, config["value"], '\n')
self.assertTrue(os.path.exists(parameter['file']))
self.assertTrue(os.path.exists(http_passwd))
self.assertEquals(config["value"], open(parameter['file']).read())
self.assertEquals(open(http_passwd).read(), command)
self.assertEqual(config["value"], open(parameter['file']).read())
self.assertEqual(open(http_passwd).read(), command)
elif config["key"] == 'cors-domain':
cors_file = "%s/test-httpd-cors.cfg" % self.base_dir
self.assertTrue(os.path.exists(cors_file))
cors_string = self.generate_cors_string(config["value"].split())
self.assertEquals(cors_string, open(cors_file).read())
self.assertEqual(cors_string, open(cors_file).read())
def check_cfg_config(self, config_list):
cfg_output = os.path.join(self.config_dir, 'config.cfg')
......@@ -150,7 +150,7 @@ echo "htpasswd $@" > %s/monitor-htpasswd
result = instance.applyConfigChanges()
self.assertTrue(os.path.exists(cfg_output))
# Check result of non raw parameter edition
self.assertEquals(result, {'cors-domain': True, 'from-file': True, 'httpd-password': True})
self.assertEqual(result, {'cors-domain': True, 'from-file': True, 'httpd-password': True})
self.check_config()
self.check_cfg_config(self.config)
......@@ -172,7 +172,7 @@ echo "htpasswd $@" > %s/monitor-htpasswd
result = instance.applyConfigChanges()
self.assertTrue(os.path.exists(cfg_output))
# Check result of non raw parameter edition
self.assertEquals(result, {'from-file': True, 'httpd-password': True})
self.assertEqual(result, {'from-file': True, 'httpd-password': True})
self.check_config()
self.check_cfg_config(self.config)
......@@ -189,7 +189,7 @@ echo "htpasswd $@" > %s/monitor-htpasswd
result = instance.applyConfigChanges()
self.assertTrue(os.path.exists(cfg_output))
self.assertEquals(result, {'cors-domain': True, 'from-file': True, 'httpd-password': True})
self.assertEqual(result, {'cors-domain': True, 'from-file': True, 'httpd-password': True})
self.check_config()
self.check_cfg_config(self.config)
......@@ -199,7 +199,7 @@ echo "htpasswd $@" > %s/monitor-htpasswd
self.writeContent(self.config_path, json.dumps(self.config))
result = instance.applyConfigChanges()
self.assertEquals(result, {'cors-domain': True, 'from-file': True, 'httpd-password': True})
self.assertEqual(result, {'cors-domain': True, 'from-file': True, 'httpd-password': True})
self.check_config()
self.check_cfg_config(self.config)
......@@ -210,6 +210,6 @@ echo "htpasswd $@" > %s/monitor-htpasswd
self.writeContent(self.config_path, json.dumps(self.config))
result = instance.applyConfigChanges()
self.assertEquals(result, {'cors-domain': True, 'from-file': True, 'httpd-password': True})
self.assertEqual(result, {'cors-domain': True, 'from-file': True, 'httpd-password': True})
self.check_config()
self.check_cfg_config(self.config)
......@@ -51,28 +51,28 @@ class TestMonitorCollect(unittest.TestCase):
def test_getPartitionUsedMemoryAverage(self):
self.assertEquals(1195.492578125,
self.assertEqual(1195.492578125,
self.collector.getPartitionUsedMemoryAverage('slapuser15', '2017-09-16'))
def test_getPartitionCPULoadAverage(self):
self.assertEquals(2.1599999999999993,
self.assertEqual(2.1599999999999993,
self.collector.getPartitionCPULoadAverage('slapuser15', '2017-09-16'))
def test_getPartitionDiskUsedAverage(self):
self.assertEquals(35.5234375,
self.assertEqual(35.5234375,
self.collector.getPartitionDiskUsedAverage('slapuser15', '2017-04-18'))
def test_getPartitionConsumption(self):
data = self.collector.getPartitionConsumption('slapuser15', date_scope='2017-09-16',
min_time='00:01:00', max_time='00:13:00')
self.assertEquals(1302.66, data[0]['cpu_time'])
self.assertEquals(26825304064.0, data[0]['io_rw_counter'])
self.assertEqual(1302.66, data[0]['cpu_time'])
self.assertEqual(26825304064.0, data[0]['io_rw_counter'])
def test_getPartitionComsumptionStatus(self):
data = self.collector.getPartitionComsumptionStatus('slapuser15', date_scope='2017-09-16',
min_time='00:01:00', max_time='00:13:00')
self.assertEquals(7.3, data[0]['cpu_percent'])
self.assertEquals(2822535483392.0, data[2]['io_rw_counter'])
self.assertEqual(7.3, data[0]['cpu_percent'])
self.assertEqual(2822535483392.0, data[2]['io_rw_counter'])
def tearDown(self):
os.remove("/tmp/collector.db")
......
......@@ -128,7 +128,7 @@ partition-folder = %(base_dir)s
destination += '/'
dest_file_list = os.listdir(destination)
source_file_list = os.listdir(source)
self.assertEquals(dest_file_list, source_file_list)
self.assertEqual(dest_file_list, source_file_list)
def check_symlink(self, source, destination):
if source.endswith('/'):
......@@ -139,7 +139,7 @@ partition-folder = %(base_dir)s
source_basename = os.path.basename(source)
dest_basename = os.path.basename(destination)
self.assertEquals(source_basename, dest_basename)
self.assertEqual(source_basename, dest_basename)
if os.path.isdir(source):
self.check_folder_equals(source, destination)
......@@ -251,32 +251,32 @@ partition-folder = %(base_dir)s
instance_config = os.path.join(instance.config_folder, '.jio_documents', 'config.json')
self.assertTrue(os.path.exists(instance_config))
config_content = json.loads(open(instance_config).read())
self.assertEquals(len(config_content), 4)
self.assertEqual(len(config_content), 4)
key_list = ['', 'sample', 'monitor-password', 'cors-domain']
for parameter in config_content:
if parameter['key'] in key_list:
key_list.pop(key_list.index(parameter['key']))
if parameter['key'] == '':
self.assertEquals(parameter, dict(
self.assertEqual(parameter, dict(
key="",
title="monitor-user",
value="admin"))
if parameter['key'] == 'sample':
self.assertEquals(parameter, dict(
self.assertEqual(parameter, dict(
key="sample",
title="sample",
value="12345"))
if parameter['key'] == 'monitor-password':
self.assertEquals(parameter, dict(
self.assertEqual(parameter, dict(
key="monitor-password",
title="monitor-password",
value="bcuandjy"))
if parameter['key'] == 'cors-domain':
self.assertEquals(parameter, dict(
self.assertEqual(parameter, dict(
key="cors-domain",
title="cors-domain",
value=""))
self.assertEquals(key_list, [])
self.assertEqual(key_list, [])
......@@ -232,7 +232,7 @@ exit %(code)s
with open(os.path.join(self.private_dir, 'monitor.global.json')) as r:
result = json.loads(r.read().decode("utf-8"))
result.pop("date")
self.assertEquals(result,
self.assertEqual(result,
json.loads(expected_result))
# all promises are OK now
......@@ -251,7 +251,7 @@ exit %(code)s
instance_result_dict = json.loads(r.read().decode("utf-8"))
result = instance_result_dict.copy()
result.pop("date")
self.assertEquals(result,
self.assertEqual(result,
expected_result_dict)
# validate returned json result
......
......@@ -161,7 +161,7 @@ class RunPromise(GenericPromise):
u'execution-time': 0.1,
u'path': u'%s/my_promise.py' % self.promise_dir,
}
self.assertEquals(expected_result, my_result)
self.assertEqual(expected_result, my_result)
result_file = os.path.join(self.output_dir, 'my_second_promise.status.json')
self.assertTrue(os.path.exists(result_file))
......@@ -176,7 +176,7 @@ class RunPromise(GenericPromise):
u'execution-time': 0.1,
u'path': u'%s/my_second_promise.py' % self.promise_dir,
}
self.assertEquals(expected_result, second_result)
self.assertEqual(expected_result, second_result)
def test_promise_generic_failed(self):
promise_file = self.generatePromiseScript('my_promise.py', success=False)
......@@ -197,7 +197,7 @@ class RunPromise(GenericPromise):
u'execution-time': 0.1,
u'path': u'%s/my_promise.py' % self.promise_dir,
}
self.assertEquals(expected_result, my_result)
self.assertEqual(expected_result, my_result)
def test_promise_generic_status_change(self):
promise_file = self.generatePromiseScript('my_promise.py', success=False)
......@@ -218,7 +218,7 @@ class RunPromise(GenericPromise):
u'execution-time': 0.1,
u'path': u'%s/my_promise.py' % self.promise_dir,
}
self.assertEquals(expected_result, my_result)
self.assertEqual(expected_result, my_result)
os.system('rm %s/*.pyc' % self.promise_dir)
time.sleep(2)
......@@ -237,7 +237,7 @@ class RunPromise(GenericPromise):
u'execution-time': 0.1,
u'path': u'%s/my_promise.py' % self.promise_dir,
}
self.assertEquals(expected_result, my_result)
self.assertEqual(expected_result, my_result)
def test_promise_generic_periodicity(self):
promise_file = self.generatePromiseScript('my_promise.py', success=False, periodicity=0.03)
......@@ -305,7 +305,7 @@ class RunPromise(GenericPromise):
promise_runner.start()
result2 = json.loads(open(result_file).read().decode("utf-8"))
start_date2 = datetime.strptime(result2['result'].pop('date'), '%Y-%m-%dT%H:%M:%S')
self.assertEquals(expected_result, result2)
self.assertEqual(expected_result, result2)
def test_promise_two_folder(self):
......@@ -330,7 +330,7 @@ class RunPromise(GenericPromise):
u'execution-time': 0.1,
u'path': u'%s' % promise,
}
self.assertEquals(expected_result, result1)
self.assertEqual(expected_result, result1)
result2 = json.loads(open(result2_file).read())
start_date2 = datetime.strptime(result2['result'].pop('date'), '%Y-%m-%dT%H:%M:%S')
......@@ -343,7 +343,7 @@ class RunPromise(GenericPromise):
u'execution-time': 0.1,
u'path': u'%s' % promise2,
}
self.assertEquals(expected_result, result2)
self.assertEqual(expected_result, result2)
def test_promise_NOK(self):
promise = self.writePromiseNOK('promise_1')
......@@ -363,14 +363,14 @@ class RunPromise(GenericPromise):
u'execution-time': 0.1,
u'path': u'%s' % promise,
}
self.assertEquals(expected_result, result1)
self.assertEqual(expected_result, result1)
# second run
promise_runner = MonitorPromiseLauncher(parser)
promise_runner.start()
result2 = json.loads(open(result_file).read().decode("utf-8"))
result2['result'].pop('date')
self.assertEquals(expected_result, result2)
self.assertEqual(expected_result, result2)
def test_promise_mixed(self):
promise = self.writePromiseOK('promise_1')
......@@ -390,7 +390,7 @@ class RunPromise(GenericPromise):
u'execution-time': 0.1,
u'path': u'%s' % promise,
}
self.assertEquals(expected_result, result1)
self.assertEqual(expected_result, result1)
# second run with failure
time.sleep(1)
......@@ -403,5 +403,5 @@ class RunPromise(GenericPromise):
result2 = json.loads(open(result_file).read().decode("utf-8"))
result2['result'].pop('date')
self.assertEquals(expected_result, result2)
self.assertEqual(expected_result, result2)
......@@ -78,7 +78,7 @@ extra_config_dict = {{
self.configureLauncher(enable_anomaly=True)
self.launcher.run()
result = self.getPromiseResult(self.promise_name)
self.assertEquals(result['result']['failed'], False)
self.assertEqual(result['result']['failed'], False)
self.assertIn("Backup OK", result['result']['message'])
def test_check_backup_fail(self):
......@@ -103,7 +103,7 @@ extra_config_dict = {{
with self.assertRaises(PromiseError):
self.launcher.run()
result = self.getPromiseResult(self.promise_name)
self.assertEquals(result['result']['failed'], True)
self.assertEqual(result['result']['failed'], True)
self.assertIn("Backup didn't start at correct time", result['result']['message'])
if __name__ == '__main__':
......
......@@ -84,15 +84,15 @@ extra_config_dict = {
self.configureLauncher()
self.launcher.run()
result = self.getPromiseResult(self.promise_name)
self.assertEquals(result['result']['failed'], False)
self.assertEquals(result['result']['message'], "No result from collector database: disk check skipped")
self.assertEqual(result['result']['failed'], False)
self.assertEqual(result['result']['message'], "No result from collector database: disk check skipped")
def test_disk_space_ok(self):
self.configureLauncher()
self.launcher.run()
result = self.getPromiseResult(self.promise_name)
self.assertEquals(result['result']['failed'], False)
self.assertEquals(result['result']['message'], "Disk usage: OK")
self.assertEqual(result['result']['failed'], False)
self.assertEqual(result['result']['message'], "Disk usage: OK")
def test_disk_space_nok(self):
with open(self.th_file, 'w') as f:
......@@ -101,8 +101,8 @@ extra_config_dict = {
with self.assertRaises(PromiseError):
self.launcher.run()
result = self.getPromiseResult(self.promise_name)
self.assertEquals(result['result']['failed'], True)
self.assertEquals(result['result']['message'], "Free disk space low: remaining 269.1 G (threshold: 291921381.0 G)")
self.assertEqual(result['result']['failed'], True)
self.assertEqual(result['result']['message'], "Free disk space low: remaining 269.1 G (threshold: 291921381.0 G)")
def test_check_free_disk_with_unicode_string_path(self):
# set path unicode
......@@ -110,8 +110,8 @@ extra_config_dict = {
self.configureLauncher()
self.launcher.run()
result = self.getPromiseResult(self.promise_name)
self.assertEquals(result['result']['failed'], False)
self.assertEquals(result['result']['message'], "Disk usage: OK")
self.assertEqual(result['result']['failed'], False)
self.assertEqual(result['result']['message'], "Disk usage: OK")
if __name__ == '__main__':
unittest.main()
......@@ -49,8 +49,8 @@ from slapos.promise.plugin.check_partition_deployment_state import RunPromise
self.configureLauncher()
self.launcher.run()
result = self.getPromiseResult("partition-deployment-state.py")
self.assertEquals(result['result']['failed'], False)
self.assertEquals(result['result']['message'], 'buildout is OK')
self.assertEqual(result['result']['failed'], False)
self.assertEqual(result['result']['message'], 'buildout is OK')
def test_partition_deployment_state_failed(self):
content = """
......@@ -65,10 +65,10 @@ from slapos.promise.plugin.check_partition_deployment_state import RunPromise
result = self.getPromiseResult("partition-deployment-state.py")
buildout_output = os.path.join(self.partition_dir, 'var/log', 'slapgrid-%s-error.log' % self.partition_id)
self.assertEquals(result['result']['failed'], True)
self.assertEquals(result['result']['message'], 'Buildout failed to process %s.' % self.partition_id)
self.assertEqual(result['result']['failed'], True)
self.assertEqual(result['result']['message'], 'Buildout failed to process %s.' % self.partition_id)
with open(buildout_output) as f:
self.assertEquals(f.read(), message)
self.assertEqual(f.read(), message)
if __name__ == '__main__':
unittest.main()
......@@ -50,7 +50,7 @@ extra_config_dict = {
if result['result']['failed']:
self.assertTrue("CPU load is high" in result['result']['message'])
else:
self.assertEquals("CPU load is OK", result['result']['message'].strip())
self.assertEqual("CPU load is OK", result['result']['message'].strip())
if __name__ == '__main__':
unittest.main()
......@@ -67,8 +67,8 @@ extra_config_dict = {
self.configureLauncher()
self.launcher.run()
result = self.getPromiseResult(self.promise_name)
self.assertEquals(result['result']['failed'], False)
self.assertEquals(result['result']['message'], "Bootstrap didn't run!")
self.assertEqual(result['result']['failed'], False)
self.assertEqual(result['result']['message'], "Bootstrap didn't run!")
def test_monitor_bootstrap_ok(self):
self.writeResult('')
......@@ -76,8 +76,8 @@ extra_config_dict = {
self.configureLauncher()
self.launcher.run()
result = self.getPromiseResult(self.promise_name)
self.assertEquals(result['result']['failed'], False)
self.assertEquals(result['result']['message'], "Bootstrap OK")
self.assertEqual(result['result']['failed'], False)
self.assertEqual(result['result']['message'], "Bootstrap OK")
def test_monitor_bootstrap_fail(self):
self.writePid(2425)
......@@ -85,9 +85,9 @@ extra_config_dict = {
with self.assertRaises(PromiseError):
self.launcher.run()
result = self.getPromiseResult(self.promise_name)
self.assertEquals(result['result']['failed'], True)
self.assertEqual(result['result']['failed'], True)
message = "Monitor bootstrap exited with error.\n ---- Latest monitor-boostrap.log ----\nBuildout running..."
self.assertEquals(result['result']['message'], message)
self.assertEqual(result['result']['message'], message)
if __name__ == '__main__':
unittest.main()
......@@ -46,30 +46,30 @@ class TestApacheMPMWatchdog(unittest.TestCase):
server_status = f.read()
f.close()
self.assertEquals(['12345', '12346'],
self.assertEqual(['12345', '12346'],
re.findall(search_pid_regex, server_status))
def test_loadJSONFile(self):
self.assertEquals({},
self.assertEqual({},
loadJSONFile("couscous"))
self.assertEquals(
self.assertEqual(
{"1234": 1496161635.514768 , "4321": 1496161635.514768},
loadJSONFile(os.path.join(self.base_path, "test_db.json")))
self.assertEquals(
self.assertEqual(
{},
loadJSONFile(os.path.join(self.base_path, "corrupted_db.json")))
def test_writeJSONFile(self):
# Check if don't raise.
self.assertEquals(None,
self.assertEqual(None,
writeJSONFile({}, None))
current_pid = os.getpid()
self.assertEquals(None,
self.assertEqual(None,
writeJSONFile({"123482": 123, current_pid: 124},
os.path.join(self.base_path, "write_db.json")))
......@@ -77,14 +77,14 @@ class TestApacheMPMWatchdog(unittest.TestCase):
json_content = f.read()
f.close()
self.assertEquals(json_content,
self.assertEqual(json_content,
'{"%s": 124}' % current_pid)
def test_getServerStatus(self):
self.assertEquals(None,
self.assertEqual(None,
getServerStatus("http://localhost/", None, None))
self.assertEquals(None,
self.assertEqual(None,
getServerStatus("http://localhost/",
"user", "password"))
self.assertNotEquals(None,
......
......@@ -76,28 +76,28 @@ class TestCheckApacheDigestResult(unittest.TestCase):
def test_threshold_is_greater(self):
status, message = checkApachedexResult(self.base_dir, self.status_file, 60)
self.assertEquals(ok_message_formater.format(80), message)
self.assertEquals(0, status)
self.assertEqual(ok_message_formater.format(80), message)
self.assertEqual(0, status)
def test_no_today_file_and_empty_yesterday_file(self):
self._remove_file(self.today)
status, message = checkApachedexResult(self.base_dir, self.status_file, 60)
self.assertEquals(apdex_not_found_message, message)
self.assertEquals(1, status)
self.assertEqual(apdex_not_found_message, message)
self.assertEqual(1, status)
self._create_file(self.today, True)
def test_threshold_is_lower(self):
threshold = 90.0
status, message = checkApachedexResult(self.base_dir, self.status_file, threshold)
self.assertEquals(low_score_message_formater.format(80, threshold), message)
self.assertEquals(1, status)
self.assertEqual(low_score_message_formater.format(80, threshold), message)
self.assertEqual(1, status)
def test_no_today_file_but_yesterday_file(self):
self._remove_file(self.today)
self._create_file(self.yesterday, True)
status, message = checkApachedexResult(self.base_dir, self.status_file, 60)
self.assertEquals(ok_message_formater.format(80), message)
self.assertEquals(0, status)
self.assertEqual(ok_message_formater.format(80), message)
self.assertEqual(0, status)
self._create_file(self.today, True)
self._remove_file(self.yesterday)
self._create_file(self.yesterday, False)
......
......@@ -49,7 +49,7 @@ class TestComputerMemory(unittest.TestCase):
self.conn.close()
def test_check_memory(self):
self.assertEquals(
self.assertEqual(
({
'total': 33705312256,
'used': 33139023872,
......@@ -58,41 +58,41 @@ class TestComputerMemory(unittest.TestCase):
'free_percent': 1.6801161184886904,
}, ""),
getMemoryInfo('/tmp', '00:02', '2017-09-15'))
self.assertEquals(
self.assertEqual(
(True, "OK - memory used: 33139023872B of 33705312256B (98.3%)", ""),
checkMemoryUsage('/tmp', '00:02', '2017-09-15', threshold=33500000000),
)
self.assertEquals(
self.assertEqual(
(True, "OK - memory used: 98.3% (33139023872B of 33705312256B)", ""),
checkMemoryUsage('/tmp', '00:02', '2017-09-15', threshold=99, unit="percent"),
)
self.assertEquals(
self.assertEqual(
(True, "OK - free memory: 566288384B of 33705312256B (1.7%)", ""),
checkMemoryUsage('/tmp', '00:02', '2017-09-15', threshold=500000000, key="free"),
)
self.assertEquals(
self.assertEqual(
(True, "OK - free memory: 1.7% (566288384B of 33705312256B)", ""),
checkMemoryUsage('/tmp', '00:02', '2017-09-15', threshold=1, key="free", unit="percent"),
)
self.assertEquals(
self.assertEqual(
(False, "Low available memory - usage: 33139023872B of 33705312256B (98.3%)", ""),
checkMemoryUsage('/tmp', '00:02', '2017-09-15', threshold=33000000000),
)
self.assertEquals(
self.assertEqual(
(False, "Low available memory - usage: 98.3% (33139023872B of 33705312256B)", ""),
checkMemoryUsage('/tmp', '00:02', '2017-09-15', threshold=98, unit="percent"),
)
self.assertEquals(
self.assertEqual(
(False, "Low available memory - free: 566288384B of 33705312256B (1.7%)", ""),
checkMemoryUsage('/tmp', '00:02', '2017-09-15', threshold=600000000, key="free"),
)
self.assertEquals(
self.assertEqual(
(False, "Low available memory - free: 1.7% (566288384B of 33705312256B)", ""),
checkMemoryUsage('/tmp', '00:02', '2017-09-15', threshold=2, key="free", unit="percent"),
)
def test_check_memory_with_unavailable_dates(self):
self.assertEquals(
self.assertEqual(
(False, "error", total_memory_fetch_failure_message),
checkMemoryUsage('/tmp', '18:00', '2017-09-14', 1.0),
)
......
......@@ -63,31 +63,31 @@ class TestCheckErrorOnApacheLog(unittest.TestCase):
self._update_logs()
def test_no_error(self):
self.assertEquals("OK",
self.assertEqual("OK",
test(self.base_path + "/SOFTINST-0_infoonly_error_log", 0))
self.assertEquals("OK",
self.assertEqual("OK",
test(self.base_path + "/SOFTINST-0_infoonly_error_log", 3600))
def test_error(self):
self.assertEquals("ERROR=2 (NOTROUTE=2, UNREACHEABLENET=0, TIMEOUT=0)",
self.assertEqual("ERROR=2 (NOTROUTE=2, UNREACHEABLENET=0, TIMEOUT=0)",
test(self.base_path + "/SOFTINST-0_apache_error_log", 0))
self.assertEquals("ERROR=1 (NOTROUTE=1, UNREACHEABLENET=0, TIMEOUT=0)",
self.assertEqual("ERROR=1 (NOTROUTE=1, UNREACHEABLENET=0, TIMEOUT=0)",
test(self.base_path + "/SOFTINST-0_apache_error_log", 3600))
def test_error_timeout(self):
self.assertEquals("ERROR=4 (NOTROUTE=0, UNREACHEABLENET=0, TIMEOUT=4)",
self.assertEqual("ERROR=4 (NOTROUTE=0, UNREACHEABLENET=0, TIMEOUT=4)",
test(self.base_path + "/SOFTINST-0_timeout_error_log", 0))
self.assertEquals("ERROR=2 (NOTROUTE=0, UNREACHEABLENET=0, TIMEOUT=2)",
self.assertEqual("ERROR=2 (NOTROUTE=0, UNREACHEABLENET=0, TIMEOUT=2)",
test(self.base_path + "/SOFTINST-0_timeout_error_log", 3600))
def test_error_unreacheabler(self):
self.assertEquals("ERROR=11 (NOTROUTE=0, UNREACHEABLENET=11, TIMEOUT=0)",
self.assertEqual("ERROR=11 (NOTROUTE=0, UNREACHEABLENET=11, TIMEOUT=0)",
test(self.base_path + "/SOFTINST-0_unreachable_error_log", 0))
self.assertEquals("ERROR=11 (NOTROUTE=0, UNREACHEABLENET=11, TIMEOUT=0)",
self.assertEqual("ERROR=11 (NOTROUTE=0, UNREACHEABLENET=11, TIMEOUT=0)",
test(self.base_path + "/SOFTINST-0_unreachable_error_log", 3600))
if __name__ == '__main__':
......
......@@ -35,19 +35,19 @@ class TestCheckRe6stOptimalStatus(unittest.TestCase):
def test_ipv6_is_faster(self):
result = test('::1', '8.8.8.8', 5)
self.assertEquals(result, 'OK')
self.assertEqual(result, 'OK')
def test_ipv4_is_faster(self):
result = test('2001:67c:1254::1', '127.0.0.1', 5)
self.assertEquals(result, 'FAIL')
self.assertEqual(result, 'FAIL')
def test_ipv4_unreacheable_and_ipv6_ok(self):
result = test('::1', 'couscous', 5)
self.assertEquals(result, 'OK')
self.assertEqual(result, 'OK')
def test_ipv6_fail(self):
result = test('couscous', '127.0.0.1', 5)
self.assertEquals(result, 'FAILED')
self.assertEqual(result, 'FAILED')
if __name__ == '__main__':
unittest.main()
......@@ -71,27 +71,27 @@ class TestCheckSlowQueriesDigestResult(unittest.TestCase):
def test_threshold_is_greater(self):
status, message = checkMariadbDigestResult(self.base_dir, self.status_file, 5000, 100)
self.assertEquals("Thanks for keeping it all clean, total queries are : 3420.0 slowest query time is : 34", message)
self.assertEquals(0, status)
self.assertEqual("Thanks for keeping it all clean, total queries are : 3420.0 slowest query time is : 34", message)
self.assertEqual(0, status)
def test_no_today_file_and_empty_yesterday_file(self):
self._remove_file(self.today)
status, message = checkMariadbDigestResult(self.base_dir, self.status_file, 60, 100)
self.assertEquals("No result found in the slow query digest file or the file is corrupted", message)
self.assertEquals(1, status)
self.assertEqual("No result found in the slow query digest file or the file is corrupted", message)
self.assertEqual(1, status)
self._create_file(self.today, True)
def test_fail(self):
status, message = checkMariadbDigestResult(self.base_dir, self.status_file, 90, 100)
self.assertEquals("Threshold is lower than expected: \nExpected total queries : 90 and current is: 3420.0\nExpected slowest query : 100 and current is: 34", message)
self.assertEquals(1, status)
self.assertEqual("Threshold is lower than expected: \nExpected total queries : 90 and current is: 3420.0\nExpected slowest query : 100 and current is: 34", message)
self.assertEqual(1, status)
def test_no_today_file_but_yesterday_file(self):
self._remove_file(self.today)
self._create_file(self.yesterday, True)
status, message = checkMariadbDigestResult(self.base_dir, self.status_file, 5000, 100)
self.assertEquals("Thanks for keeping it all clean, total queries are : 3420.0 slowest query time is : 34", message)
self.assertEquals(0, status)
self.assertEqual("Thanks for keeping it all clean, total queries are : 3420.0 slowest query time is : 34", message)
self.assertEqual(0, status)
self._create_file(self.today, True)
self._remove_file(self.yesterday)
self._create_file(self.yesterday, False)
......
......@@ -51,7 +51,7 @@ class TestUserMemory(unittest.TestCase):
self.conn.close()
def test_check_memory(self):
self.assertEquals(
self.assertEqual(
({
'byte': 29544162598,
'percent': 87.65432099725093,
......@@ -62,7 +62,7 @@ class TestUserMemory(unittest.TestCase):
'slaptestuser1',
),
)
self.assertEquals(
self.assertEqual(
(True, "User memory usage: 29544162598B (87.7%)", ""),
checkMemoryUsage(
self.db_dir,
......@@ -71,7 +71,7 @@ class TestUserMemory(unittest.TestCase):
threshold=29600000000,
),
)
self.assertEquals(
self.assertEqual(
(True, "User memory usage: 87.7% (29544162598B)", ""),
checkMemoryUsage(
self.db_dir,
......@@ -81,7 +81,7 @@ class TestUserMemory(unittest.TestCase):
unit="percent",
),
)
self.assertEquals(
self.assertEqual(
(False, "High user memory usage: 29544162598B (87.7%)", ""),
checkMemoryUsage(
self.db_dir,
......@@ -90,7 +90,7 @@ class TestUserMemory(unittest.TestCase):
threshold=29500000000,
),
)
self.assertEquals(
self.assertEqual(
(False, "High user memory usage: 87.7% (29544162598B)", ""),
checkMemoryUsage(
self.db_dir,
......@@ -102,7 +102,7 @@ class TestUserMemory(unittest.TestCase):
)
def test_check_memory_with_unavailable_dates(self):
self.assertEquals(