def testAllTabsIntegrity(self): self.testname="TestAllTabsIntegrity" self.setup() util = WebdriverUtilities() util.setDriver(self.driver) element = Elements() do = Helpers(self) do.setUtils(util) do.login() directive_xpath = '//a[(@class="governance list-toggle" and @data-object-singular="OBJECT")]' self.assertEqual("PROGRAMS", self._returnStringUpToFirstSpace(do.util.getTextFromXpathString(element.left_nav_expand_object_section_link.replace("OBJECT", "Program")))) self.assertEqual("AUDITS", self._returnStringUpToFirstSpace(do.util.getTextFromXpathString(element.left_nav_expand_object_section_link.replace("OBJECT", "Audit")))) temp = do.util.getTextFromXpathString('//a[(@class="governance list-toggle" and @data-object-singular="Regulation")]') self.assertEqual("REGULATIONS", self._returnStringUpToFirstSpace(do.util.getTextFromXpathString(self.directive_xpath.replace("OBJECT", "Regulation")))) self.assertEqual("POLICIES", self._returnStringUpToFirstSpace(directive_xpath.replace("OBJECT", "Policy"))) self.assertEqual("STANDARDS", self._returnStringUpToFirstSpace(directive_xpath.replace("OBJECT", "Standard"))) self.assertEqual("CONTRACTS", self._returnStringUpToFirstSpace(directive_xpath.replace("OBJECT", "Contract"))) self.assertEqual("CLAUSES", self._returnStringUpToFirstSpace(directive_xpath.replace("OBJECT", "Clause"))) self.assertEqual("Sections", self._returnStringUpToFirstSpace(directive_xpath.replace("OBJECT", "Section"))) self.assertEqual("Objectives", self._returnStringUpToFirstSpace(do.util.getTextFromXpathString(element.left_nav_expand_object_section_link.replace("OBJECT", "Objective")))) self.assertEqual("Controls", self._returnStringUpToFirstSpace(do.util.getTextFromXpathString(element.left_nav_expand_object_section_link.replace("OBJECT", "Control")))) self.assertEqual("People", self._returnStringUpToFirstSpace(do.util.getTextFromXpathString(element.left_nav_expand_object_section_link.replace("OBJECT", "Person")))) self.assertEqual("Org Groups", do.util.getTextFromXpathString(element.left_nav_org_group_link)[0:10]) self.assertEqual("Systems", self._returnStringUpToFirstSpace(do.util.getTextFromXpathString(element.left_nav_expand_object_section_link.replace("OBJECT", "System")))) self.assertEqual("Processes", self._returnStringUpToFirstSpace(do.util.getTextFromXpathString(element.left_nav_expand_object_section_link.replace("OBJECT", "Process")))) self.assertEqual("Data Assets", do.util.getTextFromXpathString(element.left_nav_data_asset_link)[0:11]) self.assertEqual("Products", self._returnStringUpToFirstSpace(do.util.getTextFromXpathString(element.left_nav_expand_object_section_link.replace("OBJECT", "Product")))) self.assertEqual("Projects", self._returnStringUpToFirstSpace(do.util.getTextFromXpathString(element.left_nav_expand_object_section_link.replace("OBJECT", "Project")))) self.assertEqual("Facilities", self._returnStringUpToFirstSpace(do.util.getTextFromXpathString(element.left_nav_expand_object_section_link.replace("OBJECT", "Facility")))) self.assertEqual("Markets", do.util.getTextFromXpathString(element.left_nav_market_link)[0:7])
def __evaluate_inspect(condition_tmp: Condition = None, game_status_tmp: GameStatus = None): evaluated = False LoggingController.logger.debug( "Evaluating: " + str(inspect.currentframe().f_code.co_name)) # verify size of elements in the condition if len(condition_tmp.list) >= 2: inspect_type = condition_tmp.list[0] artifact_id = condition_tmp.list[1] store_name = condition_tmp.list[2] fourth_element = condition_tmp.list[3] if (len(condition_tmp.list) == 3) else None fifth_element = condition_tmp.list[4] if (len(condition_tmp.list) == 4) else None player = fourth_element if ( fifth_element is not None and Helpers.is_player( game_status_tmp, fourth_element)) else None role = fifth_element if (player is None and Helpers.is_role( game_status_tmp, fourth_element)) else None commitment_timing = fifth_element if (fifth_element is not None) else None data = { 'inspect_type': inspect_type, 'artifact_id': artifact_id, 'store_name': store_name, 'player': player, 'role': role, 'commitment_timing': commitment_timing } if inspect_type in InspectEvaluator.__options: evaluated = InspectEvaluator.__options[inspect_type].__func__( data, evaluated, game_status_tmp) return evaluated
def testReindex(self): self.testname="deleteObject" self.setup() util = WebdriverUtilities() util.setDriver(self.driver) do = Helpers(self) do.setUtils(util) do.login() util.driver.execute_script(REINDEX_SCRIPT) time.sleep(90)
def testLogin(self): self.testname="TestLogin" self.setup() util = WebdriverUtilities() util.setDriver(self.driver) element = Elements() do = Helpers(self) do.setUtils(util) do.login() self.assertTrue(util.isElementPresent(element.dashboard_title), "no dashboard page found")
def testSystemCreate(self): self.testname="TestSystemCreate" self.setup() util = WebdriverUtilities() util.setDriver(self.driver) do = Helpers(self) do.setUtils(util) do.login() last_created_object_link =do.createObject("System") #object_name = str(util.getTextFromXpathString(last_created_object_link)).strip() do.navigateToObjectAndOpenObjectEditWindow("System",last_created_object_link) do.deleteObject()
def testSectionCreate(self): self.testname="TestSectionCreate" self.setup() util = WebdriverUtilities() util.setDriver(self.driver) element = Elements() do = Helpers(self) do.setUtils(util) do.login() last_created_object_link =do.createObjectSaveAddAnother("Section", "", "unchecked") do.navigateToObjectAndOpenObjectEditWindow("Section",last_created_object_link) do.deleteObject()
def testProgramCreate(self): self.testname="TestProgramCreate" self.setup() util = WebdriverUtilities() util.setDriver(self.driver) element = Elements() do = Helpers(self) do.setUtils(util) do.login() last_created_object_link =do.createObject("Program") do.navigateToObjectAndOpenObjectEditWindow("Program",last_created_object_link) do.deleteObject()
def __init__(self): super().__init__() self.db = DataBaseManager() self.check_manager = CheckManager() self.warning_manager = WarningManager() self.email_notifications = EmailNotifications() self.helpers = Helpers()
def __init__(self, user_name): self.USER_NAME = user_name self.db = DataBaseManager() self.check_manager = CheckManager() self.warning_manager = WarningManager() self.email_notifications = EmailNotifications() self.helpers = Helpers()
def testPolicyMapWidget(self): self.testname="TestPolicyMapWidget" self.setup() util = WebdriverUtilities() util.setDriver(self.driver) element = Elements() grcobject = GRCObject() do = Helpers(self) do.setUtils(util, "Policy") do.login() policy_name = "Policy for Auto Mapping from Widget" +do.getTimeId() last_created_object_link = do.createObject("Policy", policy_name) for obj in grcobject.policy_map_to_widget: do.mapAObjectWidget(obj, policy_name, False, ("Section", "Objective", "Control"))
def testProgramMapWidget(self): self.testname="TestProgramMapWidget" self.setup() util = WebdriverUtilities() util.setDriver(self.driver) element = Elements() grcobject = GRCObject() do = Helpers(self) do.setUtils(util, "Program") do.login() program_name = "Program for Auto Mapping from Widget" + do.getTimeId() last_created_object_link = do.createObject("Program", program_name) for obj in grcobject.program_map_to_widget: do.mapAObjectWidget(obj, "", True, ("Control", "Objective", "System"))
def testDataAssetMapWidget(self): self.testname="TestDataAssetMapWidget" self.setup() util = WebdriverUtilities() util.setDriver(self.driver) element = Elements() grcobject = GRCObject() do = Helpers(self) do.setUtils(util, "DataAsset") do.login() data_asset_name = "DataAsset for Auto Mapping from Widget" +do.getTimeId() last_created_object_link = do.createObject("DataAsset",data_asset_name) for obj in grcobject.data_asset_map_to_widget: do.mapAObjectWidget(obj)
def testControlMapWidget(self): self.testname="TestControlMapWidget" self.setup() util = WebdriverUtilities() util.setDriver(self.driver) element = Elements() grcobject = GRCObject() do = Helpers(self) do.setUtils(util, "Control") do.login() control_name = "Control for Auto Mapping from Widget" + do.getTimeId() last_created_object_link = do.createObject("Control", control_name) for obj in grcobject.control_map_to_widget: do.mapAObjectWidget(obj)
def testVendorMapWidget(self): self.testname="TestVendorMapWidget" self.setup() util = WebdriverUtilities() util.setDriver(self.driver) element = Elements() grcobject = GRCObject() do = Helpers(self) do.setUtils(util, "Vendor") do.login() vendor_name = "Vendor for Auto Mapping from Widget" + do.getTimeId() last_created_object_link = do.createObject("Vendor", vendor_name) for obj in grcobject.vendor_map_to_widget: do.mapAObjectWidget(obj, "")
def testOrgGroupMapWidget(self): self.testname="TestOrgGroupMapWidget" self.setup() util = WebdriverUtilities() util.setDriver(self.driver) element = Elements() grcobject = GRCObject() do = Helpers(self) do.setUtils(util, "OrgGroup") do.login() org_group_name = "OrgGroup for Auto Mapping from Widget" +do.getTimeId() last_created_object_link = do.createObject("OrgGroup",org_group_name) for obj in grcobject.org_group_map_to_widget: do.mapAObjectWidget(obj)
def testObjectiveMapLHN(self): self.testname="TestObjectiveMapLHN" self.setup() util = WebdriverUtilities() util.setDriver(self.driver) element = Elements() grcobject = GRCObject() do = Helpers(self) do.setUtils(util, "Objective") do.login() program_name = "Objective for Auto Mapping from LHN" +do.getTimeId() last_created_object_link = do.createObject("Objective", program_name) for obj in grcobject.objective_map_to_lhn: do.mapAObjectLHN(obj) #util.refreshPage() # test unmapping for obj in grcobject.objective_map_to_lhn: self.assertTrue(do.unmapAObjectFromWidget(obj))
def testFacilityMapLHN(self): self.testname="TestFacilityMapLHN" self.setup() util = WebdriverUtilities() util.setDriver(self.driver) element = Elements() grcobject = GRCObject() do = Helpers(self) do.setUtils(util, "Facility") do.login() system_name = "Facility for Auto Mapping from LHN" +do.getTimeId() last_created_object_link = do.createObject("Facility", system_name) for obj in grcobject.facility_map_to_lhn: do.mapAObjectLHN(obj) # test unmapping for obj in grcobject.facility_map_to_lhn: self.assertTrue(do.unmapAObjectFromWidget(obj))
def testObjectMapsToItself(self): self.testname="TestObjectMapsToItself" self.setup() util = WebdriverUtilities() util.setDriver(self.driver) element = Elements() grcobject = GRCObject() do = Helpers(self) do.setUtils(util, "Contract") do.login() contract_name = "Contract for Auto Mapping from LHN" +do.getTimeId() contract_map_to_lhn2 = ["Contract", "Program"] for obj in grcobject.contract_map_to_lhn2: last_created_object_link = do.createObject(obj, contract_name) do.mapAObjectLHN(obj) #util.refreshPage() # test unmapping for obj in grcobject.contract_map_to_lhn: self.assertTrue(do.unmapAObjectFromWidget(obj))
def __evaluate_move(effect_tmp: Effect = None, game_status_tmp: GameStatus = None): LoggingController.logger.debug( "Evaluating: " + str(inspect.currentframe().f_code.co_name)) # verify size of elements in the condition if len(effect_tmp.list) >= 3: permit_mandate = effect_tmp.list[0] which_move = effect_tmp.list[1] move_name = effect_tmp.list[2] fourth_element = None artifact = None player = None role = None if len(effect_tmp.list) == 4: fourth_element = effect_tmp.list[3] if Helpers.is_player(game_status_tmp, fourth_element): player = fourth_element elif Helpers.is_role(game_status_tmp, fourth_element): role = fourth_element if player is None and role is None: artifact = fourth_element elif len(effect_tmp.list) == 5: artifact = effect_tmp.list[3] player_or_role = effect_tmp.list[4] if Helpers.is_player(game_status_tmp, player_or_role): player = fourth_element elif Helpers.is_role(game_status_tmp, player_or_role): role = fourth_element data = { 'permit_mandate': permit_mandate, 'which_move': which_move, 'move_name': move_name, 'artifact': artifact, 'player': player, 'role': role } if permit_mandate in MoveEvaluator.__options: game_status_tmp = MoveEvaluator.__options[ permit_mandate].__func__(game_status_tmp, data) return game_status_tmp
def testDeleteObject(self): self.testname="TestDeleteObject" self.setup() util = WebdriverUtilities() util.setDriver(self.driver) element = Elements() do = Helpers(self) do.setUtils(util) do.login() do.clickActiveTab()
def __get_interaction_moves_with_failed_conditions( interaction_move_list: [], game_status_tmp: GameStatus) -> []: interaction_moves_not_meeting_conditions = [] if len(interaction_move_list) > 0: for interaction_move in interaction_move_list: move = Helpers.get_move_from_interaction_move( interaction_move, game_status_tmp) if move is not None: if not ConditionsController.__are_all_conditions_satisfied( move, game_status_tmp): interaction_moves_not_meeting_conditions.append( interaction_move) return [ x for x in interaction_move_list if x not in interaction_moves_not_meeting_conditions ]
def testRemoveObjectsFromLHS(self): self.testname="TestRemoveObjectsFromLHS" self.setup() util = WebdriverUtilities() util.setDriver(self.driver) element = Elements() do = Helpers(self) do.setUtils(util) do.login() myObjList = [ "Program", "Objective", "OrgGroup", "Regulation", "Contract", "Policy", "Control", "Section", "Person", "OrgGroup", "System", "Process", "DataAsset", "Product", "Project", "Facility", "Market", "Standard", "Audit"] do.searchLHS("auto") for obj in myObjList: print "Start deleting " + obj + " objects." do.deleteObjectsFromHLSMatching(obj, False)
def __init__(self, name, username, photo_profile, phonenumber, birthday_place, birthday, address, resume, headline, summary, email, link_instagram, link_linkedin, link_twitter, link_youtube, link_google_plus, link_facebook, password, type_theme): self.name = name self.username = username self.photo_profile = photo_profile self.phonenumber = phonenumber self.birthday_place = birthday_place self.birthday = birthday self.address = address self.resume = resume self.headline = headline self.summary = summary self.email = email self.link_instagram = link_instagram self.link_linkedin = link_linkedin self.link_twitter = link_twitter self.link_youtube = link_youtube self.link_google_plus = link_google_plus self.link_facebook = link_facebook self.password = Helpers().password_hash(password) self.type_theme = type_theme
def test_object_creation(self): '''Intialization & Setup''' self.testname="CreateObjectTests" # name the test case self.setup() # do the setup do = Helpers() # instantiate Helpers class util = WebdriverUtilities() # instantiate utilities class and pass it to Helper object (can remove complexity by inheritance etc and can use seleniumwrapper) util.setDriver(self.driver) do.setUtils(util) do.login() # login into the system '''Test case''' object_list = ["Regulation"] #object_list = ["Program", "Contract","Control","DataAsset","Facility","Market","Objective","OrgGroup","Policy","Process","Product", # "Project","Regulation","System","Standard","Clause"] for obj in object_list: obj_title = do.createObject(obj) title = self.driver.find_element_by_css_selector(".row-fluid.wrap-row:first-child .span6:first-child h3").text self.assertEqual(title, obj_title)
def testProgramAudit(self): self.testname="TestProgramAudit" self.setup() util = WebdriverUtilities() util.setDriver(self.driver) element = Elements() grcobject = GRCObject() do = Helpers(self) do.setUtils(util) do.login() # Read audit_setup_data to retrieve program name and the IDs of the 3 objectives # objectiveID={} # default to using setup file for TEST server setup_file = SETUP_FILE_PREFIX + TARGET_SERVER_DICT.get(config.url, "test") f = open(os.path.join(SETUP_DIR, setup_file), "r") program_name=f.readline().strip("\n") # 1. Navigate to the Program page created in Audit Part 1 #print first_program_in_lhn do.navigateToObjectWithSearch(program_name,"Program") util.max_screen() # 2. Choose Audit from Object page nav to bring up the Audit widget do.navigateToAuditSectionViaInnerNavSection("Audit") # 3. Click on blue +Audit link in widget util.clickOn(element.audit_area_plus_audit_link) # 4. New Audit (modal) do.authorizeGAPI() # Another place GAPI dialog could pop up new_audit_title = do.createAudit(program_name) # 5. Confirm the audit appear in the widget newly_created_audit = element.audit_area_by_title.replace("AUDIT_TITLE", new_audit_title) print newly_created_audit util.waitForElementToBePresent(newly_created_audit) self.assertTrue(util.isElementPresent(newly_created_audit), "do not see the newly created audit " +new_audit_title ) # 6. Click on it to open the 2nd tier info. confirm there are 3 requests in the PBC Requests section. # GAPI could pop up here do.authorizeGAPI() util.scrollIntoView(newly_created_audit) util.clickOn(newly_created_audit + element.first_link_within) #util.switch_to_active_element() util.max_screen() util.scrollIntoView(newly_created_audit) #verifying the 3 objectives do.dismissFlashMessages() for objective_title in grcobject.objective_title: objective_title_element = element.audit_pbc_request.replace("TITLE", objective_title) print objective_title_element util.waitForElementToBePresent(objective_title_element) self.assertTrue(util.isElementPresent(objective_title_element), "do not see the pbc request " + objective_title_element ) util.scrollIntoView(objective_title_element) #do.waitForAlertSuccessMessages() ####7. Change Objective 2 for Auto test of Audit - Type: Interview ###print "Change Objective 2 for Auto test of Audit - Type: Interview" #### navigate into PBC edit modal ####click on "Objective 2 for Auto test of Audit" to open 2nd tier info ###print "click on Objective 2 for Auto test of Audit to open 2nd tier info" ###do.expandCollapseRequest(grcobject.objective_title[1]) ####click on Edit PBC Request ###util.waitForElementToBePresent(element.audit_pbc_request_expanded_content_edit_link) ###self.assertTrue(util.isElementPresent(element.audit_pbc_request_expanded_content_edit_link), "do not see the Edit link in the expanded request " ) ###util.clickOn(element.audit_pbc_request_expanded_content_edit_link) ###objective2_selected_option = element.audit_pbc_request_modal_type_select_selected_option ###util.waitForElementToBePresent(element.audit_pbc_request_modal_type_select) ###util.selectFromDropdownUntilSelected(element.audit_pbc_request_modal_type_select, "Interview") ####verifying the selected option ### ###util.waitForElementToBePresent(objective2_selected_option) ###do.saveObjectData() ###util.clickOn(element.audit_pbc_request_expanded_content_edit_link) ###new_value = util.getTextFromXpathString(objective2_selected_option) ###self.assertTrue(new_value =="Interview" , "the selected option is not Interview" ) ####Delete ###print "deleting Request" ###do.deleteObject() ### #8. Change Objective 3 for Auto test of Audit - Type: Population Sample ###objective3_select = element.audit_pbc_request_type_select.replace("TITLE", grcobject.objective_title[2] ) ###do.expandCollapseRequest(grcobject.objective_title[2]) ####click on Edit PBC Request ###util.waitForElementToBePresent(element.audit_pbc_request_expanded_content_edit_link) ###self.assertTrue(util.isElementPresent(element.audit_pbc_request_expanded_content_edit_link), "do not see the Edit link in the expanded request " ) ###util.clickOn(element.audit_pbc_request_expanded_content_edit_link) ###objective3_selected_option = element.audit_pbc_request_modal_type_select_selected_option ###util.waitForElementToBePresent(element.audit_pbc_request_modal_type_select) ###util.selectFromDropdownUntilSelected(element.audit_pbc_request_modal_type_select, "Population Sample") ####verifying the selected option ### ###util.waitForElementToBePresent(objective3_selected_option) ###do.saveObjectData() ###util.clickOn(element.audit_pbc_request_expanded_content_edit_link) ###new_value = util.getTextFromXpathString(objective2_selected_option) ###self.assertTrue(new_value == "Population Sample" , "the selected option is not Population Sample" ) ####Delete ###print "deleting Response" ###do.deleteObject() #9. Click on Objective 1 for Auto Test of Audit to open 2nd tier info (Documentation Response) #util.scrollIntoView(newly_created_audit_open_link) do.expandCollapseRequest(grcobject.objective_title[0]) do.setRequestToRespondable(grcobject.objective_title[0]) # open the response model and fill it out new_response_button = element.audit_pbc_request_response_create.replace("TITLE", grcobject.objective_title[0]) util.waitForElementToBePresent(new_response_button) util.clickOn(new_response_button) new_response_title = "Response to " + grcobject.objective_title[0] do.NewResponseCreate(new_response_title) response_element = element.audit_pbc_request_response2.replace("TITLE", grcobject.objective_title[0]).replace("RESPONSE", new_response_title) print "response element " + response_element util.waitForElementToBePresent(response_element) util.scrollIntoView(response_element) time.sleep(20) self.assertTrue(util.isElementPresent(response_element), "can't see the new Response for the request link") # look for edit button new_response_edit_link = element.audit_pbc_request_expanded_response_edit_link2.replace("TITLE", grcobject.objective_title[0]).replace("RESPONSE", new_response_title) util.waitForElementToBePresent(new_response_edit_link) util.clickOn(new_response_edit_link) # need to re-open # verify assignee is the same as audit lead ([email protected]) pbc_response_elements = { # name is description, but functions more like a title in # the context of the verifyObjectValues helper "description": element.response_title, "owner": element.response_assignee, } pbc_response_values = { "description": new_response_title, "owner": do.current_user_email(), } do.verifyObjectValues(pbc_response_elements, pbc_response_values, "Audit") do.saveObjectData() audit_edit_button = newly_created_audit + element.audit_edit util.scrollIntoView(audit_edit_button) util.clickOn(audit_edit_button) do.deleteObject()
from flask import Flask from flask_restful import Api from db import db from helpers.Helpers import Helpers from routers import Routers app = Flask(__name__) configs = Helpers().config_app for key in configs: app.config[key] = configs[key] api = Api(app) router = Routers(api) router.get() if __name__ == '__main__': db.init_app(app) app.run(port=configs["APP_PORT"], debug=configs["DEBUG"], host=configs["APP_SERVER"])
def testCreatePrivateProgramReader(self): self.testname="TestCreatePrivateProgramReader" self.setup() util = WebdriverUtilities() util.setDriver(self.driver) element = Elements() do = Helpers(self) do.setUtils(util) do.login() email = config.reader1 password = config.same_password private_prgm_1 = do.createPrivateProgramPermission(email, "", "ProgramReader") print private_prgm_1 # map any object so that we can check if read can see it or not do.mapAObjectLHN("Contract") # now log out and then log in with the ProgramReader user do.selectMenuInTopRight("Logout") do.refresh() # Log in with new user do.login(email, password) print "Log in as : " + do.whoAmI() do.assertEquals("Reader", do.getRoleLabelInTopRight(), "Label does not says 'Reader'.") do.selectMenuInTopRight("My Work") # verify that user can see program tab and some programs; by seeing counts do.selectInnerNavTab("program") count = do.countOfAnyObjectInWidget("Program") do.assertGreater(count, 0, "Fail because count is expected to be non-zero if programs indeed exist.") # and being able to navigate to the expanded program row index = do.expandItemWidget("program", private_prgm_1) do.clickViewProgram("program", index) # can see mapped objects do.selectInnerNavTab("contract") count = do.countOfAnyObjectInWidget("Contract") do.assertGreater(count, 0, "Fail because count is expected to be non-zero if programs indeed exist.") # map link and edit authorization link should not exist do.selectInnerNavTab("person") do.assertFalse(do.isMapLinkPresent("person"), "Expect map link not present since it's a ProgramReader role.") do.assertFalse(do.isEditAuthorizationPresent(), "Expect Edit Authorization link not present since it's a ProgramReader role.") # go to program info page do.selectInnerNavTab("program") do.assertFalse(do.isInfoPageEditLinkPresent(), "Expect Edit link not present since it's a ProgramReader role.") do.assertFalse(do.isSubmitForReviewPresent(), "Expect Submit For Review link not present since it's a ProgramReader role.")
def testMapRegulationToSystem(self): self.testname="TestMapRegulationToSystem" self.setup() util = WebdriverUtilities() util.setDriver(self.driver) element = Elements() do = Helpers(self) do.setUtils(util) do.login() titleReg = do.getUniqueString("regulation") titleSys = do.getUniqueString("system") do.createObject("Regulation", titleReg) do.createObject("System", titleSys) do.mapAObjectLHN("Regulation", titleReg)
def testImportExportProcess(self): self.testname="TestImportExportProcess" self.setup() util = WebdriverUtilities() util.setDriver(self.driver) do = Helpers(self) do.setUtils(util) do.login() # create a process processObject =do.createObject("Process") processObject = str(util.getTextFromXpathString(processObject)) #it's name, not xpath print "" print "On screen." print "Process object is displayed as : " + processObject # export process filePath = config.test_db + "PROCESSES.csv" do.selectMenuInTopRight("Admin Dashboard") do.exportFile("processes", filePath) # verify that information in file matched self.assertTrue(do.verifyDataInExportFile(processObject, filePath), "Process object not found in exported file.") # import process # create some data, add it to the import file and upload number = str(do.getRandomNumber()) processObject = "processImport" + number print "" print "Add this new system object to the import file and upload." print "Process object: " + processObject # proof: verify that this user never exist in the database do.navigateToObjectWithSearchWithNoAssertion(processObject, "Process") count = do.countOfAnyObjectLHS("Process") self.assertEqual(0, count, "Process " + processObject + " is verified not existed.") # make it complete conformingText = "PROCESS-" + number + "," + processObject + ",,,,,,[email protected],,,,,,2014-7-17,2014-7-17,,Draft" do.appendToFile(conformingText, filePath) do.importFile("Processes", filePath) do.refresh() # after import, verify that user has been added to the database do.navigateToObjectWithSearch(processObject, "Process") count = do.countOfAnyObjectLHS("Process") self.assertEqual(1, count, "Process " + processObject + " is not added successfully.") self.assertEqual(processObject, do.getObjectNavWidgetInfo("username"), "Process object " + processObject + " is not found in the database.") print "" print "Process object is imported successfully and found in the database." print processObject
def testProgramAuditSetup(self): self.testname="TestProgramAuditSetup" self.setup() util = WebdriverUtilities() util.setDriver(self.driver) element = Elements() grcobject = GRCObject() do = Helpers() do.setUtils(util) do.login() objectiveID = {} # 1: Create New Program #program_name = "The Program for Auto Test of Audit" #temporary to use one program with unique name current_time = do.getTimeId() program_name = "Program for Auto Test of Audit" +current_time last_created_object_link = do.createObject("Program", program_name, "checked",True, config.username) #object_name = str(util.getTextFromXpathString(last_created_object_link)).strip() # 2. Navigate to that Program page #do.navigateToObjectWithSearch(program_name,"Program") do.navigateToObject("Program",last_created_object_link) util.max_screen() # 3. Select Regulations tab in Object pg Nav to bring up the Mapped Regulations widget # 4. Click +Regulation button to bring up modal selector for mapping Regulation to the Program do.navigateToMappingWindowForObject("Regulation") # 5. In modal, click green +Regulation button to bring up create a new Regulation modal util.clickOn(element.mapping_modal_add_button) # 6. Fill in title for the new Regulation, "Regulation for Auto Test of Audit" # 7. click Save (this dismisses the 2nd modal and puts the newly created Regulation at the top of the list in the 1st modal (the mapping modal) regulation_name = "Regulation for Auto Test of Audit"+current_time do.createObject("Regulation", regulation_name,"unchecked",False) # 8. Select "Regulation for Auto test of Audit" at top of list then click Map button (dismisses modal and returns to Program pg now with the Regulation mapped) mapped_object_id = do.mapFirstObject("Regulation",False,regulation_name) # 9. Click on Regulation for Auto Test of Audit in Mapped Regulations widget to expand the drop down and reveal Sections list #expand regulation area mapped_object_link = element.mapped_object.replace("OBJECT", "regulation").replace("ID", mapped_object_id) util.waitForElementToBePresent(mapped_object_link) self.assertTrue(util.isElementPresent(mapped_object_link),"doesn't see the newly created mapped object") util.clickOn(mapped_object_link) # 10. Hover over +Sections link to reveal 3 options, then click on Create Section to launch the Create new Section modal # 11. New Section modal:Title: "Section 1 of Regulation for Auto Test of Audit" # 12. Click Save - returns you to the Program pg > Regulation widget > Section now shows in revealed Sections display area do.createSectionFor("regulation",mapped_object_id,"Section 1 of Regulation for Auto Test of Audit"+current_time) section_id= do.getTheIdOfTheLastCreated("section") # 13. Click on "Section 1 of Regulation for Auto Test of Audit" title in the Sections display area - this reveals the Text of Section we entered and the "OBJECTIVES, CONTROLS, AND BUSINESS OBJECTS (0)" display area. #expand section area util.waitForElementToBePresent(element.sections_area_first_section) self.assertTrue(util.isElementPresent(element.sections_area_first_section),"doesn't see the newly created Section in the section area") util.clickOn(element.sections_area_first_section) self.assertTrue(util.isElementPresent(element.theShortDescriptionElement),"doesn't see the short description element") #make objectiveID link visible util.waitForElementToBePresent(element.section_area_add_object_link) self.assertTrue(util.isElementPresent(element.section_area_add_object_link),"doesn't see +Objective link") # 16. Repeat steps 14-15 3 times, increment Objective name, leave the next bullet point in description util.max_screen() for n in range(3): print "objective number " + str(n+1) # 14. Hover over +Object to reveal 2 options util.scrollIntoView(element.section_area_add_object_link) util.hoverOverAndWaitFor(element.section_area_add_object_link, element.section_area_add_objective_link) self.assertTrue(util.isElementPresent(element.section_area_add_objective_link),"doesn't see the section_area_add_objective_link") # 15. Click on +Objectives to open "Map New Objective to Section 1 of Regulation for Auto Test of Audit" modal, input data and click Save #util.clickOn(element.section_area_add_object_link) util.clickOn( element.section_area_add_objective_link) #create new objective do.createObjectives(grcobject.objective_title[n], grcobject.objective_description[n]) last_created_object_element = element.objective_elemet_in_the_inner_tree_with_index.replace("INDEX",str(n+1 )) print "the last created objective element is "+last_created_object_element util.waitForElementToBePresent(last_created_object_element) self.assertTrue(util.isElementPresent(last_created_object_element), "cannot see the newly created objective") # store objectiveID ids objective_id= do.getTheIdOfTheLastCreatedObjective(last_created_object_element) objectiveID[n]=objective_id print objectiveID[n] # 17.after creating 3 Objectives, Hover over +Object 1 more time but this time click on +Object to launch the multi object mapper modal #util.clickOnAndWaitFor(element.section_area_add_object_link, element.section_area_add_objective_link) util.clickOn(element.section_area_add_object_link) # 18. Select Controls from top filter selector in modal util.selectFromDropdownByValue(element.mapping_modal_top_filter_selector_dropdown, "Control") # 19. Click green +Control button to create a new control util.clickOn(element.mapping_modal_add_button) # 20. Give it the title "Control for Auto Test of Audit" - Click Save control_name = "Control for Auto Test of Audit" +current_time do.createObject("Control", control_name,"unchecked",False) mapped_object_id= do.mapFirstObject("Control", False,control_name) print mapped_object_id # # Write audit setup data to file - program_name and the 3 objective ids, each on separate line # f=open("audit_setup_data","w") f.write(program_name+"\n") f.write(objectiveID[0]+"\n") f.write(objectiveID[1]+"\n") f.write(objectiveID[2]+"\n") f.close()
import datetime from validate_email import validate_email from helpers.Helpers import Helpers helper = Helpers() class Rules: @staticmethod def date(value, name): message = helper.response_message()['validator'] if value is None or value == "": raise ValueError(message['required']) try: datetime.datetime.strptime(value, '%Y-%m-%d') except ValueError: raise ValueError(message['date-invalid']) return value @staticmethod def email(value, name): message = helper.response_message()['validator'] if value is None or value == "": raise ValueError(message['required']) if validate_email(value): value = value else: raise ValueError(message['email-invalid'])
class Ui_MainWindow(object): USER_NAME = '' def __init__(self): self.db = DataBaseManager() self.check_manager = CheckManager() self.warning_manager = WarningManager() self.email_notifications = EmailNotifications() self.helpers = Helpers() def radioIsChecked(self): if self.radio_User.isChecked(): self.account_type = 'user' elif self.radio_Admin.isChecked(): self.account_type = 'admin' elif self.radio_Klient_2.isChecked(): self.account_type = 'klient' else: return False def check_type_of_account(self, account_type): if account_type == 'user': self.radio_User.click() elif account_type == 'admin': self.radio_Admin.click() elif account_type == 'klient': self.radio_Klient_2.click() def clear_all_lines(self): self.lineEdit_imie.clear() self.lineEdit_nazwisko.clear() self.lineEdit_telefon.clear() self.lineEdit_email.clear() self.lineEdit_Adres.clear() self.lineEdit_kod_pocztowy.clear() self.lineEdit_PESEL.clear() self.lineEdit_haslo.clear() def get_info_about_user(self): self.clear_all_lines() self.USER_NAME = self.lineEdit_login.text() self.user_data_obj = self.db.getUserData(self.USER_NAME) if self.user_data_obj is None: self.warning_manager.showWarningBox('error', 'incorrect user_name') return None self.lineEdit_imie.insert(self.user_data_obj.imie) self.lineEdit_nazwisko.insert(self.user_data_obj.nazwisko) self.lineEdit_telefon.insert(str(self.user_data_obj.telefon)) self.lineEdit_email.insert(self.user_data_obj.mail) self.lineEdit_Adres.insert(self.user_data_obj.adres) self.lineEdit_kod_pocztowy.insert(self.user_data_obj.kod_pocztowy) self.lineEdit_PESEL.insert(str(self.user_data_obj.PESEL)) self.lineEdit_haslo.insert(self.user_data_obj.password) account_type = self.user_data_obj.account_type self.check_type_of_account(account_type) def editUser(self): password = self.lineEdit_haslo.text() self.account_type = '' mail = self.lineEdit_email.text() imie = self.lineEdit_imie.text() nazwisko = self.lineEdit_nazwisko.text() telefon = self.lineEdit_telefon.text() adres = self.lineEdit_Adres.text() kod_pocztowy = self.lineEdit_kod_pocztowy.text() pesel = self.lineEdit_PESEL.text() self.user_data_obj = self.db.getUserData(self.USER_NAME) if self.user_data_obj is None: self.warning_manager.showWarningBox('error', 'incorrect user_name') return None if not self.helpers.checkCorrectionMail(mail): self.warning_manager.showWarningBox('error', 'incorrect mail!!!') return None correction_logindata = self.check_manager.checkCorrectionLoginData( self.USER_NAME, password) if not correction_logindata: self.warning_manager.showWarningBox('error', 'incorrect login data') return None if self.radioIsChecked(): self.warning_manager.showWarningBox( 'error', 'please check an account type') return None data = {} data['username'] = self.USER_NAME data['password'] = password data['account_type'] = self.account_type data['mail'] = mail data['imie'] = imie data['nazwisko'] = nazwisko data['telefon'] = telefon data['adres'] = adres data['kod_pocztowy'] = kod_pocztowy data['pesel'] = pesel check_exception = self.db.editUser(data) if check_exception: self.warning_manager.showWarningBox('Error', str(check_exception)) return None # check_exception = self.email_notifications.sendUserRegistered(mail,self.USER_NAME,password) # if check_exception: # self.warning_manager.showWarningBox('Error', str(check_exception)) # return None self.MainWindow.close() def setupUi(self, MainWindow): MainWindow.setObjectName("MainWindow") MainWindow.setEnabled(True) MainWindow.resize(429, 516) sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Ignored, QtWidgets.QSizePolicy.Preferred) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth( MainWindow.sizePolicy().hasHeightForWidth()) MainWindow.setSizePolicy(sizePolicy) self.centralwidget = QtWidgets.QWidget(MainWindow) self.centralwidget.setObjectName("centralwidget") self.verticalLayout_2 = QtWidgets.QVBoxLayout(self.centralwidget) self.verticalLayout_2.setObjectName("verticalLayout_2") self.verticalLayout = QtWidgets.QVBoxLayout() self.verticalLayout.setObjectName("verticalLayout") self.label_2 = QtWidgets.QLabel(self.centralwidget) self.label_2.setObjectName("label_2") self.verticalLayout.addWidget(self.label_2) self.horizontalLayout_3 = QtWidgets.QHBoxLayout() self.horizontalLayout_3.setObjectName("horizontalLayout_3") self.label_9 = QtWidgets.QLabel(self.centralwidget) self.label_9.setObjectName("label_9") self.horizontalLayout_3.addWidget(self.label_9) spacerItem = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum) self.horizontalLayout_3.addItem(spacerItem) self.lineEdit_login = QtWidgets.QLineEdit(self.centralwidget) self.lineEdit_login.setMinimumSize(QtCore.QSize(280, 0)) self.lineEdit_login.setObjectName("lineEdit_login") self.horizontalLayout_3.addWidget(self.lineEdit_login) self.verticalLayout.addLayout(self.horizontalLayout_3) self.pushButton = QtWidgets.QPushButton(self.centralwidget) self.pushButton.setObjectName("pushButton") self.verticalLayout.addWidget(self.pushButton) ############### Button Event #################### self.pushButton.clicked.connect(self.get_info_about_user) ################################################# self.line = QtWidgets.QFrame(self.centralwidget) self.line.setFrameShape(QtWidgets.QFrame.HLine) self.line.setFrameShadow(QtWidgets.QFrame.Sunken) self.line.setObjectName("line") self.verticalLayout.addWidget(self.line) self.horizontalLayout_10 = QtWidgets.QHBoxLayout() self.horizontalLayout_10.setObjectName("horizontalLayout_10") self.label = QtWidgets.QLabel(self.centralwidget) self.label.setObjectName("label") self.horizontalLayout_10.addWidget(self.label) spacerItem1 = QtWidgets.QSpacerItem(20, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum) self.horizontalLayout_10.addItem(spacerItem1) self.lineEdit_imie = QtWidgets.QLineEdit(self.centralwidget) self.lineEdit_imie.setMinimumSize(QtCore.QSize(280, 0)) self.lineEdit_imie.setMaximumSize(QtCore.QSize(900, 16777215)) self.lineEdit_imie.setObjectName("lineEdit_imie") self.horizontalLayout_10.addWidget(self.lineEdit_imie) self.verticalLayout.addLayout(self.horizontalLayout_10) self.horizontalLayout_9 = QtWidgets.QHBoxLayout() self.horizontalLayout_9.setObjectName("horizontalLayout_9") self.label_3 = QtWidgets.QLabel(self.centralwidget) self.label_3.setObjectName("label_3") self.horizontalLayout_9.addWidget(self.label_3) spacerItem2 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum) self.horizontalLayout_9.addItem(spacerItem2) self.lineEdit_nazwisko = QtWidgets.QLineEdit(self.centralwidget) self.lineEdit_nazwisko.setMinimumSize(QtCore.QSize(280, 0)) self.lineEdit_nazwisko.setObjectName("lineEdit_nazwisko") self.horizontalLayout_9.addWidget(self.lineEdit_nazwisko) self.verticalLayout.addLayout(self.horizontalLayout_9) self.horizontalLayout_8 = QtWidgets.QHBoxLayout() self.horizontalLayout_8.setObjectName("horizontalLayout_8") # self.label_4 = QtWidgets.QLabel(self.centralwidget) # self.label_4.setObjectName("label_4") # self.horizontalLayout_8.addWidget(self.label_4) # spacerItem3 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum) # self.horizontalLayout_8.addItem(spacerItem3) # self.lineEdit_id = QtWidgets.QLineEdit(self.centralwidget) # self.lineEdit_id.setMinimumSize(QtCore.QSize(280, 0)) # self.lineEdit_id.setObjectName("lineEdit_id") # self.horizontalLayout_8.addWidget(self.lineEdit_id) self.verticalLayout.addLayout(self.horizontalLayout_8) self.horizontalLayout_7 = QtWidgets.QHBoxLayout() self.horizontalLayout_7.setObjectName("horizontalLayout_7") self.label_5 = QtWidgets.QLabel(self.centralwidget) self.label_5.setObjectName("label_5") self.horizontalLayout_7.addWidget(self.label_5) spacerItem4 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum) self.horizontalLayout_7.addItem(spacerItem4) self.lineEdit_telefon = QtWidgets.QLineEdit(self.centralwidget) self.lineEdit_telefon.setMinimumSize(QtCore.QSize(280, 0)) self.lineEdit_telefon.setObjectName("lineEdit_telefon") self.horizontalLayout_7.addWidget(self.lineEdit_telefon) self.verticalLayout.addLayout(self.horizontalLayout_7) self.horizontalLayout_6 = QtWidgets.QHBoxLayout() self.horizontalLayout_6.setObjectName("horizontalLayout_6") self.label_6 = QtWidgets.QLabel(self.centralwidget) self.label_6.setObjectName("label_6") self.horizontalLayout_6.addWidget(self.label_6) spacerItem5 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum) self.horizontalLayout_6.addItem(spacerItem5) self.lineEdit_email = QtWidgets.QLineEdit(self.centralwidget) self.lineEdit_email.setMinimumSize(QtCore.QSize(280, 0)) self.lineEdit_email.setObjectName("lineEdit_email") self.horizontalLayout_6.addWidget(self.lineEdit_email) self.verticalLayout.addLayout(self.horizontalLayout_6) self.horizontalLayout_5 = QtWidgets.QHBoxLayout() self.horizontalLayout_5.setObjectName("horizontalLayout_5") self.label_7 = QtWidgets.QLabel(self.centralwidget) self.label_7.setObjectName("label_7") self.horizontalLayout_5.addWidget(self.label_7) spacerItem6 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum) self.horizontalLayout_5.addItem(spacerItem6) self.lineEdit_Adres = QtWidgets.QLineEdit(self.centralwidget) self.lineEdit_Adres.setMinimumSize(QtCore.QSize(280, 0)) self.lineEdit_Adres.setObjectName("lineEdit_Adres") self.horizontalLayout_5.addWidget(self.lineEdit_Adres) self.verticalLayout.addLayout(self.horizontalLayout_5) self.horizontalLayout_2 = QtWidgets.QHBoxLayout() self.horizontalLayout_2.setObjectName("horizontalLayout_2") self.label_11 = QtWidgets.QLabel(self.centralwidget) self.label_11.setObjectName("label_11") self.horizontalLayout_2.addWidget(self.label_11) spacerItem7 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum) self.horizontalLayout_2.addItem(spacerItem7) self.lineEdit_kod_pocztowy = QtWidgets.QLineEdit(self.centralwidget) self.lineEdit_kod_pocztowy.setMinimumSize(QtCore.QSize(280, 0)) self.lineEdit_kod_pocztowy.setObjectName("lineEdit_kod_pocztowy") self.horizontalLayout_2.addWidget(self.lineEdit_kod_pocztowy) self.verticalLayout.addLayout(self.horizontalLayout_2) self.horizontalLayout_4 = QtWidgets.QHBoxLayout() self.horizontalLayout_4.setObjectName("horizontalLayout_4") self.label_8 = QtWidgets.QLabel(self.centralwidget) self.label_8.setObjectName("label_8") self.horizontalLayout_4.addWidget(self.label_8) spacerItem8 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum) self.horizontalLayout_4.addItem(spacerItem8) self.lineEdit_PESEL = QtWidgets.QLineEdit(self.centralwidget) self.lineEdit_PESEL.setMinimumSize(QtCore.QSize(280, 0)) self.lineEdit_PESEL.setObjectName("lineEdit_PESEL") self.horizontalLayout_4.addWidget(self.lineEdit_PESEL) self.verticalLayout.addLayout(self.horizontalLayout_4) self.horizontalLayout = QtWidgets.QHBoxLayout() self.horizontalLayout.setObjectName("horizontalLayout") self.label_10 = QtWidgets.QLabel(self.centralwidget) self.label_10.setObjectName("label_10") self.horizontalLayout.addWidget(self.label_10) spacerItem9 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum) self.horizontalLayout.addItem(spacerItem9) self.lineEdit_haslo = QtWidgets.QLineEdit(self.centralwidget) self.lineEdit_haslo.setMinimumSize(QtCore.QSize(280, 0)) self.lineEdit_haslo.setObjectName("lineEdit_haslo") self.horizontalLayout.addWidget(self.lineEdit_haslo) self.verticalLayout.addLayout(self.horizontalLayout) self.radio_User = QtWidgets.QRadioButton(self.centralwidget) self.radio_User.setObjectName("radio_User") self.verticalLayout.addWidget(self.radio_User) self.radio_Admin = QtWidgets.QRadioButton(self.centralwidget) self.radio_Admin.setObjectName("radio_Admin") self.verticalLayout.addWidget(self.radio_Admin) self.radio_Klient_2 = QtWidgets.QRadioButton(self.centralwidget) self.radio_Klient_2.setObjectName("radio_Klient_2") self.verticalLayout.addWidget(self.radio_Klient_2) self.horizontalLayout_11 = QtWidgets.QHBoxLayout() self.horizontalLayout_11.setObjectName("horizontalLayout_11") spacerItem10 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum) self.horizontalLayout_11.addItem(spacerItem10) self.btn_edit = QtWidgets.QPushButton(self.centralwidget) self.btn_edit.setObjectName("btn_edit") ############### Button Event #################### self.btn_edit.clicked.connect(self.editUser) ################################################# self.horizontalLayout_11.addWidget(self.btn_edit) spacerItem11 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum) self.horizontalLayout_11.addItem(spacerItem11) self.verticalLayout.addLayout(self.horizontalLayout_11) self.verticalLayout_2.addLayout(self.verticalLayout) MainWindow.setCentralWidget(self.centralwidget) self.statusbar = QtWidgets.QStatusBar(MainWindow) self.statusbar.setObjectName("statusbar") MainWindow.setStatusBar(self.statusbar) self.retranslateUi(MainWindow) QtCore.QMetaObject.connectSlotsByName(MainWindow) def retranslateUi(self, MainWindow): _translate = QtCore.QCoreApplication.translate MainWindow.setWindowTitle(_translate("MainWindow", "MainWindow")) self.label_2.setText(_translate("MainWindow", "Edycja konta")) self.label_9.setText(_translate("MainWindow", "Login: "******"MainWindow", "get info about user")) self.label.setText(_translate("MainWindow", "Imie:")) self.label_3.setText(_translate("MainWindow", "Nazwisko: ")) # self.label_4.setText(_translate("MainWindow", "ID: ")) self.label_5.setText(_translate("MainWindow", "Telefon: ")) self.label_6.setText(_translate("MainWindow", "Adres email: ")) self.label_7.setText(_translate("MainWindow", "Adres: ")) self.label_11.setText(_translate("MainWindow", "Kod pocztowy:")) self.label_8.setText(_translate("MainWindow", "PESEL: ")) self.label_10.setText(_translate("MainWindow", "Haslo: ")) self.radio_User.setText(_translate("MainWindow", "User")) self.radio_Admin.setText(_translate("MainWindow", "Admin")) self.radio_Klient_2.setText(_translate("MainWindow", "Klient")) self.btn_edit.setText(_translate("MainWindow", "Edytuj")) #################################### self.MainWindow = MainWindow
def testSaveAndAddAnotherProject(self): self.testname="TestSaveAndAddAnotherProject" self.setup() util = WebdriverUtilities() util.setDriver(self.driver) element = Elements() do = Helpers(self) do.setUtils(util) do.login() object_1_name = do.generateNameForTheObject("Project") do.delay(10) # count number does not appear right away, weird object_2_name = "Project_" + str(do.getRandomNumber()) do.ensureLHNSectionExpanded("Project") count_before = do.countOfAnyObjectLHS("Project") do.createObjectSaveAddAnother("Project", object_1_name, "unchecked", True, "", False) do.createObjectSaveAddAnother("Project", object_2_name, "unchecked", False, "", True) do.clearSearchBoxOnLHS() #clear any text so total count displays do.ensureLHNSectionExpanded("Project") count_after = do.countOfAnyObjectLHS("Project") do.assertEqual(count_after, count_before+2, "Count has not incremented by 1 as expected.") print "Object 1: " object_1_link = do.verifyObjectIsCreatedinLHN("Project", object_1_name) do.navigateToObjectAndOpenObjectEditWindow("Project",object_1_link) do.deleteObject() print "Object 2: " object_2_link = do.verifyObjectIsCreatedinLHN("Project", object_2_name) do.navigateToObjectAndOpenObjectEditWindow("Project",object_2_link) do.deleteObject()
from flask_restful import Resource, reqparse from models.UserModel import UserModel from validators.UserRequest import UserRequest from validators.IdRequest import IdRequest from helpers.Helpers import Helpers helper = Helpers() message = helper.response_message()['user'] class UserFindByUsername(Resource): @classmethod def get(cls, username: str): user = UserModel.find_by_username(_username=username) if not user: return {'message': message['not-found']}, 404 return {'message': message['single-found'], 'data': user.json()}, 200 class UserFindById(Resource): @classmethod def get(cls, id: int): user = UserModel.find_by_id(_id=id) if not user: return {'message': message['not-found']}, 404 return {'message': message['single-found'], 'data': user.json()}, 200 class User(Resource):
def testRegulationEdit(self): self.testname="TestRegulationEdit" self.setup() util = WebdriverUtilities() util.setDriver(self.driver) element = Elements() do = Helpers(self) grcobject = GRCObject() do.setUtils(util) do.login() last_created_object_link = do.createObject("Regulation") object_name = str(util.getTextFromXpathString(last_created_object_link)).strip() do.navigateToObjectAndOpenObjectEditWindow("Regulation",last_created_object_link) do.populateObjectInEditWindow( object_name , grcobject.regulation_elements, grcobject.regulation_values) do.openObjectEditWindow() do.verifyObjectValues(grcobject.regulation_elements, grcobject.regulation_values) do.deleteObject()
def testMapSystemToPeople(self): self.testname="TestMapSystemToPeople" self.setup() util = WebdriverUtilities() util.setDriver(self.driver) element = Elements() do = Helpers(self) do.setUtils(util) do.login() aEmail = "auto_email_" + str(do.getRandomNumber()) + "@gmail.com" aName = do.getUniqueString("name") aCompany = do.getUniqueString("company") titleSys = do.getUniqueString("system") do.createObject("System", titleSys) do.createPersonLHN(aName, aEmail, aCompany) do.mapAObjectLHN("System", titleSys)
def testHideShowNewModalProcess(self): self.testname="TestHideShowNewModalProcess" self.setup() util = WebdriverUtilities() util.setDriver(self.driver) element = Elements() do = Helpers(self) do.setUtils(util) do.login() list_all = "all" list_items = "description, note, owner, contact, url, reference_url, code, effective_date, network_zone, stop_date, state" a_few_items = "url, network_zone" print "TEST THAT YOU CAN SHOW OR HIDE FIELDS/ELEMENTS IN CREATE NEW OBJECT MODAL." # fill in mandatory fields only do.openCreateNewObjectWindowFromLhn("Process") # hide_all, show_all, then hide individual do.hideInNewModal(list_all, True, "process") do.hideInNewModal(list_all, False, "process") # hide individually do.hideInNewModal(list_items, True, "process") # show all again, hide a few will cause show_all to display, now reshow_all do.hideInNewModal(list_all, False, "process") do.hideInNewModal(a_few_items, True, "process") do.hideInNewModal(list_all, False, "process") do.populateNewObjectData(do.generateNameForTheObject("process")) do.saveNewObjectAndWait() do.clickInfoPageEditLink() # now start testing hide/show after clicking on the Edit link do.hideInNewModal(list_all, True, "process") do.hideInNewModal(list_all, False, "process") do.hideInNewModal(a_few_items, True, "process") do.hideInNewModal(list_all, False, "process")
def __init__(self, _parser): self.parser = _parser self.rule = Rules() self.message = Helpers().response_message()['validator']
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 testCreatePersonObjectEditorLogInOut(self): self.testname="TestCreatePersonObjectEditorLogInOut" self.setup() util = WebdriverUtilities() util.setDriver(self.driver) element = Elements() do = Helpers(self) do.setUtils(util) do.login() # ***************************** run this block of codes if run locally ***************************** if "localhost" in config.url: print "Executing the block of codes locally ..." aEmail = "auto_email_" + str(do.getRandomNumber(65535)) + "@gmail.com" aName = do.getUniqueString("name") aCompany = do.getUniqueString("company") do.selectMenuInTopRight("Admin Dashboard") do.selectMenuItemInnerNavDashBoard("People") do.addPersonInAdminDB(aName, aEmail, aCompany) self.assertTrue(do.searchPersonInAdminDB(aName), "Fail searching for newly created person in Admin Dashboard.") # edit person authorization do.selectMenuItemInnerNavDashBoard("People") # on the roles selection do.clickOnEditAuthorization(aName) do.assignUserRole("ObjectEditor") # now log out and then log in with the new account and try to create a program oldEmail = "Example user" oldName = "*****@*****.**" absFilePath = expanduser("~") + "/ggrc-core/src/ggrc/login/noop.py" do.changeUsernameEmail(oldName, aName, oldEmail, aEmail, absFilePath) do.selectMenuInTopRight("Logout") # Refresh the page do.refresh() # Log in with new user do.login() print "Log in as : " + do.whoAmI() object_list = ["Workflow", "Vendor", "Regulation", "Policy", "Standard", "Contract", "Clause", "Section", "Section", "Objective", "Control", "Person", "OrgGroup", "System","Process", "DataAsset", "Product", "Project", "Facility", "Market", "Program", "Audit"] # since it's an object editor role, the Create New button won't show for certain types for object in object_list: if object=="Program" or object=="Audit": do.assertFalse(do.doesCreateNewExist(object), "Create New button exists for " + str(object)) else: do.assertTrue(do.doesCreateNewExist(object), "Create New button does not exist for " + str(object)) # should be able to create an object that is not Program or Audit last_created_object_link = do.createObject("Contract") object_name = str(do.util.getTextFromXpathString(last_created_object_link)).strip() self.assertTrue(do.partialMatch("contract-auto-test", object_name), "Fail to match contract name.") # Restore old login information do.changeUsernameEmail(aName, oldName, aEmail, oldEmail, absFilePath) do.selectMenuInTopRight("Logout") # ******************* execute this else block of codes if not run locally ******************* else: print "Executing the block of codes for non-local ..." aEmail = config.editor2 aName = do.getUniqueString("name") aCompany = do.getUniqueString("company") do.selectMenuInTopRight("Admin Dashboard") do.selectMenuItemInnerNavDashBoard("People") do.addPersonInAdminDB(aName, aEmail, aCompany) self.assertTrue(do.searchPersonInAdminDB(aName), "Fail searching for newly created person in Admin Dashboard.") # edit person authorization do.selectMenuItemInnerNavDashBoard("People") # on the roles selection do.clickOnEditAuthorization(aName) do.assignUserRole("ObjectEditor") # 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(aEmail, config.password) print "Log in as : " + do.whoAmI() object_list = ["Workflow", "Vendor", "Regulation", "Policy", "Standard", "Contract", "Clause", "Section", "Section", "Objective", "Control", "Person", "OrgGroup", "System","Process", "DataAsset", "Product", "Project", "Facility", "Market", "Program", "Audit"] # since it's an object editor role, the Create New button won't show for certain types for object in object_list: do.ensureLHNSectionExpanded(object) if object=="Program" or object=="Audit": do.assertFalse(do.doesCreateNewExist(object), "Create New button exists for " + str(object)) else: do.assertTrue(do.doesCreateNewExist(object), "Create New button does not exist for " + str(object)) # should be able to create an object that is not Program or Audit last_created_object_link = do.createObject("Contract") object_name = str(do.util.getTextFromXpathString(last_created_object_link)).strip() self.assertTrue(do.partialMatch("contract-auto-test", object_name), "Fail to match contract name.") if "localhost" in config.url: # Restore old login information do.changeUsernameEmail(aName, oldName, aEmail, oldEmail, absFilePath) do.selectMenuInTopRight("Logout")
def testCreatePersonProgramCreatorLogInOut(self): self.testname="TestCreatePersonProgramCreatorLogInOut" self.setup() util = WebdriverUtilities() util.setDriver(self.driver) element = Elements() do = Helpers(self) do.setUtils(util) do.login() aEmail = "auto_email_" + str(do.getRandomNumber(65535)) + "@gmail.com" aName = do.getUniqueString("name") aCompany = do.getUniqueString("company") do.selectMenuInTopRight("Admin Dashboard") do.selectMenuItemInnerNavDashBoard("People") do.addPersonInAdminDB(aName, aEmail, aCompany) self.assertTrue(do.searchPersonInAdminDB(aName), "Fail searching for newly created person in Admin Dashboard.") # edit person authorization do.selectMenuItemInnerNavDashBoard("People") # on the roles selection do.clickOnEditAuthorization(aName) do.assignUserRole("ProgramCreator") # now log out and then log in with the new account and try to create a program oldEmail = "*****@*****.**" oldName = "Example User" absFilePath = expanduser("~") + "/ggrc-core/src/ggrc/login/noop.py" do.changeUsernameEmail(oldName, aName, oldEmail, aEmail, absFilePath) do.selectMenuInTopRight("Logout") # Refresh the page do.refresh() # Log in with new user do.login() print "Log in as : " + do.whoAmI() object_list = ["Program", "Workflow", "Audit", "Regulation", "Policy", "Standard", "Contract", "Clause", "Section", "Objective", "Control", "Person", "OrgGroup", "System","Process", "DataAsset", "Product", "Project", "Facility", "Market"] for object in object_list: # cannot create audit; it requires other non-system wide role if object == "Audit": do.assertFalse(do.doesCreateNewExist(object), "Create New button exists for " + str(object)) else: do.assertTrue(do.doesCreateNewExist(object), "Create New button does not exist for " + str(object)) # should be able to create a program object last_created_object_link = do.createObject("Program") object_name = str(do.util.getTextFromXpathString(last_created_object_link)).strip() self.assertTrue(do.partialMatch("program-auto-test", object_name), "Fail to match program name.") # Restore old login information do.changeUsernameEmail(aName, oldName, aEmail, oldEmail, absFilePath) do.selectMenuInTopRight("Logout")
from flask_restful import Resource, reqparse from models.UserModel import UserModel from helpers.Helpers import Helpers from validators.LoginRequest import LoginRequest helper = Helpers() message = helper.response_message()['login'] class Login(Resource): @classmethod def post(cls): _parser_login = LoginRequest(reqparse.RequestParser(bundle_errors=True, trim=True)) _parser_login = _parser_login.validate() data = _parser_login.parse_args() username = data['username'] user = UserModel.find_by_username(_username=username) user_json = user.json() if not user: return { 'message': message['not-found'] }, 404 hashed = helper.check_password(data['password'], user_json['password']) if hashed: return { 'message': message['succeed'], 'data': user.json() }, 200