From 525a8322c8cdfb7d5d9eeb9740e8166b641e059b Mon Sep 17 00:00:00 2001 From: Konstantinos Papadopoulos Date: Sun, 5 Mar 2017 09:04:19 +0200 Subject: [PATCH] Corrections on unittests --- util/unittests/test_html.py | 24 ++++++++++++------------ util/unittests/test_netutil.py | 14 +++++++------- util/unittests/test_plot_json.py | 12 ++++++------ util/unittests/test_process.py | 12 ++++++------ util/unittests/test_stats.py | 2 +- util/unittests/test_sysstats.py | 28 ++++++++++++++-------------- 6 files changed, 46 insertions(+), 46 deletions(-) diff --git a/util/unittests/test_html.py b/util/unittests/test_html.py index 1a38aa99..95d65eac 100644 --- a/util/unittests/test_html.py +++ b/util/unittests/test_html.py @@ -23,7 +23,7 @@ def setUp(self): self.foot_output = '

testing

' self.foot_input = '

testing

' - def test01_generate_html_foot(self): + def test_generate_html_foot(self): """Checks the generate_html_footl() method of util/html.py. It checks the equality of the result of an input. """ @@ -62,7 +62,7 @@ def setUp(self): '', '') - def test01_generate_html_head(self): + def test_generate_html_head(self): """Checks the generate_html_headl() method of util/html.py. It checks the equality of the result of an input. """ @@ -98,7 +98,7 @@ def setUpClass(cls): cls.not_list_of_dictionaries = [1, 2, 'a', 3] cls.noise = 'This_is_just_noise' - def test01_isalistofdictionaries(self): + def test_isalistofdictionaries(self): """Checks the isalistofdictionaries() method of util/html.py. It checks the equality of the result of an input. - in this case is checked the result, when the provided input is a @@ -110,7 +110,7 @@ def test01_isalistofdictionaries(self): ('Testing isalistofdictionaries output. ' 'Assert true')) - def test02_isalistofdictionaries(self): + def test_isalistofdictionaries(self): """Checks the isalistofdictionaries() method of util/html.py. Checks the equality of the result of an input. - in this case is checked the result, when the provided input is a @@ -123,7 +123,7 @@ def test02_isalistofdictionaries(self): ('Testing isalistofdictionaries output. ' 'Assert false 1')) - def test03_isalistofdictionaries(self): + def test_isalistofdictionaries(self): """Checks the isalistofdictionaries() method of util/html.py. Checks the equality of the result of an input. - in this case is checked the result, when the provided input is not @@ -189,7 +189,7 @@ def setUpClass(cls): cls.row_data2['result3'] = 900 cls.multy_dict_input.append([cls.row_data1, cls.row_data2]) - def test01_multy_dict_to_html(self): + def test_multy_dict_to_html(self): """Tests the multy_dict_to_html() method of util/html.py. It checks the equality of the result of an input. - In this test case we are using only the compulsory arguments of the @@ -202,7 +202,7 @@ def test01_multy_dict_to_html(self): ('Testing multy_dict_to_' 'html_multiline output test 2')) - def test02_multy_dict_to_html(self): + def test_multy_dict_to_html(self): """Tests the multy_dict_to_html() method of util/html.py. It checks the equality of the result of an input. In this test case we are using only the compulsory arguments of the method @@ -248,7 +248,7 @@ def setUp(self): 'Test table', self.data_row) - def test01_single_dict_to_html(self): + def test_single_dict_to_html(self): """ Method that tests the single_dict_to_html() method of util/html.py It checks the equality of the result of an input. @@ -283,7 +283,7 @@ def setUpClass(cls): cls.map_dict['result3'] = 'switches' cls.map_dict['result4'] = 'switches' - def test01_get_ordered_index(self): + def test_get_ordered_index(self): """Method that tests functionality of get_ordered_index() function in case where it returns a valid index""" self.assertEqual(1, @@ -291,7 +291,7 @@ def test01_get_ordered_index(self): self.map_dict), 'Testing returned index when key exists.') - def test02_get_ordered_index(self): + def test_get_ordered_index(self): """Method that tests functionality of get_ordered_index() function in case where it returns a invalid index (returns None)""" self.assertEqual(-1, util.html.get_ordered_index('result33', @@ -332,7 +332,7 @@ def setUpClass(cls): cls.td_style = 'font-size:bold;' cls.td_class = 'info' - def test_01_singledicttabledata(self): + def test_singledicttabledata(self): """ Method that tests single_dict_table_data() when data_values parameter is a string value. @@ -345,7 +345,7 @@ def test_01_singledicttabledata(self): 'Testing single_dict_table_data() ' 'with a string input.') - def test_02_singledicttabledata(self): + def test_singledicttabledata(self): """ Method that tests single_dict_table_data() when data_values parameter is a List of Dictionaries. diff --git a/util/unittests/test_netutil.py b/util/unittests/test_netutil.py index e4b38532..d63b395a 100644 --- a/util/unittests/test_netutil.py +++ b/util/unittests/test_netutil.py @@ -83,7 +83,7 @@ def setUpClass(cls): logging.info('could not reach remote node: test cannot continue') return -1 - def test01_ssh_connection_open(self): + def test_ssh_connection_open(self): """ssh_connection_open() false "remote ip" provided """ logging.info('[netutil-test] remote address: {0} '. @@ -93,7 +93,7 @@ def test01_ssh_connection_open(self): self.assertIsNotNone(sftp) util.netutil.ssh_connection_close(sftp, transport_layer) - def test02_ssh_connect_or_return(self): + def test_ssh_connect_or_return(self): """ssh_connect_or_return() check returned ssh object """ logging.info('[netutil-test] remote address: {0} '. @@ -101,7 +101,7 @@ def test02_ssh_connect_or_return(self): self.assertIsNotNone(util.netutil.ssh_connect_or_return( self.remote_node, self.constants_set.maxretries)) - def test03_isdir(self): + def test_isdir(self): """testing isdir() with /tmp on localhost """ (sftp, transport_layer) = \ @@ -112,7 +112,7 @@ def test03_isdir(self): sftp)) util.netutil.ssh_connection_close(sftp, transport_layer) - def test04_ssh_copy_file_to_target(self): + def test_ssh_copy_file_to_target(self): """ssh_copy_file_to_target() copying a local file to remote target """ subprocess.check_output("touch" + " " + 'fooDir/' + @@ -131,7 +131,7 @@ def test04_ssh_copy_file_to_target(self): localfile, remotefile) - def test05_copy_dir_local_to_remote(self): + def test_copy_dir_local_to_remote(self): """copy_dir_local_to_remote(). copying a local directory to remote node """ util.netutil.copy_dir_local_to_remote(self.remote_node,self.localnodefilepath, @@ -140,7 +140,7 @@ def test05_copy_dir_local_to_remote(self): util.netutil.ssh_connection_open(self.remote_node) self.assertTrue(util.netutil.isdir(self.file_paths_set.rem_node_path, sftp)) - def test06_create_dir_remote(self): + def test_create_dir_remote(self): """create_dir_remote(). creating directory to remote node """ remote_dir_create = self.file_paths_set.rem_node_path + \ @@ -150,7 +150,7 @@ def test06_create_dir_remote(self): util.netutil.create_dir_remote(self.remote_node, remote_dir_create) - def test07_ssh_connect_or_return2(self): + def test_ssh_connect_or_return2(self): """ssh_connect_or_return2() check returned ssh object """ logging.info('[netutil-test] remote address: {0} '. diff --git a/util/unittests/test_plot_json.py b/util/unittests/test_plot_json.py index 6be8b81c..8ca25073 100644 --- a/util/unittests/test_plot_json.py +++ b/util/unittests/test_plot_json.py @@ -14,7 +14,7 @@ class PlotJsonKeyErrorTests(unittest.TestCase): module util/plot_json.py. """ - def test01_errorbar(self): + def test_errorbar(self): """Checks the errorbar() method of util/plot_json.py. It checks the case of invalid json input. """ @@ -28,7 +28,7 @@ def test01_errorbar(self): ['java_opts', 'controller'], 'errorbar.png', None, None, 0, None) - def test02_errorbar_connected(self): + def test_errorbar_connected(self): """Checks the errorbar_connected() method of util/plot_json.py. It checks the case of invalid json input. """ @@ -43,7 +43,7 @@ def test02_errorbar_connected(self): None, None, 0, None) - def test03_scatter(self): + def test_scatter(self): """ Checks the scatter() method of util/plot_json.py. It checks the case of invalid json input. @@ -58,7 +58,7 @@ def test03_scatter(self): ['java_opts', 'controller'], 'errorbar.png', None, None, 0, None) - def test04_multi_scatter(self): + def test_multi_scatter(self): """ Checks the multy_scatter() method of util/plot_json.py It checks the case of invalid json input. @@ -73,7 +73,7 @@ def test04_multi_scatter(self): ['java_opts', 'controller'], 'errorbar.png', None, None, 0, None) - def test05_multi_errorbar(self): + def test_multi_errorbar(self): """ Checks the multi_errorbar() function of util/plot_json.py. It checks the case of invalid json input. @@ -88,7 +88,7 @@ def test05_multi_errorbar(self): ['java_opts', 'controller'], 'errorbar.png', None, None, 0, None) - def test06_multi_errorbar_connected(self): + def test_multi_errorbar_connected(self): """ Method that checks the multi_errorbar_connected() function of util/plot_json.py. It checks the case of invalid json input. diff --git a/util/unittests/test_process.py b/util/unittests/test_process.py index 8c76eee5..2c0652f8 100644 --- a/util/unittests/test_process.py +++ b/util/unittests/test_process.py @@ -105,7 +105,7 @@ def setUpClass(cls): logging.getLogger().info('NOT OWNED PORT: %s', cls.port_not_owned) cls.ssh_client = util.netutil.ssh_connect_or_return(NODE_CONNECTION, 10) - def test01_getpid_listeningonport(self): + def test_getpid_listeningonport(self): """Checks the getpid_listeningonport() function of util/process.py module. Checks the equality between the known process id of the initializes server, with the one returned from the function. @@ -116,7 +116,7 @@ def test01_getpid_listeningonport(self): 'Testing the returned PID. Local') - def test02_getpid_listeningonport(self): + def test_getpid_listeningonport(self): """Checks the getpid_listeningonport() function of util/process.py module. In this scenario we check the result in case we give as input to the function, a port number on which a process @@ -132,7 +132,7 @@ def test02_getpid_listeningonport(self): self.ssh_client), 'Testing when port is not owned. Remote') - def test03_getpid_listeningonport(self): + def test_getpid_listeningonport(self): """Checks the getpid_listeningonport() function of util/process.py module. In this scenario we check the result in case we give as input to the function something that is not a port number. @@ -147,7 +147,7 @@ def test03_getpid_listeningonport(self): self.ssh_client), 'Testing with an invalid port. Remote') - def test01_is_process_running(self): + def test_is_process_running(self): """Checks the is_process_running() function of util/process.py module. In this scenario we check the result in case we give as input to the function a valid process id. @@ -158,7 +158,7 @@ def test01_is_process_running(self): self.ssh_client), 'Testing true case for a valid process id. Remote') - def test02_is_process_running(self): + def test_is_process_running(self): """Checks the is_process_running() function of util/process.py module. In this scenario we check the result in case we give as input to the function a invalid process id. @@ -169,7 +169,7 @@ def test02_is_process_running(self): self.ssh_client), 'Testing false case for invalid process id. Remote') - def test03_is_process_running(self): + def test_is_process_running(self): """Checks the is_process_running() function of util/process.py module. In this scenario we check the result in case we give as input to the function a invalid process id. diff --git a/util/unittests/test_stats.py b/util/unittests/test_stats.py index 876ba7df..ee61129c 100644 --- a/util/unittests/test_stats.py +++ b/util/unittests/test_stats.py @@ -28,7 +28,7 @@ def setUpClass(cls): cls.stddev = math.sqrt(cls.variance) cls.coefvariance = cls.stddev / cls.mean - def test01_mean(self): + def test_mean(self): """ Checks the mean() function of util/statutil.stats.py module. diff --git a/util/unittests/test_sysstats.py b/util/unittests/test_sysstats.py index e3ec4065..eb162d25 100644 --- a/util/unittests/test_sysstats.py +++ b/util/unittests/test_sysstats.py @@ -48,7 +48,7 @@ def setUpClass(cls): SSH_UNAME, SSH_PWD, 10) - def test01_used_ram(self): + def test_used_ram(self): """Test functionality of sysstats.sys_free_ram_mb function. """ @@ -59,7 +59,7 @@ def test01_used_ram(self): self.assertTrue((var > 0) and isinstance(var, int), 'Testing using ssh_client') - def test02_free_ram(self): + def test_free_ram(self): """Test functionality of sysstats.sys_free_ram_mb function """ @@ -70,7 +70,7 @@ def test02_free_ram(self): self.assertTrue((var > 0) and isinstance(var, int), 'Testing using ssh_client') - def test03_used_ramb(self): + def test_used_ramb(self): """Test functionality of sysstats.sys_used_memory_bytes function """ @@ -81,7 +81,7 @@ def test03_used_ramb(self): self.assertTrue((var > 0) and isinstance(var, int), 'Testing using ssh_client') - def test04_free_ramb(self): + def test_free_ramb(self): """Test functionality of sysstats.sys_free_memory_bytes function """ @@ -92,7 +92,7 @@ def test04_free_ramb(self): self.assertTrue((var > 0) and isinstance(var, int), 'Testing using ssh_client') - def test05_totam_ramb(self): + def test_totam_ramb(self): """Test functionality of sysstats.sys_total_memory_bytes function """ @@ -103,7 +103,7 @@ def test05_totam_ramb(self): self.assertTrue((var > 0) and isinstance(var, int), 'Testing using ssh_client') - def test06_get_units_base(self): + def test_get_units_base(self): """Test functionality of sysstats.get_units_base function """ base_kbytes = util.sysstats.get_units_base('kB') @@ -130,7 +130,7 @@ def setUpClass(cls): SSH_UNAME, SSH_PWD, 10) - def test01_io_error(self): + def test_io_error(self): """Test functionality of sysstats.sys_iowait_time function """ var = util.sysstats.sys_iowait_time() @@ -184,7 +184,7 @@ def setUpClass(cls): cls.cmd_remote = util.sysstats.proc_cmdline(cls.sleep_pid_remote, cls.ssh_client) - def test01_cmd_line(self): + def test_cmd_line(self): """Test functionality of sysstats.proc_cmdline function """ self.assertEqual(self.cmd_local, 'htop', @@ -193,7 +193,7 @@ def test01_cmd_line(self): self.assertEqual(self.cmd_remote, 'sleep1000', 'Testing using ssh_client') - def test02_cwd(self): + def test_cwd(self): """Test functionality of sysstats.proc_cwd function """ self.assertEqual(self.cur_dir_local, util.sysstats.proc_cwd( @@ -202,7 +202,7 @@ def test02_cwd(self): self.sleep_pid_remote, self.ssh_client), 'Testing using ssh_client') - def test04_cpu_system_time(self): + def test_cpu_system_time(self): """Test functionality of sysstats.proc_cpu_system_time function """ @@ -216,7 +216,7 @@ def test04_cpu_system_time(self): self.ssh_client), float), 'Testing using ssh_client') - def test05_vm_size(self): + def test_vm_size(self): """Test functionality of sysstats.proc_vm_size function """ @@ -290,7 +290,7 @@ def setUpClass(cls): 'ls -l /proc/{0}/fd | wc -l'.format(cls.sleep_pid_remote)) cls.num_remote_fds = int(cls.num_remote_fds.strip()) -3 - def test01_num_fds(self): + def test_num_fds(self): """Test functionality of sysstats.proc_num_fds function """ @@ -301,7 +301,7 @@ def test01_num_fds(self): self.assertTrue(isinstance(num_fds_remote, int), 'Testing using ssh_client') - def test02_num_threads(self): + def test_num_threads(self): """Test functionality of sysstats.proc_num_threads function """ @@ -337,7 +337,7 @@ def setUpClass(cls): SSH_UNAME, SSH_PWD, 10) - def test01_sys_load_average(self): + def test_sys_load_average(self): """Test functionality of sysstats.sys_load_average function """