Add log file in ACL.py and Alerts.py

This commit is contained in:
cesar991 2017-01-09 12:17:51 +01:00
parent 9b02510599
commit 38a8eeb437
2 changed files with 22 additions and 1 deletions

View File

@ -13,6 +13,7 @@ from selenium.common.exceptions import NoSuchElementException
from selenium.common.exceptions import NoAlertPresentException from selenium.common.exceptions import NoAlertPresentException
from selenium.webdriver.remote.webelement import WebElement from selenium.webdriver.remote.webelement import WebElement
import unittest2, time, re import unittest2, time, re
import logging
class ACLPropagation(PandoraWebDriverTestCase): class ACLPropagation(PandoraWebDriverTestCase):
@ -26,6 +27,9 @@ class ACLPropagation(PandoraWebDriverTestCase):
ACL Propagation test: Creates one group "A" with ACL propagation, then a group "B" son of "A" with no ACL propagation, and finally group "C". ACL Propagation test: Creates one group "A" with ACL propagation, then a group "B" son of "A" with no ACL propagation, and finally group "C".
The test asserts if a user with privileges to "A" can see the agent of "B" but no agents of "C". The test asserts if a user with privileges to "A" can see the agent of "B" but no agents of "C".
""" """
logging.basicConfig(filename="ACL.log", level=logging.INFO, filemode='w')
group_name_A = gen_random_string(6) group_name_A = gen_random_string(6)
group_name_B = gen_random_string(6) group_name_B = gen_random_string(6)
group_name_C = gen_random_string(6) group_name_C = gen_random_string(6)
@ -69,6 +73,8 @@ class ACLPropagation(PandoraWebDriverTestCase):
search_agent(driver,agent_name_B,go_to_agent=False) search_agent(driver,agent_name_B,go_to_agent=False)
element = driver.find_elements_by_xpath('//a[contains(.,"'+agent_name_B+'")]') element = driver.find_elements_by_xpath('//a[contains(.,"'+agent_name_B+'")]')
self.assertEqual(element,[]) self.assertEqual(element,[])
logging.info("test_ACL_propagation is correct")
class ACLReports(PandoraWebDriverTestCase): class ACLReports(PandoraWebDriverTestCase):
@ -124,6 +130,8 @@ class ACLReports(PandoraWebDriverTestCase):
element = driver.find_element_by_xpath('//td[contains(.,"No data found.")]') element = driver.find_element_by_xpath('//td[contains(.,"No data found.")]')
self.assertIsInstance(element,WebElement) self.assertIsInstance(element,WebElement)
logging.info("test_ACL_reports is correct")
class ACLTags(PandoraWebDriverTestCase): class ACLTags(PandoraWebDriverTestCase):
test_name = u'ACL tag test' test_name = u'ACL tag test'
@ -175,6 +183,8 @@ class ACLTags(PandoraWebDriverTestCase):
#The user should NOT be able to see the module without tag #The user should NOT be able to see the module without tag
#modules = driver.find_elements_by_xpath('//td[contains(.,"'+module_name_A+'")]') #modules = driver.find_elements_by_xpath('//td[contains(.,"'+module_name_A+'")]')
#self.assertEqual(modules,[]) #self.assertEqual(modules,[])
#logging.info("test_ACL_tag is correct")
if __name__ == "__main__": if __name__ == "__main__":
unittest2.main() unittest2.main()

View File

@ -10,6 +10,7 @@ from selenium.common.exceptions import StaleElementReferenceException, NoSuchEle
from selenium.common.exceptions import NoAlertPresentException from selenium.common.exceptions import NoAlertPresentException
from selenium.webdriver.remote.webelement import WebElement from selenium.webdriver.remote.webelement import WebElement
import unittest2, time, re import unittest2, time, re
import logging
class Alerts (PandoraWebDriverTestCase): class Alerts (PandoraWebDriverTestCase):
@ -21,7 +22,9 @@ class Alerts (PandoraWebDriverTestCase):
u""" u"""
Create a new alert action using eMail command and check that create ok Create a new alert action using eMail command and check that create ok
""" """
logging.basicConfig(filename="Alerts.log", level=logging.INFO, filemode='w')
action_name = gen_random_string(6) action_name = gen_random_string(6)
driver = self.driver driver = self.driver
@ -38,6 +41,8 @@ class Alerts (PandoraWebDriverTestCase):
element = driver.find_element_by_xpath('//a[contains(.,"'+action_name+'")]') element = driver.find_element_by_xpath('//a[contains(.,"'+action_name+'")]')
self.assertIsInstance(element,WebElement) self.assertIsInstance(element,WebElement)
logging.info("test_A_create_new_email_action is correct")
def test_B_create_new_action_command(self): def test_B_create_new_action_command(self):
u""" u"""
@ -67,6 +72,8 @@ class Alerts (PandoraWebDriverTestCase):
element = driver.find_element_by_xpath('//a[contains(.,"'+action_name+'")]') element = driver.find_element_by_xpath('//a[contains(.,"'+action_name+'")]')
self.assertIsInstance(element,WebElement) self.assertIsInstance(element,WebElement)
logging.info("test_B_create_new_action_command")
def test_C_create_new_template(self): def test_C_create_new_template(self):
u""" u"""
@ -93,6 +100,8 @@ class Alerts (PandoraWebDriverTestCase):
element = driver.find_element_by_xpath('//a[contains(.,"'+template_name+'")]') element = driver.find_element_by_xpath('//a[contains(.,"'+template_name+'")]')
self.assertIsInstance(element,WebElement) self.assertIsInstance(element,WebElement)
logging.info("test_C_create_new_template is correct")
def test_D_edit_template_created(self): def test_D_edit_template_created(self):
u""" u"""
@ -138,6 +147,8 @@ class Alerts (PandoraWebDriverTestCase):
self.assertEqual("_agentdescription_" in driver.page_source,True) self.assertEqual("_agentdescription_" in driver.page_source,True)
logging.info("test_D_edit_template_created is correct")
if __name__ == "__main__": if __name__ == "__main__":
unittest2.main() unittest2.main()