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")   
    def testCreatePrivateProgramEditor(self):
        self.testname="TestCreatePrivateProgramEditor"
        self.setup()
        util = WebdriverUtilities()
        util.setDriver(self.driver)
        element = Elements()
        do = Helpers(self)
        grcobject = GRCObject()
        do.setUtils(util)
        do.login()

        email = config.editor1
        password = config.same_password

        private_prgm_1 = do.createPrivateProgramPermission(email, "", "ProgramEditor")       
        print private_prgm_1
        # map any object so that we can check that reader can see
        do.mapAObjectLHN("Contract")
 
        # now log out and then log in with the ProgramEditor user
        do.selectMenuInTopRight("Logout")          
        do.refresh()          
        # Log in with new user
        do.login(email, password)
        print "Log in as : " + do.whoAmI()      
 
        do.assertEquals("ObjectEditor", do.getRoleLabelInTopRight(), "Label does not says 'ObjectEditor'.")
        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.")         

        # can map an object to program
        do.mapAObjectWidget("Product", "", True, ("Control", "Objective", "System"))

        # 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.expandItemWidget("Person", email)
        do.assertFalse(do.isEditAuthorizationPresent(), "Expect Edit Authorization link not present since it's a ProgramReader role.")
        
        # can edit info page
        do.selectInnerNavTab("info")
        do.assertTrue(do.isSubmitForReviewPresent(), "Expect Submit For Review link not present since it's a ProgramReader role.") 
        do.clickOnInfoPageEditLink()
        do.populateObjectInEditWindow(private_prgm_1 , grcobject.program_elements, grcobject.program_values)
        do.openObjectEditWindow()
        do.verifyObjectValues(grcobject.program_elements, grcobject.program_values)   
    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")      
Exemplo n.º 4
0
    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()