def testReferences(self):
        if sqlite3.sqlite_version_info() < (3,7,0):
            raise testhelp.SkipTestException("buggy sqlite; use embedded sqlite")
        repos = self.openRepository()
        # remove anonymous access
        repos.deleteUserByName("localhost@rpl:linux", "anonymous")
        self.addUserAndRole(repos, "localhost@rpl:linux", "alluser", "allpw")
        repos.addAcl("localhost@rpl:linux", "alluser", ".*", "ALL")
        allrepo = self.getRepositoryClient(user = "alluser", password = "allpw")
        # a limited user
        self.addUserAndRole(repos, "localhost@rpl:qa", "qauser", "qapw")
        repos.addAcl("localhost@rpl:qa", "qauser", "beta.*", "localhost@rpl:qa")
        qarepo = self.getRepositoryClient(user="qauser", password="qapw")

        # set up the test case
        verlist = [
            "/localhost@rpl:linux//devel/1.0-1-1",
            "/localhost@rpl:linux//qa/1.0-1-1",
            "/localhost@rpl:linux//prod/1.0-1-1",
            "/localhost@rpl:linux//devel/2.0-1-1",
            "/localhost@rpl:linux//qa/2.0-1-1",
            "/localhost@rpl:linux//prod/2.0-1-1",
            ]
        for i, v in enumerate(verlist):
            for n1 in ["alpha", "beta"]:
                for n2 in [":runtime", ":data"]:
                    self.addComponent(n1+n2, v)
                self.addCollection(n1, v, [":runtime", ":data"])
            self.addCollection("alpha%d" % i, v, [("alpha", v), ("alpha:runtime",v)])
            self.addCollection("beta%d" % i, v, [("beta", v), ("beta:runtime",v)], weakRefList = [("alpha:data",v)])
        # getTroveReferences
        noF = deps.Flavor()
        for i, vStr in enumerate(verlist):
            v = versions.VersionFromString(vStr)
            # test alluser
            ret = allrepo.getTroveReferences("localhost", [("alpha", v, noF)])
            self.assertEqual(ret, [[("alpha%d" %i, v, noF)]] )
            ret = allrepo.getTroveReferences("localhost", [("alpha:runtime", v, noF)])
            self.assertEqual(set(ret[0]), set([("alpha", v, noF), ("alpha%d" %i, v, noF)]))
            ret = allrepo.getTroveReferences("localhost", [("alpha:data", v, noF)])
            self.assertEqual(set(ret[0]),
                                 set([("alpha",v,noF),("alpha%d"%i,v,noF),("beta%d"%i,v,noF)]) )

            # test qauser
            ret = qarepo.getTroveReferences("localhost", [("beta:runtime",v,noF), ("beta:data",v,noF)])
            if v.branch().label().asString() == "localhost@rpl:qa":
                self.assertEqual(set(ret[0]),
                                     set([("beta",v,noF), ("beta%d"%i,v,noF)]))
                self.assertEqual(ret[1],[("beta", v, noF)])
            else:
                self.assertEqual(ret, [[],[]])
        # getTroveDescendants
        ret = allrepo.getTroveDescendants("localhost", [
            ("alpha", versions.VersionFromString("/localhost@rpl:linux//prod"), noF)])
        self.assertEqual(ret, [[]])
        ret = allrepo.getTroveDescendants("localhost", [
            ("alpha", versions.VersionFromString("/localhost@rpl:linux"), noF)])
        self.assertEqual(set(ret[0]),
                             set([(versions.VersionFromString(x), noF) for x in verlist]) )
        # limited user
        qaset = set([
            (versions.VersionFromString("/localhost@rpl:linux//qa/1.0-1-1"), noF),
            (versions.VersionFromString("/localhost@rpl:linux//qa/2.0-1-1"), noF),
            ])
        ret = qarepo.getTroveDescendants("localhost", [
            ("alpha", versions.VersionFromString("/localhost@rpl:linux"), noF),
            ("beta", versions.VersionFromString("/localhost@rpl:linux"), noF)])
        self.assertEqual(ret[0], [])
        self.assertEqual(set(ret[1]), qaset)
        # test deep branching
        branch = "/localhost@rpl:linux"
        retset = set()
        for b in ["devel", "qa", "prod"]:
            branch = branch + "//" + b
            verStr = branch+"/1.0-1-1"
            self.addComponent("gamma:runtime", verStr)
            self.addCollection("gamma", verStr, [":runtime"])
            retset.add((versions.VersionFromString(verStr), noF))
        ret = allrepo.getTroveDescendants("localhost", [
            ("gamma", versions.VersionFromString("/localhost@rpl:linux"), noF)])
        self.assertEqual(set(ret[0]), retset)
dataset/ETHPy150Open sassoftware/conary/conary_test/repositorytest/netclienttest.py/NetclientTest.testReferences/original