Beispiel #1
0
    def test_cachingDBInsert(self):

        for processType in (
                "Single",
                "Combined",
        ):
            config.ProcessType = processType

            # Get the DB
            db_path = os.path.abspath(self.mktemp())
            db = ProxySqliteDB(db_path)

            # Do one insert and check the result
            yield db.setGroupMembers("A", (
                "B",
                "C",
                "D",
            ))

            membersA = yield db.getMembers("A")
            membershipsB = yield db.getMemberships("B")
            membershipsC = yield db.getMemberships("C")
            membershipsD = yield db.getMemberships("D")
            membershipsE = yield db.getMemberships("E")

            self.assertEqual(membersA, set((
                "B",
                "C",
                "D",
            )))
            self.assertEqual(membershipsB, set(("A", )))
            self.assertEqual(membershipsC, set(("A", )))
            self.assertEqual(membershipsD, set(("A", )))
            self.assertEqual(membershipsE, set(()))

            # Change and check the result
            yield db.setGroupMembers("A", (
                "B",
                "C",
                "E",
            ))

            membersA = yield db.getMembers("A")
            membershipsB = yield db.getMemberships("B")
            membershipsC = yield db.getMemberships("C")
            membershipsD = yield db.getMemberships("D")
            membershipsE = yield db.getMemberships("E")

            self.assertEqual(membersA, set((
                "B",
                "C",
                "E",
            )))
            self.assertEqual(membershipsB, set(("A", )))
            self.assertEqual(membershipsC, set(("A", )))
            self.assertEqual(membershipsD, set())
            self.assertEqual(membershipsE, set(("A", )))

            yield db.clean()
    def test_cachingDBInsertUncached(self):
    
        for processType in ("Single", "Combined",):
            config.ProcessType = processType

            # Get the DB
            db_path = os.path.abspath(self.mktemp())
            db = ProxySqliteDB(db_path)
            
            # Do one insert and check the result for the one we will remove
            yield db.setGroupMembers("AA", ("BB", "CC", "DD",))
            yield db.getMemberships("DD")
    
            # Change and check the result
            yield db.setGroupMembers("AA", ("BB", "CC", "EE",))
    
            membersAA = yield db.getMembers("AA")
            membershipsBB = yield db.getMemberships("BB")
            membershipsCC = yield db.getMemberships("CC")
            membershipsDD = yield db.getMemberships("DD")
            membershipsEE = yield db.getMemberships("EE")
    
            self.assertEqual(membersAA, set(("BB", "CC", "EE",)))
            self.assertEqual(membershipsBB, set(("AA",)))
            self.assertEqual(membershipsCC, set(("AA",)))
            self.assertEqual(membershipsDD, set())
            self.assertEqual(membershipsEE, set(("AA",)))

            yield db.clean()
    def test_cachingDBRemoveSpecial(self):
    
        for processType in ("Single", "Combined",):
            config.ProcessType = processType

            # Get the DB
            db_path = os.path.abspath(self.mktemp())
            db = ProxySqliteDB(db_path)
            
            # Do one insert and check the result
            yield db.setGroupMembers("A", ("B", "C", "D",))
            yield db.setGroupMembers("X", ("B", "C",))
    
            membershipsB = yield db.getMemberships("B")
            membershipsC = yield db.getMemberships("C")
            membershipsD = yield db.getMemberships("D")
            
            # Remove and check the result
            yield db.removeGroup("A")
    
            membersA = yield db.getMembers("A")
            membersX = yield db.getMembers("X")
            membershipsB = yield db.getMemberships("B")
            membershipsC = yield db.getMemberships("C")
            membershipsD = yield db.getMemberships("D")
    
            self.assertEqual(membersA, set())
            self.assertEqual(membersX, set(("B", "C",)))
            self.assertEqual(membershipsB, set("X",))
            self.assertEqual(membershipsC, set("X",))
            self.assertEqual(membershipsD, set())

            yield db.clean()
    def test_DBUpgrade(self):
    
        # Get the DB
        db_path = os.path.abspath(self.mktemp())
        db = self.old_ProxyDB(db_path)
        yield db.setGroupMembers("A", ("B", "C", "D",))

        membersA = yield db.getMembers("A")
        membershipsB = yield db.getMemberships("B")

        self.assertEqual(membersA, set(("B", "C", "D",)))
        self.assertEqual(membershipsB, set(("A",)))
        self.assertEqual(set([row[1] for row in (yield db.query("PRAGMA index_list(GROUPS)"))]), set())
        db.close()
        db = None
        
        db = ProxySqliteDB(db_path)

        membersA = yield db.getMembers("A")
        membershipsB = yield db.getMemberships("B")

        self.assertEqual(membersA, set(("B", "C", "D",)))
        self.assertEqual(membershipsB, set(("A",)))
        self.assertEqual(set([row[1] for row in (yield db.query("PRAGMA index_list(GROUPS)"))]), set(("GROUPNAMES", "MEMBERS")))
        db.close()
        db = None
Beispiel #5
0
    def test_cachingDBInsertUncached(self):

        for processType in ("Single", "Combined",):
            config.ProcessType = processType

            # Get the DB
            db_path = os.path.abspath(self.mktemp())
            db = ProxySqliteDB(db_path)

            # Do one insert and check the result for the one we will remove
            yield db.setGroupMembers("AA", ("BB", "CC", "DD",))
            yield db.getMemberships("DD")

            # Change and check the result
            yield db.setGroupMembers("AA", ("BB", "CC", "EE",))

            membersAA = yield db.getMembers("AA")
            membershipsBB = yield db.getMemberships("BB")
            membershipsCC = yield db.getMemberships("CC")
            membershipsDD = yield db.getMemberships("DD")
            membershipsEE = yield db.getMemberships("EE")

            self.assertEqual(membersAA, set(("BB", "CC", "EE",)))
            self.assertEqual(membershipsBB, set(("AA",)))
            self.assertEqual(membershipsCC, set(("AA",)))
            self.assertEqual(membershipsDD, set())
            self.assertEqual(membershipsEE, set(("AA",)))

            yield db.clean()
Beispiel #6
0
    def test_DBUpgrade(self):

        # Get the DB
        db_path = os.path.abspath(self.mktemp())
        db = self.old_ProxyDB(db_path)
        yield db.setGroupMembers("A", ("B", "C", "D",))

        membersA = yield db.getMembers("A")
        membershipsB = yield db.getMemberships("B")

        self.assertEqual(membersA, set(("B", "C", "D",)))
        self.assertEqual(membershipsB, set(("A",)))
        self.assertEqual(set([row[1] for row in (yield db.query("PRAGMA index_list(GROUPS)"))]), set())
        db.close()
        db = None

        db = ProxySqliteDB(db_path)

        membersA = yield db.getMembers("A")
        membershipsB = yield db.getMemberships("B")

        self.assertEqual(membersA, set(("B", "C", "D",)))
        self.assertEqual(membershipsB, set(("A",)))
        self.assertEqual(set([row[1] for row in (yield db.query("PRAGMA index_list(GROUPS)"))]), set(("GROUPNAMES", "MEMBERS")))
        db.close()
        db = None
 def test_normalDB(self):
 
     # Get the DB
     db_path = os.path.abspath(self.mktemp())
     db = ProxySqliteDB(db_path)
     yield db.setGroupMembers("A", ("B", "C", "D",))
     
     membersA = yield db.getMembers("A")
     membershipsB = yield db.getMemberships("B")
     
     self.assertEqual(membersA, set(("B", "C", "D",)))
     self.assertEqual(membershipsB, set(("A",)))
Beispiel #8
0
    def test_normalDB(self):

        # Get the DB
        db_path = os.path.abspath(self.mktemp())
        db = ProxySqliteDB(db_path)
        yield db.setGroupMembers("A", ("B", "C", "D",))

        membersA = yield db.getMembers("A")
        membershipsB = yield db.getMemberships("B")

        self.assertEqual(membersA, set(("B", "C", "D",)))
        self.assertEqual(membershipsB, set(("A",)))
 def test_normalDBNonAscii(self):
 
     # Get the DB
     db_path = os.path.abspath(self.mktemp())
     db = ProxySqliteDB(db_path)
     principalID = "Test \xe4\xbd\x90\xe8\x97\xa4"
     yield db.setGroupMembers(principalID, ("B", "C", "D",))
     
     membersA = yield db.getMembers(principalID)
     membershipsB = yield db.getMemberships("B")
     
     self.assertEqual(membersA, set(("B", "C", "D",)))
     self.assertEqual(membershipsB, set((principalID,)))
Beispiel #10
0
    def test_normalDBNonAscii(self):

        # Get the DB
        db_path = os.path.abspath(self.mktemp())
        db = ProxySqliteDB(db_path)
        principalID = "Test \xe4\xbd\x90\xe8\x97\xa4"
        yield db.setGroupMembers(principalID, ("B", "C", "D",))

        membersA = yield db.getMembers(principalID)
        membershipsB = yield db.getMemberships("B")

        self.assertEqual(membersA, set(("B", "C", "D",)))
        self.assertEqual(membershipsB, set((principalID,)))
    def test_cachingDBInsert(self):
    
        for processType in ("Single", "Combined",):
            config.ProcessType = processType

            # Get the DB
            db_path = os.path.abspath(self.mktemp())
            db = ProxySqliteDB(db_path)
            
            # Do one insert and check the result
            yield db.setGroupMembers("A", ("B", "C", "D",))
    
            membersA = yield db.getMembers("A")
            membershipsB = yield db.getMemberships("B")
            membershipsC = yield db.getMemberships("C")
            membershipsD = yield db.getMemberships("D")
            membershipsE = yield db.getMemberships("E")
    
            self.assertEqual(membersA, set(("B", "C", "D",)))
            self.assertEqual(membershipsB, set(("A",)))
            self.assertEqual(membershipsC, set(("A",)))
            self.assertEqual(membershipsD, set(("A",)))
            self.assertEqual(membershipsE, set(()))
            
            # Change and check the result
            yield db.setGroupMembers("A", ("B", "C", "E",))
    
            membersA = yield db.getMembers("A")
            membershipsB = yield db.getMemberships("B")
            membershipsC = yield db.getMemberships("C")
            membershipsD = yield db.getMemberships("D")
            membershipsE = yield db.getMemberships("E")
    
            self.assertEqual(membersA, set(("B", "C", "E",)))
            self.assertEqual(membershipsB, set(("A",)))
            self.assertEqual(membershipsC, set(("A",)))
            self.assertEqual(membershipsD, set())
            self.assertEqual(membershipsE, set(("A",)))