diff --git a/tests/console/Network_components.py b/tests/console/Network_components.py index ebcd20513a..146c1a2b95 100644 --- a/tests/console/Network_components.py +++ b/tests/console/Network_components.py @@ -19,11 +19,11 @@ import unittest2, time, re class Network_components(PandoraWebDriverTestCase): - test_name = u'Planned_downtime' - test_description = u'Planed downtime test' + test_name = u'Network_components' + test_description = u'Network components test' tickets_associated = [] - def test_A_create_network_component(self): + def atest_A_create_network_component(self): u""" Create and search new network component module @@ -73,14 +73,18 @@ class Network_components(PandoraWebDriverTestCase): self.assertEqual(network_component_name in driver.page_source,True) - def test_B_create_plugin_component(self): + def atest_B_create_plugin_component(self): u""" Create and search new plug-in component """ driver = self.driver + + self.login() + detect_and_pass_all_wizards(driver) + agent_name = gen_random_string(6) plugin_component_name = gen_random_string(6) @@ -120,10 +124,55 @@ class Network_components(PandoraWebDriverTestCase): self.assertEqual(plugin_component_name in driver.page_source,True) + def test_C_create_wmi_component(self): + + u""" + Create and search new wmi component + """ + + driver = self.driver + + self.login() + detect_and_pass_all_wizards(driver) + + agent_name = gen_random_string(6) + plugin_component_name = gen_random_string(6) + + activate_api(driver,"1234") + + params = [agent_name,"127.0.0.1","0","4","0","300","2","pandorafms","2","0","0","pruebas"] + create_agent_api(driver,params,user="admin",pwd="pandora") + + lista = driver.current_url.split('/') + + url = lista[0]+'//'+lista[2]+'/pandora_console' + + driver.get(url) + + create_wmi_component(driver,plugin_component_name,"Generic numeric","Network Management","Application",max_warning=50,max_critical=100,description="New WMI component") + + search_agent(driver,agent_name,go_to_agent=True) + + driver.find_element_by_xpath('//ul[@class="mn"]/li/a/img[@data-title="Manage"]').click() + driver.find_element_by_xpath('//ul[@class="mn"]/li/a/img[@data-title="Modules"]').click() + + Select(driver.find_element_by_id("moduletype")).select_by_visible_text("Create a new WMI server module") + + driver.find_element_by_xpath('//*[@id="main"]/form/table/tbody/tr/td[5]/input').click() + + driver.find_element_by_xpath('//a[contains(.,"Advanced options")]').click() + + Select(driver.find_element_by_id("network_component_group")).select_by_visible_text("Network Management") + + time.sleep(3) + + Select(driver.find_element_by_id("network_component")).select_by_visible_text(plugin_component_name) + + driver.find_element_by_id("submit-crtbutton").click() + + search_module (driver,agent_name,plugin_component_name,go_to_module=False) + + self.assertEqual(plugin_component_name in driver.page_source,True) if __name__ == "__main__": unittest2.main() - - - - diff --git a/tests/console/include/network_components_functions.py b/tests/console/include/network_components_functions.py index de67513dfa..0c387e0d4c 100644 --- a/tests/console/include/network_components_functions.py +++ b/tests/console/include/network_components_functions.py @@ -28,8 +28,7 @@ def create_network_component(driver,name,type_component,group,module_group,min_w driver.find_element_by_id("type").click() Select(driver.find_element_by_id("type")).select_by_visible_text(type_component) - driver.find_element_by_id("id_group").click() - Select(driver.find_element_by_id("id_group")).select_by_visible_text(group) + driver.find_element_by_xpath('//option[contains(.,"'+group+'")]').click() driver.find_element_by_id("id_module_group").click() Select(driver.find_element_by_id("id_module_group")).select_by_visible_text(module_group) @@ -58,6 +57,7 @@ def create_network_component(driver,name,type_component,group,module_group,min_w driver.find_element_by_id("text-max_critical").clear() driver.find_element_by_id("text-max_critical").send_keys(max_critical) + # str_warning and str_critical if type_component supports this type if str_warning != None: driver.find_element_by_id("text-str_warning").click() @@ -95,8 +95,7 @@ def create_plugin_component(driver,name,type_component,group,module_group,min_wa driver.find_element_by_id("type").click() Select(driver.find_element_by_id("type")).select_by_visible_text(type_component) - driver.find_element_by_id("id_group").click() - Select(driver.find_element_by_id("id_group")).select_by_visible_text(group) + driver.find_element_by_xpath('//option[contains(.,"'+group+'")]').click() driver.find_element_by_id("id_module_group").click() Select(driver.find_element_by_id("id_module_group")).select_by_visible_text(module_group) @@ -147,3 +146,71 @@ def create_plugin_component(driver,name,type_component,group,module_group,min_wa driver.find_element_by_id("submit-crt").click() +def create_wmi_component(driver,name,type_component,group,module_group,min_warning=None,max_warning=None,min_critical=None,max_critical=None,str_warning=None,str_critical=None,description=None): + + # type_component is for example -> Generic boolean or Generic numeric incremental (absolute) + + click_menu_element(driver,"Network components") + + driver.find_element_by_xpath('//*[@id="id_component_type"]/option[3]').click() + + driver.find_element_by_id("submit-crt").click() + + driver.find_element_by_id("text-name").click() + driver.find_element_by_id("text-name").clear() + driver.find_element_by_id("text-name").send_keys(name) + + driver.find_element_by_id("type").click() + Select(driver.find_element_by_id("type")).select_by_visible_text(type_component) + + driver.find_element_by_xpath('//option[contains(.,"'+group+'")]').click() + + driver.find_element_by_id("id_module_group").click() + Select(driver.find_element_by_id("id_module_group")).select_by_visible_text(module_group) + + if min_warning != None: + + driver.find_element_by_id("text-min_warning").click() + driver.find_element_by_id("text-min_warning").clear() + driver.find_element_by_id("text-min_warning").send_keys(min_warning) + + if max_warning != None: + + driver.find_element_by_id("text-max_warning").click() + driver.find_element_by_id("text-max_warning").clear() + driver.find_element_by_id("text-max_warning").send_keys(max_warning) + + if min_critical != None: + + driver.find_element_by_id("text-min_critical").click() + driver.find_element_by_id("text-min_critical").clear() + driver.find_element_by_id("text-min_critical").send_keys(min_critical) + + + if max_critical != None: + + driver.find_element_by_id("text-max_critical").click() + driver.find_element_by_id("text-max_critical").clear() + driver.find_element_by_id("text-max_critical").send_keys(max_critical) + + # str_warning and str_critical if type_component is Generic boolean + if str_warning != None: + + driver.find_element_by_id("text-str_warning").click() + driver.find_element_by_id("text-str_warning").clear() + driver.find_element_by_id("text-str_warning").send_keys(str_warning) + + if str_critical != None: + + driver.find_element_by_id("text-str_critical").click() + driver.find_element_by_id("text-str_critical").clear() + driver.find_element_by_id("text-str_critical").send_keys(str_critical) + + if description != None: + + driver.find_element_by_id("textarea_description").click() + driver.find_element_by_id("textarea_description").clear() + driver.find_element_by_id("textarea_description").send_keys(description) + + driver.find_element_by_id("submit-crt").click() +