def testCreatePrivateProgramOwner(self):
        self.testname="TestCreatePrivateProgramOwner"
        self.setup()
        util = WebdriverUtilities()
        util.setDriver(self.driver)
        element = Elements()
        do = Helpers(self)
        grcobject = GRCObject()
        do.setUtils(util)
        do.login()

        email = config.creator1
        password = config.same_password

        private_prgm_1 = do.createPrivateProgramPermission(email, "", "ProgramOwner")       
        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("ProgramCreator", do.getRoleLabelInTopRight(), "Label does not says 'ProgramCreator'.")
        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.assertTrue(do.isMapLinkPresent("Person"), "Expect map link present since it's a ProgramOwner role.")
        do.expandItemWidget("Person", email)
        do.assertTrue(do.isEditAuthorizationPresent(), "Expect Edit Authorization link present since it's a ProgramOwner role.")
        
        # can edit info page
        do.selectInnerNavTab("info")
        do.assertTrue(do.isSubmitForReviewPresent(), "Expect Submit For Review link not present since it's a ProgramOwner role.") 
        do.clickOnInfoPageEditLink()
        do.populateObjectInEditWindow(private_prgm_1 , grcobject.program_elements, grcobject.program_values)
        do.openObjectEditWindow()
        do.verifyObjectValues(grcobject.program_elements, grcobject.program_values)   
        do.deleteObject()
    def testRelevantStress(self):
        self.testname="TestRelevantStress"
        self.setup()
        util = WebdriverUtilities()
        util.setDriver(self.driver)
        element = Elements()
        do = Helpers(self)
        do.setUtils(util)
        do.login()

        titleContract = do.getUniqueString("contract")
        titleClause = do.getUniqueString("clause")
          
        print "Contract: " + titleContract
        print "Clause: " + titleClause
                       
        # SETUP        
        do.checkMyWorkBox() # show my objects only
        # Make sure we have at least 20 data assets already if not create them
        count = do.countOfAnyObjectLHS("Data")
        diff = 20 - count
        while diff > 0:
            id = do.getRandomNumber()            
            do.createObject("Data", "data_" + str(id))
            diff = diff - 1
            do.delay(5)
           
        # Map 20 data assets to Clause
        do.createObject("Clause", titleClause)   
        expandables = []   
        do.mapAObjectWidget("Data_Asset", "data_", False, expandables, 20)
           
        # Map a clause to contract
        do.createObject("Contract", titleContract)
         
        do.mapAObjectWidget("Clause", titleClause, False, ("Clause"), 1)         
        # expand it

        do.expandItemWidget("Clause", titleClause)
         
        # check the MakeAllRelevant checkbox
        do.makeAllRelevant(True)
        do.delay(120) 
        # switch to Data Asset tab
        do.selectInnerNavTab("data_asset")
        do.assertEqual(20, do.countOfAnyObjectInWidget("data_asset"), "Count is not 20 in Data Asset Widget.")
       
        # just select because it will maintain its expanded mode
        do.selectInnerNavTab("clause")  
        
        do.makeAllRelevant(False)
        do.delay(120) # takes time for the unmapping to complete
        
        # switch to Data Asset tab again
        do.selectInnerNavTab("data_asset")
        
        # if MAKE ALL RELEVANT checkbox is deselected, no data asset tab is shown and thus no count is shown either
        print "Continue to fail until CORE-890 is fixed."
        do.assertEqual(0, do.countOfAnyObjectInWidget("data_asset"), "Count is not 0 in Data Asset Widget.")
    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 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.")