Moving forward to 2.0 Framework

(cherry picked from commit bbe02ab8ff)
This commit is contained in:
cesar991 2016-08-16 15:04:37 +02:00 committed by axl89
parent fc1a7f0f99
commit c14618ac02
3 changed files with 90 additions and 34 deletions

View File

@ -1,26 +0,0 @@
# -*- coding: utf-8 -*-
from include.common_classes_60 import PandoraWebDriverTestCase
from include.common_functions_60 import login, click_menu_element, detect_and_pass_all_wizards
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support.ui import Select
from selenium.common.exceptions import NoSuchElementException
from selenium.common.exceptions import NoAlertPresentException
import unittest, time, re
class PAN1(PandoraWebDriverTestCase):
test_name = u'PAN_1'
test_description = u'Tests that an Administrator user can access the Setup'
tickets_associated = []
def test_pan1(self):
driver = self.driver
self.login()
detect_and_pass_all_wizards(driver)
click_menu_element(driver,"General Setup")
self.assertEqual("IP list with API access", driver.find_element_by_id("table2-15-0").text)
if __name__ == "__main__":
unittest.main()

View File

@ -1,7 +1,8 @@
# -*- coding: utf-8 -*-
from include.common_classes_60 import PandoraWebDriverTestCase
from include.common_functions_60 import login, detect_and_pass_all_wizards, gen_random_string
from include.common_functions_60 import login, detect_and_pass_all_wizards, gen_random_string, is_enterprise
from include.policy_functions import *
from include.agent_functions import *
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys
@ -20,8 +21,13 @@ class Policies(PandoraWebDriverTestCase):
policy_name = gen_random_string(6)
network_server_module_name = gen_random_string(6)
def test_1_create_policy(self):
@is_enterprise
def test_A_create_policy(self):
u"""
Create a policy and verify that it is created
"""
driver = self.driver
self.login()
detect_and_pass_all_wizards(driver)
@ -33,8 +39,13 @@ class Policies(PandoraWebDriverTestCase):
element = driver.find_element_by_xpath('//a[contains(.,"'+self.policy_name+'")]')
self.assertIsInstance(element,WebElement)
def test_2_add_network_server_module_to_policy(self):
@is_enterprise
def test_B_add_network_server_module_to_policy(self):
u"""
Add network server module to previous policy
"""
driver = self.driver
add_module_policy(driver,self.policy_name,"network_server",driver,module_name=self.network_server_module_name,component_group="Network Management",network_component="Host Alive")
@ -42,6 +53,80 @@ class Policies(PandoraWebDriverTestCase):
element = driver.find_element_by_xpath('//td[contains(.,"uccessfully")]')
self.assertIsInstance(element,WebElement)
@is_enterprise
def test_C_add_collection_to_policy(self):
u"""
Create policy, create collection and add collection to policy
"""
policy_name = gen_random_string(6)
collection_name = gen_random_string(6)
driver = self.driver
create_policy(driver,policy_name,"Applications",description="Policy for test")
create_collection(driver,collection_name,collection_name,group="All",description="Collection for test")
add_collection_to_policy(driver,policy_name,collection_name)
element = driver.find_element_by_xpath('//td[contains(.,"Correct: add the collection in the policy")]')
self.assertIsInstance(element,WebElement)
@is_enterprise
def test_D_Apply_policy_to_agents(self):
u"""
Create two agent, create a policy, create two modules in policy and apply policy in new agents, check that modules is created in agents
"""
policy_name = gen_random_string(6)
agent_name_1 = gen_random_string(6)
agent_name_2 = gen_random_string(6)
module_name_1 = gen_random_string(6)
module_name_2 = gen_random_string(6)
driver = self.driver
create_agent(driver,agent_name_1,description="First agent by test")
create_agent(driver,agent_name_2,description="Second agent 2 by test")
create_policy(driver,policy_name,"Applications",description="This is policy by test")
add_module_policy(driver,policy_name,"network_server",driver,module_name=module_name_1,component_group="Network Management",network_component="Host Alive")
add_module_policy(driver,policy_name,"network_server",driver,module_name=module_name_2,component_group="Network Management",network_component="Host Latency")
list_agent = (agent_name_1,agent_name_2)
apply_policy_to_agent(driver,policy_name,list_agent)
search_agent(driver,agent_name_1,go_to_agent=True)
driver.find_element_by_xpath('//*[@id="menu_tab"]/ul/li[1]/a/img').click()
driver.find_element_by_xpath('//*[@id="menu_tab"]/ul/li[3]/a/img').click()
module = driver.find_element_by_xpath('//td[contains(.,"'+module_name_1+'")]')
self.assertIsInstance(module,WebElement)
module = driver.find_element_by_xpath('//td[contains(.,"'+module_name_2+'")]')
self.assertIsInstance(module,WebElement)
search_agent(driver,agent_name_2,go_to_agent=True)
driver.find_element_by_xpath('//*[@id="menu_tab"]/ul//img[@data-title="Manage"]').click()
driver.find_element_by_xpath('//ul[@class="mn"]/li/a/img[@data-title="Modules"]').click()
module = driver.find_element_by_xpath('//td[contains(.,"'+module_name_1+'")]')
self.assertIsInstance(module,WebElement)
module = driver.find_element_by_xpath('//td[contains(.,"'+module_name_2+'")]')
self.assertIsInstance(module,WebElement)
if __name__ == "__main__":
unittest.main()

View File

@ -15,10 +15,7 @@ is_enterprise = '1' == getenv('ENTERPRISE', False)
a = TestLoader()
if is_enterprise:
tests = a.discover(start_dir='console',pattern='*.py')
else:
tests = a.discover(start_dir='console',pattern='PAN*.py')
tests = a.discover(start_dir='console',pattern='*.py')
c = ArticaTestResult()
tests.run(c)