def testNoAccessRole(self): self.testname="TestNoAccessRole" self.setup() util = WebdriverUtilities() util.setDriver(self.driver) element = Elements() do = Helpers(self) do.setUtils(util) do.login() email = config.reader1 reader = config.reader2 password = config.same_password title = "Auto_Private_" + do.getTimeId() + str(do.getRandomNumber()) do.createObject("Program", title, "checked") do.verifyObjectIsCreatedinLHN("Program", title) do.assertEqual(1, do.countOfAnyObjectLHS("Program"), "Expect count to be 1 but don't see it.") # now log out and then log in with the new account and try to create a program do.selectMenuInTopRight("Logout") # Refresh the page do.refresh() # Log in with new user do.login(reader, password) print "Log in as : " + do.whoAmI() do.uncheckMyWorkBox() try: do.verifyObjectIsCreatedinLHN("Program", title) except: do.assertEqual(0, do.countOfAnyObjectLHS("Program"), "Expect count to be 0 but don't see it.") print "Good...private program should not be visible to reader role unless permitted."
def testSaveAndAddAnotherPerson(self): self.testname="TestSaveAndAddAnotherPerson" self.setup() util = WebdriverUtilities() util.setDriver(self.driver) element = Elements() do = Helpers(self) do.setUtils(util) do.login() object_1_name = do.generateNameForTheObject("Person") do.delay(10) # count number does not appear right away, weird object_2_name = "Person_" + str(do.getRandomNumber()) do.ensureLHNSectionExpanded("Person") do.uncheckMyWorkBox() count_before = do.countOfAnyObjectLHS("Person") do.createObjectSaveAddAnother("Person", object_1_name, "unchecked", True, "", False) do.createObjectSaveAddAnother("Person", object_2_name, "unchecked", False, "", True) do.clearSearchBoxOnLHS() #clear any text so total count displays do.ensureLHNSectionExpanded("Person") do.uncheckMyWorkBox() count_after = do.countOfAnyObjectLHS("Person") do.delay(10) do.assertEqual(count_after, count_before+2, "Count has not incremented by 1 as expected.") print "Object 1: " object_1_link = do.verifyObjectIsCreatedinLHN("Person", object_1_name) do.navigateToObjectAndOpenObjectEditWindow("Person",object_1_link) do.deleteObject() print "Object 2: " object_2_link = do.verifyObjectIsCreatedinLHN("Person", object_2_name) do.navigateToObjectAndOpenObjectEditWindow("Person",object_2_link) do.deleteObject()
def testImportExportPeople(self): self.testname="TestImportExportPeople" self.setup() util = WebdriverUtilities() util.setDriver(self.driver) do = Helpers(self) do.setUtils(util) do.login() # create a person number = str(do.getRandomNumber()) aEmail = "email" + number + "@gmail.com" aName = "name" + number aCompany = "company" + number do.createPersonLHN(aName, aEmail, aCompany) do.uncheckMyWorkBox() do.navigateToObjectWithSearch(aName, "Person") print "" print "On screen." print "User is displayed as : " + aName print "Email is displayed as : " + aEmail print "Company is displayed as : " + aCompany # export people filePath = config.test_db + "PEOPLE.csv" print filePath do.selectMenuInTopRight("Admin Dashboard") do.exportFile("people", filePath) # verify that information in file matched self.assertTrue(do.verifyPeopleExportFile(aName, aEmail, aCompany, filePath), "User not found in exported file.") # import people # create some data, add it to the import file and upload number = str(do.getRandomNumber()) aEmail = "emailImport" + number + "@gmail.com" aName = "nameImport" + number aCompany = "companyImport" + number print "" print "Add this new user info to the import file and upload." print "User name: " + aName print "Email: " + aEmail print "Company: " + aCompany userInfo = aName + "," + aEmail + "," + aCompany # proof: verify that this user never exist in the database do.navigateToObjectWithSearchWithNoAssertion(aName, "Person") count = do.countOfAnyObjectLHS("Person") self.assertEqual(0, count, "User " + aName + " is verified not existed.") do.appendToFile(userInfo, filePath) do.importFile("People", filePath) do.refresh() # after import, verify that user has been added to the database do.navigateToObjectWithSearch(aName, "Person") count = do.countOfAnyObjectLHS("Person") self.assertEqual(1, count, "User " + aName + " is verified not existed.") self.assertEqual(aName, do.getObjectNavWidgetInfo("username"), "User's name " + aName + " is not found in the database.") self.assertEqual(aEmail, do.getObjectNavWidgetInfo("email"), "User's email " + aEmail + " is not found in the database.") self.assertEqual(aCompany, do.getObjectNavWidgetInfo("company"), "User's company " + aCompany + " is not found in the database.") print "" print "User is imported successfully and found in the database." print aName + "," + aEmail + "," + aCompany
def testMyWorkPageGeneral(self): self.testname="TestMyWorkPageGeneral" self.setup() util = WebdriverUtilities() util.setDriver(self.driver) element = Elements() do = Helpers(self) do.setUtils(util) do.login() item_input = ['Program', 'Workflow', 'Audit', 'Regulation', 'Policy', 'Standard', 'Contract', 'Clause', 'Section', \ 'Objective', 'Control', 'Person', 'OrgGroup', 'Vendor', 'System', 'Process', 'DataAsset', 'Product', \ 'Project', 'Facility', 'Market'] # open menu do.showLHMenu(True) # All and my object radio buttons exist? do.assertTrue(do.isMyObjectsOnlyPresent(), "My objects only radio button does not exist") do.assertTrue(do.isMyObjectsOnlyChecked(), "My objects only is not checked by default") # get counts for each type of object my_list = [] for object in item_input: count_my = do.countOfAnyObjectLHS(object) my_list.append(count_my) do.assertTrue(do.isAllObjectsPresent(), "All objects radio button does not exist") do.assertFalse(do.isAllObjectsChecked(), "All objects is checked by default which is wrong") do.uncheckMyWorkBox() # select all radio # program, workflows, audits with count in the parenthesis should update and should be different than in the above # get counts for each type of object all_list = [] for object in item_input: count_all = do.countOfAnyObjectLHS(object) all_list.append(count_all) # counts are not updating; it's likely that there is a difference count_updated = False total_items = len(item_input) for object_count in my_list: my_count = my_list.pop() all_count = all_list.pop() total_items = total_items - 1 if not my_count == all_count: count_updated = True break # good, it updates else: if total_items == 0: do.assertTrue(count_updated, "Count of objects do not update. Error.") # verify that objects created by different users show up; repeat for all different object type # PRE-REQUISITES: There are at least 2 objects created by 2 different users for each object type print ("WARNING !!!") print ("PRE-REQUISITES: There are at least 2 objects created by 2 different users for each object type") for object in item_input: do.verifyAllUsersObjectsShown(object) # verify to each items in the LHS exist and labels are correct expected = ['Programs', 'Workflows', 'Audits', 'Regulations', 'Policies', 'Standards', 'Contracts', 'Clauses', 'Sections', \ 'Objectives', 'Controls', 'People', 'Org Groups', 'Vendors', 'Systems', 'Processes', 'Data Assets', 'Products', \ 'Projects', 'Facilities', 'Markets'] dictionary = dict(zip(item_input, expected)) for object in item_input: raw = do.getItemLabelInLHS(object) if object == 'OrgGroup' or \ object == 'DataAsset': Nth = 2 else: Nth = 1 filtered = do.getTextUpToNthSpace(raw, Nth) expected_text = dictionary.get(object) do.assertTrue(do.compareText(filtered, expected_text), "Mismatch text for object: " + filtered) # add help content and verify do.addHelpTitleContent("Help Me", "I will help you.") do.clickHelpTopRightCorner() do.assertEqual(do.getHelpTitle(), "Help Me", "Fail to get Help title.") #do.assertEqual(do.getHelpContent(), "I will help you.", "Fail to get Help content.") do.clickHelpDone() # click help icon, then click outside of modal do.clickHelpIcon() do.clickMyTasksIcon()
def testRelevantMapping(self): self.testname="TestRelevantMapping" self.setup() util = WebdriverUtilities() util.setDriver(self.driver) element = Elements() do = Helpers(self) do.setUtils(util) do.login() # mapping and un-mapping up to 3 levels: # Program->Policy->Section->Object titlePol = do.getUniqueString("policy") #regulation titlePrgm = do.getUniqueString("program") titleSec = do.getUniqueString("section") titleMkt = do.getUniqueString("market") print "Policy: " + titlePol print "Program: " + titlePrgm print "Section: " + titleSec print "Market: " + titleMkt # SETUP do.createObject("Market", titleMkt) do.createObject("Policy", titlePol) last_created_object_link = do.createObject("Program", titlePrgm) do.mapAObjectLHN("Policy", titlePol) # maps to a Policy object do.expandItemWidget("Policy", titlePol) # expand the item so that "+ Section" link is displayed do.createSectionFromInnerNavLink(titleSec) do.mapObjectToSectionFromInnerNav(titleSec) do.mapObjectFormFilling("Market", titleMkt) do.expandWidget4thTier(titleMkt) # Policy page do.navigateToObjectWithSearch(titlePol, "Policy") do.navigateToInnerNavSection("Market") do.assertEqual(0, do.countOfAnyObjectInWidget("market"), "Count is not 0 in Widget.") do.assertEqual(0, do.countOfAnyObjectInnerNav("market"), "Count is not 0 in InnerNav.") # Verification: you don't see person object from Program page # 1 because the creator is automatically mapped to the program do.navigateToObjectWithSearch(titlePrgm, "Program") do.navigateToInnerNavSection("Market") do.assertEqual(1, do.countOfAnyObjectInWidget("market"), "Count is not 1 in Widget.") do.assertEqual(1, do.countOfAnyObjectInnerNav("market"), "Count is not 1 in InnerNav.") # Verification: you see Market object in Section page do.navigateToObjectWithSearch(titleSec, "Section") do.navigateToInnerNavSection("Market") do.assertEqual(titleMkt, do.getTitleFromWidgetList(1, "Section")) do.assertEqual(1, do.countOfAnyObjectInWidget("market"), "Count is not 1 in Widget.") do.assertEqual(1, do.countOfAnyObjectInnerNav("market"), "Count is not 1 in InnerNav.") # Verification: you see section object from People page do.uncheckMyWorkBox() do.navigateToObjectWithSearch(titleMkt, "Market") do.navigateToInnerNavSection("Section") do.assertEqual(titleSec, do.getTitleFromWidgetList(1, "Market")) #STOP HERE do.assertEqual(1, do.countOfAnyObjectInWidget("section"), "Count is not 1 in Widget.") do.assertEqual(1, do.countOfAnyObjectInnerNav("section"), "Count is not 1 in InnerNav.") # **** Test making person object relevant and verify its effect ************************** do.navigateToObjectWithSearch(titlePol, "Regulation") # Before making it relevant do.navigateToInnerNavSection("Person") do.assertEqual(0, do.countOfAnyObjectInWidget("person"), "Count is not 0 in Widget.") do.assertEqual(0, do.countOfAnyObjectInnerNav("person"), "Count is not 0 in InnerNav.") do.navigateToInnerNavSection("Section") do.expandItemWidget("Section", titleSec) # expand the item so that "+ Section" link is displayed do._searchObjectIn3rdLevelAndClickOnIt(titleMkt, True) do.expandWidget4thTier(titleMkt, True) # Verification: you now see person object from Regulation page do.navigateToInnerNavSection("Person") do.assertEqual(1, do.countOfAnyObjectInWidget("person"), "Count is not 1 in Widget.") do.assertEqual(1, do.countOfAnyObjectInnerNav("person"), "Count is not 1 in InnerNav.") # Verification: you don't see person object from Program page # 1 because the creator is automatically mapped to the program do.navigateToObjectWithSearch(titlePrgm, "Program") do.navigateToInnerNavSection("Person") do.assertEqual(1, do.countOfAnyObjectInWidget("person"), "Count is not 1 in Widget.") do.assertEqual(1, do.countOfAnyObjectInnerNav("person"), "Count is not 1 in InnerNav.") # Verification: regulation object appears in the widget on People page do.navigateToObjectWithSearch(titleMkt, "Person") do.navigateToInnerNavSection("regulation") title_fr_widget = do.getTitleFromWidgetList(1, "Person") do.assertEqual(titlePol, title_fr_widget, "Titles do match.")