Add delete_module_in_bulk_operation funtion and add test_D in Bulk_operations file

This commit is contained in:
cesar991 2016-09-13 12:06:27 +02:00
parent 05426b9512
commit 885854ab93
2 changed files with 86 additions and 1 deletions

View File

@ -114,7 +114,47 @@ class Bulk_operations(PandoraWebDriverTestCase):
edit_agents_in_bulk(driver,agent_names_list,new_description="test C edit description bulk operation")
self.assertRegexpMatches(self.close_alert_and_get_its_text(), r"^Are you sure[\s\S]$")
self.assertEqual(self.driver.find_element_by_xpath('//div[@id="main"]//td[contains(.,"Agents updated successfully(2)")]').text,"Agents updated successfully(2)")
def test_D_delete_modules_in_bulk(self):
u"""
Create two agents with two modules and delete this modules through bulk operation
"""
agent_name_1 = gen_random_string(6)
agent_name_2 = gen_random_string(6)
module_name_1 = gen_random_string(6)
driver = self.driver
activate_api(driver,"1234")
params = [agent_name_1,"127.0.0.1","0","4","0","300","2","pandorafms","2","0","0","pruebas"]
create_agent_api(driver,params,user="admin",pwd="pandora")
params = [agent_name_2,"127.0.0.1","0","4","0","300","2","pandorafms","2","0","0","pruebas"]
create_agent_api(driver,params,user="admin",pwd="pandora")
params = [agent_name_1,module_name_1,"0","6","1","0","0","0","0","0","0","0","0","129.99.40.1","0","0","180","0","0","0","0","Host_Alive"]
add_network_module_to_agent_api(driver,params,user="admin",pwd="pandora",apipwd="1234")
params = [agent_name_2,module_name_1,"0","6","1","0","0","0","0","0","0","0","0","129.99.40.1","0","0","180","0","0","0","0","Host_Alive"]
add_network_module_to_agent_api(driver,params,user="admin",pwd="pandora",apipwd="1234")
lista = driver.current_url.split('/')
url = lista[0]+'//'+lista[2]+'/pandora_console'
driver.get(url)
agent_name_list = [agent_name_1,agent_name_2]
module_name_list = [module_name_1]
delete_modules_in_bulk(driver,agent_name_list,module_name_list)
self.assertRegexpMatches(self.close_alert_and_get_its_text(), r"^Are you sure[\s\S]$")
if __name__ == "__main__":
unittest.main()

View File

@ -43,3 +43,48 @@ def edit_agents_in_bulk(driver,agent_names_list,new_group=None,new_description=N
driver.find_element_by_id("submit-updbutton").click()
def delete_modules_in_bulk(driver,agent_name_list,module_name_list,select_agent_first=None):
#If select_agent_first is None, select the modules first
#To erase all modules with this names, add "Any" in agent_name_list
#To erase all modules of the agent put "Any" in module_name_list
click_menu_element(driver,"Module operations")
driver.find_element_by_id("option").click()
Select(driver.find_element_by_id("option")).select_by_visible_text("Delete modules in bulk")
if select_agent_first != None:
driver.find_element_by_id("radiobtn0002").click()
for agent_name in agent_name_list:
Select(driver.find_element_by_id("id_agents")).select_by_visible_text(agent_name)
time.sleep(3)
for module_name in module_name_list:
Select(driver.find_element_by_id("module")).select_by_visible_text(module_name)
else:
#driver.find_element_by_id("module_type").click()
Select(driver.find_element_by_id("module_type")).select_by_visible_text("All")
time.sleep(3)
for module_name in module_name_list:
Select(driver.find_element_by_id("module_name")).select_by_visible_text(module_name)
time.sleep(3)
for agent_name in agent_name_list:
Select(driver.find_element_by_id("agents")).select_by_visible_text(agent_name)
driver.find_element_by_id("submit-go").click()