Add edit_agents_in_bulk functions and test_B_edit_agents_group_bulk_operations in Bulk_operations
(cherry picked from commit 0523a3d984
)
This commit is contained in:
parent
dac4b25b99
commit
890e7c4514
|
@ -3,6 +3,7 @@ from include.common_classes_60 import PandoraWebDriverTestCase
|
||||||
from include.common_functions_60 import login, click_menu_element, detect_and_pass_all_wizards, gen_random_string
|
from include.common_functions_60 import login, click_menu_element, detect_and_pass_all_wizards, gen_random_string
|
||||||
from include.agent_functions import create_agent, delete_agent
|
from include.agent_functions import create_agent, delete_agent
|
||||||
from include.api_functions import *
|
from include.api_functions import *
|
||||||
|
from include.bulk_operations import *
|
||||||
from selenium import webdriver
|
from selenium import webdriver
|
||||||
from selenium.webdriver.common.by import By
|
from selenium.webdriver.common.by import By
|
||||||
from selenium.webdriver.common.keys import Keys
|
from selenium.webdriver.common.keys import Keys
|
||||||
|
@ -15,13 +16,13 @@ import unittest, time, re
|
||||||
class Bulk_operations(PandoraWebDriverTestCase):
|
class Bulk_operations(PandoraWebDriverTestCase):
|
||||||
|
|
||||||
test_name = u'Bulk_operation'
|
test_name = u'Bulk_operation'
|
||||||
test_description = u'Creation two agents and delete this agents using bulk operation'
|
test_description = u'Bulk operation tests'
|
||||||
tickets_associated = []
|
tickets_associated = []
|
||||||
|
|
||||||
def test_A_delete_agent_bulk_operations(self):
|
def test_A_delete_agent_bulk_operations(self):
|
||||||
|
|
||||||
u"""
|
u"""
|
||||||
Creation two agents and delete this agents using bulk operation'
|
Creation two agents and delete this agents using bulk operation
|
||||||
Ticket Associated = 3831
|
Ticket Associated = 3831
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
@ -50,6 +51,43 @@ class Bulk_operations(PandoraWebDriverTestCase):
|
||||||
|
|
||||||
self.assertRegexpMatches(self.close_alert_and_get_its_text(), r"^Are you sure[\s\S]$")
|
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(.,"Successfully deleted (2)")]').text,"Successfully deleted (2)")
|
self.assertEqual(self.driver.find_element_by_xpath('//div[@id="main"]//td[contains(.,"Successfully deleted (2)")]').text,"Successfully deleted (2)")
|
||||||
|
|
||||||
|
|
||||||
|
def test_B_edit_agents_group_bulk_operations(self):
|
||||||
|
|
||||||
|
u"""
|
||||||
|
Create two agents and edit group with bulk operation
|
||||||
|
"""
|
||||||
|
|
||||||
|
agent_name_1 = gen_random_string(6)
|
||||||
|
agent_name_2 = gen_random_string(6)
|
||||||
|
|
||||||
|
driver = self.driver
|
||||||
|
self.login()
|
||||||
|
detect_and_pass_all_wizards
|
||||||
|
|
||||||
|
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")
|
||||||
|
|
||||||
|
lista = driver.current_url.split('/')
|
||||||
|
|
||||||
|
url = lista[0]+'//'+lista[2]+'/pandora_console'
|
||||||
|
|
||||||
|
driver.get(url)
|
||||||
|
|
||||||
|
agent_names_list = [agent_name_1,agent_name_2]
|
||||||
|
|
||||||
|
edit_agents_in_bulk(driver,agent_names_list,new_group="Web")
|
||||||
|
|
||||||
|
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)")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
unittest.main()
|
unittest.main()
|
||||||
|
|
|
@ -0,0 +1,45 @@
|
||||||
|
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
from selenium import selenium
|
||||||
|
from selenium.webdriver.common.by import By
|
||||||
|
from selenium.webdriver.support.ui import WebDriverWait, Select
|
||||||
|
from selenium.webdriver.support import expected_conditions as EC
|
||||||
|
from common_functions_60 import *
|
||||||
|
|
||||||
|
import random, time
|
||||||
|
import string
|
||||||
|
|
||||||
|
def delete_agents_in_bulk(driver,agent_names_list):
|
||||||
|
|
||||||
|
click_menu_element(driver,"Agent operations")
|
||||||
|
driver.find_element_by_id("option").click()
|
||||||
|
Select(driver.find_element_by_id("option")).select_by_visible_text("Delete agents in bulk")
|
||||||
|
|
||||||
|
for agent_name in agent_names_list:
|
||||||
|
Select(driver.find_element_by_id("id_agents")).select_by_visible_text(agent_name)
|
||||||
|
|
||||||
|
driver.find_element_by_id("submit-go").click()
|
||||||
|
|
||||||
|
|
||||||
|
def edit_agents_in_bulk(driver,agent_names_list,new_group=None,new_description=None):
|
||||||
|
|
||||||
|
click_menu_element(driver,"Agent operations")
|
||||||
|
driver.find_element_by_id("option").click()
|
||||||
|
Select(driver.find_element_by_id("option")).select_by_visible_text("Edit agents in bulk")
|
||||||
|
|
||||||
|
for agent_name in agent_names_list:
|
||||||
|
Select(driver.find_element_by_id("id_agents")).select_by_visible_text(agent_name)
|
||||||
|
|
||||||
|
time.sleep(3)
|
||||||
|
|
||||||
|
if new_group != None:
|
||||||
|
#driver.find_element_by_id("group").click()
|
||||||
|
Select(driver.find_element_by_id("group")).select_by_visible_text(new_group)
|
||||||
|
|
||||||
|
if new_description != None:
|
||||||
|
|
||||||
|
driver.find_element_by_id("text-description").clear()
|
||||||
|
driver.find_element_by_id("text-description").send_keys(new_description)
|
||||||
|
|
||||||
|
driver.find_element_by_id("submit-updbutton").click()
|
||||||
|
|
Loading…
Reference in New Issue