Esempio n. 1
0
    def testEventLog(self):
        self.testname="TestEventLog"
        self.setup()
        util = WebdriverUtilities()
        util.setDriver(self.driver)
        element = Elements()
        grcobject = GRCObject()
        do = Helpers(self)
        do.setUtils(util)
        do.login()

      # CREATE PROGRAM
        program_name = "Program_created_from_LHN"  + do.getTimeId()
        object_list = ["Regulation", "Contract", "Policy", "Standard"]
              
        last_created_object_link = do.createObject("Program", program_name)
      
        # MAP SOME OBJECTS
        for obj in object_list: 
            do.mapAObjectLHN(obj, program_name)      
              
        #do.selectInnerTabWhichAlreadyPresent("info")  
        do.selectInnerNavTab("info")      
        do.openObjectEditWindow()
        do.deleteObject()
                    
        do.selectMenuInTopRight("Admin Dashboard")
        do.selectMenuItemInnerNavDashBoard("Events")
            
        # when delete an object that has mapping, it automatically unmap and then delete
        self.assertTrue(do.verifyInfoInEventLogTable("unmapped from", 1), "Cannot find 'unmapped from Program' in the Event Log table.")
           
        # 4 times
        # 4 lines of "mapped to" because there are 4 mappings from the top
        self.assertTrue(do.verifyInfoInEventLogTable("mapped to", 2), "Cannot find 'map to:row2' in the Event Log table.")
        self.assertTrue(do.verifyInfoInEventLogTable("mapped to", 3), "Cannot find 'map to:row3' in the Event Log table.")
        self.assertTrue(do.verifyInfoInEventLogTable("mapped to", 4), "Cannot find 'map to:row4' in the Event Log table.")
        self.assertTrue(do.verifyInfoInEventLogTable("mapped to", 5), "Cannot find 'map to:row5' in the Event Log table.")
           
        # tests the "by whom" and "when at" fields
        self.assertTrue(do.verifyInfoInEventLogTable("whom", 2), "Cannot find 'whom' in the Event Log table.")
        self.assertTrue(do.verifyInfoInEventLogTable("when", 2), "Cannot find 'when' in the Event Log table.")
           
        # the program created should be logged
        self.assertTrue(do.verifyInfoInEventLogTable(program_name, 6), "Cannot find 'create program' in the Event Log table.")
        
        # verify that Prev and Next buttons work
        self.assertTrue(do.verifyPrevNextOperation(), "Fail verifying Prev and Next buttons.")
        
        
        # CORE-727
        print "CORE-727 is still open which causes this failure."
    def testCreatePersonAuthorizationLogInOut(self):
        self.testname="TestCreatePersonAuthorizationLogInOut"
        self.setup()
        util = WebdriverUtilities()
        util.setDriver(self.driver)
        element = Elements()
        do = Helpers(self)
        do.setUtils(util)
        do.login()      

        aEmail = "*****@*****.**"
        aName = do.getUniqueString("name")
        aCompany = do.getUniqueString("company")
        role = "ProgramCreator"
  
        do.selectMenuInTopRight("Admin Dashboard")
         
        # verify people tab
        do.selectMenuItemInnerNavDashBoard("People")
         
        # SETUP: if that email is already used change it to something else
        do.zeroizeThePersonEmail(aEmail)
           
        # you can add a person 
        do.addPersonInAdminDB(aName, aEmail, aCompany)
           
        # the Next and PREVIOUS page buttons work
        self.assertTrue(do.verifyPrevNextOperation("people"), "Fail verifying Prev and Next buttons.")
          
        # search or filter works
        self.assertTrue(do.searchPersonInAdminDB(aName), "Fail searching for newly created person in Admin Dashboard.")
           
        # edit person authorization    
        do.clickOnEditAuthorization(aName)
        do.assignUserRole(role)
        
        # at this point, 2nd tier is expanded and it's the only row displayed...
        do.verifyPersonInfoOnSecondTier(aName, aEmail, aCompany, role)

        if 'local' not in config.url:
            do.selectMenuInTopRight("Logout")
            do.refresh()
            do.login(aEmail, config.password)
            self.assertEqual(aEmail, do.whoAmI(), "Expect: " + aEmail + ", but see: " + do.whoAmI())
            
        # I can test login with the new user locally but not on on grc-test.appspot.com because it requires actual email
        # and that email has to be unique.  I can't automatically create new fake email account with google that's fraud            
        else:
            oldEmail = "*****@*****.**"
            oldName = "Example User"
            absFilePath = expanduser("~") + "/ggrc-core/src/ggrc/login/noop.py"
            do.changeUsernameEmail(oldName, aName, oldEmail, aEmail, absFilePath)            
            
            # 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 back in
            do.login()
            print "Log in as : " + do.whoAmI()
            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.")
            self.assertEqual(do.whoAmI(), aEmail, "Mismatched. I am: " + do.whoAmI() + ", " + "aEmail: " + aEmail)
            do.selectMenuInTopRight("Logout") 
     
            # Restore old login information
            do.changeUsernameEmail(aName, oldName, aEmail, oldEmail, absFilePath)