Add log file in Collections.py and Bulk_operations.py

This commit is contained in:
cesar991 2017-01-09 14:45:32 +01:00
parent 38a8eeb437
commit 037478fd53
3 changed files with 30 additions and 3 deletions

View File

@ -72,7 +72,7 @@ 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") logging.info("test_B_create_new_action_command is correct")
def test_C_create_new_template(self): def test_C_create_new_template(self):

View File

@ -14,6 +14,7 @@ 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 Bulk_operations(PandoraWebDriverTestCase): class Bulk_operations(PandoraWebDriverTestCase):
@ -28,6 +29,8 @@ class Bulk_operations(PandoraWebDriverTestCase):
Ticket Associated = 3831 Ticket Associated = 3831
""" """
logging.basicConfig(filename="Bulk_operations.log", level=logging.INFO, filemode='w')
agent_name_1 = gen_random_string(6) agent_name_1 = gen_random_string(6)
agent_name_2 = gen_random_string(6) agent_name_2 = gen_random_string(6)
@ -54,6 +57,8 @@ 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)")
logging.info("test_A_delete_agent_bulk_operations is correct")
def test_B_edit_agents_group_bulk_operations(self): def test_B_edit_agents_group_bulk_operations(self):
u""" u"""
@ -86,6 +91,8 @@ 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(.,"Agents updated successfully(2)")]').text,"Agents updated successfully(2)") self.assertEqual(self.driver.find_element_by_xpath('//div[@id="main"]//td[contains(.,"Agents updated successfully(2)")]').text,"Agents updated successfully(2)")
logging.info("test_B_edit_agents_group_bulk_operations is correct")
def test_C_edit_agent_description_bulk_operation(self): def test_C_edit_agent_description_bulk_operation(self):
u""" u"""
@ -122,6 +129,8 @@ class Bulk_operations(PandoraWebDriverTestCase):
self.assertEqual("test C edit description bulk operation" in driver.page_source,True) self.assertEqual("test C edit description bulk operation" in driver.page_source,True)
logging.info("test_C_edit_agent_description_bulk_operation is correct")
def test_D_delete_modules_in_bulk(self): def test_D_delete_modules_in_bulk(self):
u""" u"""
@ -169,6 +178,7 @@ class Bulk_operations(PandoraWebDriverTestCase):
self.assertEqual(element,[]) self.assertEqual(element,[])
logging.info("test_D_delete_modules_in_bulk is correct")
def test_E_edit_module_group_in_bulk(self): def test_E_edit_module_group_in_bulk(self):
@ -215,6 +225,7 @@ class Bulk_operations(PandoraWebDriverTestCase):
self.assertEqual("Users" in driver.page_source,True) self.assertEqual("Users" in driver.page_source,True)
logging.info("test_E_edit_module_group_in_bulk is correct")
def test_F_edit_module_umbral_in_bulk(self): def test_F_edit_module_umbral_in_bulk(self):
@ -267,7 +278,7 @@ class Bulk_operations(PandoraWebDriverTestCase):
element = driver.find_element_by_xpath('//tr//td[contains(.,"2")]') element = driver.find_element_by_xpath('//tr//td[contains(.,"2")]')
self.assertIsInstance(element,WebElement) self.assertIsInstance(element,WebElement)
logging.info("test_F_edit_module_umbral_in_bulk is correct")
def test_G_edit_module_threshold_in_bulk(self): def test_G_edit_module_threshold_in_bulk(self):
@ -324,6 +335,8 @@ class Bulk_operations(PandoraWebDriverTestCase):
element = driver.find_element_by_xpath('//tr//td[contains(.,"2")]') element = driver.find_element_by_xpath('//tr//td[contains(.,"2")]')
self.assertIsInstance(element,WebElement) self.assertIsInstance(element,WebElement)
logging.info("test_G_edit_module_threshold_in_bulk is correct")
def test_H_copy_modules_in_bulk(self): def test_H_copy_modules_in_bulk(self):
u""" u"""
@ -374,6 +387,7 @@ class Bulk_operations(PandoraWebDriverTestCase):
self.assertEqual(module_name_1 in driver.page_source,True) self.assertEqual(module_name_1 in driver.page_source,True)
logging.info("test_H_copy_modules_in_bulk is correct")
if __name__ == "__main__": if __name__ == "__main__":
unittest2.main() unittest2.main()

View File

@ -12,8 +12,9 @@ from selenium.webdriver.support.ui import Select
from selenium.common.exceptions import NoSuchElementException 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 Collections(PandoraWebDriverTestCase): class Collections(PandoraWebDriverTestCase):
@ -27,6 +28,8 @@ class Collections(PandoraWebDriverTestCase):
@is_enterprise @is_enterprise
def test_A_create_collection(self): def test_A_create_collection(self):
logging.basicConfig(filename="Collections.log", level=logging.INFO, filemode='w')
driver = self.driver driver = self.driver
self.login() self.login()
detect_and_pass_all_wizards(driver) detect_and_pass_all_wizards(driver)
@ -38,6 +41,8 @@ class Collections(PandoraWebDriverTestCase):
element = driver.find_element_by_xpath('//a[contains(.,self.collection_name)]') element = driver.find_element_by_xpath('//a[contains(.,self.collection_name)]')
self.assertIsInstance(element,WebElement) self.assertIsInstance(element,WebElement)
logging.info("test_A_create_collection is correct")
@is_enterprise @is_enterprise
def test_B_edit_collection(self): def test_B_edit_collection(self):
@ -50,6 +55,8 @@ class Collections(PandoraWebDriverTestCase):
element = driver.find_element_by_xpath('//a[contains(.,self.new_collection_name)]') element = driver.find_element_by_xpath('//a[contains(.,self.new_collection_name)]')
self.assertIsInstance(element,WebElement) self.assertIsInstance(element,WebElement)
logging.info("test_B_edit_collection is correct")
@is_enterprise @is_enterprise
def test_C_create_text_collection(self): def test_C_create_text_collection(self):
@ -60,6 +67,8 @@ class Collections(PandoraWebDriverTestCase):
element = driver.find_element_by_xpath('//a[contains(.,"file_collectionPAN11")]') element = driver.find_element_by_xpath('//a[contains(.,"file_collectionPAN11")]')
self.assertIsInstance(element,WebElement) self.assertIsInstance(element,WebElement)
logging.info("test_C_create_text_collection is correct")
@is_enterprise @is_enterprise
def test_D_directory_collection(self): def test_D_directory_collection(self):
@ -70,6 +79,8 @@ class Collections(PandoraWebDriverTestCase):
element = driver.find_element_by_xpath('//a[contains(.,"directory_collectionPAN11")]') element = driver.find_element_by_xpath('//a[contains(.,"directory_collectionPAN11")]')
self.assertIsInstance(element,WebElement) self.assertIsInstance(element,WebElement)
logging.info("test_D_directory_collection is correct")
@is_enterprise @is_enterprise
def test_E_delete_collection(self): def test_E_delete_collection(self):
@ -81,5 +92,7 @@ class Collections(PandoraWebDriverTestCase):
element = driver.find_elements_by_xpath('//a[contains(.,"'+self.new_collection_name+'")]') element = driver.find_elements_by_xpath('//a[contains(.,"'+self.new_collection_name+'")]')
self.assertEqual(element,[]) self.assertEqual(element,[])
logging.info("test_E_delete_collection is correct")
if __name__ == "__main__": if __name__ == "__main__":
unittest2.main() unittest2.main()