Exemplo n.º 1
0
    def test_add_modify(self):

        # Duplicate file as we will change it
        newxmlfile = FilePath(self.mktemp())
        FilePath(xmlFile).copyTo(newxmlfile)

        db = AugmentXMLDB((newxmlfile.path,))

        for item in testRecords:
            yield self._checkRecord(db, item)

        newrecord = AugmentRecord(
            **testAddRecords[0]
        )
        yield db.addAugmentRecords((newrecord,))

        newdb = AugmentXMLDB((newxmlfile.path,))

        for item in testRecords:
            yield self._checkRecord(newdb, item)
        yield self._checkRecord(newdb, testAddRecords[0])

        newrecord = AugmentRecord(
            **testModifyRecords[0]
        )
        yield db.addAugmentRecords((newrecord,))

        newdb = AugmentXMLDB((newxmlfile.path,))

        for item in testRecords:
            yield self._checkRecord(newdb, item)
        yield self._checkRecord(newdb, testModifyRecords[0])
Exemplo n.º 2
0
 def test_refresh(self):
     """
     Ensure that a refresh without any file changes doesn't zero out the
     cache
     """
     dbxml = AugmentXMLDB((xmlFile,))
     keys = dbxml.db.keys()
     dbxml.refresh()
     self.assertEquals(keys, dbxml.db.keys())
Exemplo n.º 3
0
 def test_refresh(self):
     """
     Ensure that a refresh without any file changes doesn't zero out the
     cache
     """
     dbxml = AugmentXMLDB((xmlFile,))
     keys = dbxml.db.keys()
     dbxml.refresh()
     self.assertEquals(keys, dbxml.db.keys())
Exemplo n.º 4
0
 def test_shouldReparse(self):
     """
     Verify that a change to the file will get noticed
     """
     newxmlfile = FilePath(self.mktemp())
     FilePath(xmlFile).copyTo(newxmlfile)
     db = AugmentXMLDB((newxmlfile.path,))
     self.assertFalse(db._shouldReparse([newxmlfile.path])) # No need to parse
     newxmlfile.setContent("") # Change the file
     self.assertTrue(db._shouldReparse([newxmlfile.path])) # Need to parse
Exemplo n.º 5
0
 def test_shouldReparse(self):
     """
     Verify that a change to the file will get noticed
     """
     newxmlfile = FilePath(self.mktemp())
     FilePath(xmlFile).copyTo(newxmlfile)
     db = AugmentXMLDB((newxmlfile.path,))
     self.assertFalse(db._shouldReparse([newxmlfile.path]))  # No need to parse
     newxmlfile.setContent("")  # Change the file
     self.assertTrue(db._shouldReparse([newxmlfile.path]))  # Need to parse
Exemplo n.º 6
0
    def test_add_modify(self):

        dbpath = os.path.abspath(self.mktemp())
        db = self._db(dbpath)

        dbxml = AugmentXMLDB((xmlFile, ))
        yield db.addAugmentRecords(dbxml.db.values())

        for item in testRecords:
            yield self._checkRecord(db, item)

        # Verify that a default record is returned, even if not specified
        # in the DB
        yield self._checkRecordExists(db,
                                      "D11F03A0-97EA-48AF-9A6C-FAC7F3975767")

        newrecord = AugmentRecord(**testAddRecords[0])
        yield db.addAugmentRecords((newrecord, ))

        newdb = self._db(dbpath)

        for item in testRecords:
            yield self._checkRecord(newdb, item)
        yield self._checkRecord(newdb, testAddRecords[0])

        newrecord = AugmentRecord(**testModifyRecords[0])
        yield db.addAugmentRecords((newrecord, ))

        newdb = self._db(dbpath)

        for item in testRecords:
            yield self._checkRecord(newdb, item)
        yield self._checkRecord(newdb, testModifyRecords[0])
Exemplo n.º 7
0
    def test_read_default(self):

        db = AugmentXMLDB((xmlFileDefault,))

        for item in testRecords:
            yield self._checkRecord(db, item)

        for item in testRecordWildcardDefault:
            yield self._checkRecord(db, item)
Exemplo n.º 8
0
    def test_read(self):

        db = AugmentXMLDB((xmlFile,))

        for item in testRecords:
            yield self._checkRecord(db, item)

        # Verify that a default record is returned, even if not specified
        # in the DB
        yield self._checkRecordExists(db, "D11F03A0-97EA-48AF-9A6C-FAC7F3975767")
Exemplo n.º 9
0
 def test_normalize(self):
     """
     Ensure augment uids are normalized upon opening
     """
     newxmlfile = FilePath(self.mktemp())
     FilePath(xmlFileNormalization).copyTo(newxmlfile)
     uids = list(self.uidsFromFile(newxmlfile.path))
     self.assertEquals(uids, ['aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa'])
     AugmentXMLDB((newxmlfile.path,))
     uids = list(self.uidsFromFile(newxmlfile.path))
     self.assertEquals(uids, ['AAAAAAAA-AAAA-AAAA-AAAA-AAAAAAAAAAAA'])
Exemplo n.º 10
0
    def test_add_modify(self):

        # Duplicate file as we will change it
        newxmlfile = FilePath(self.mktemp())
        FilePath(xmlFile).copyTo(newxmlfile)

        db = AugmentXMLDB((newxmlfile.path,))

        for item in testRecords:
            yield self._checkRecord(db, item)

        newrecord = AugmentRecord(
            **testAddRecords[0]
        )
        yield db.addAugmentRecords((newrecord,))

        newdb = AugmentXMLDB((newxmlfile.path,))

        for item in testRecords:
            yield self._checkRecord(newdb, item)
        yield self._checkRecord(newdb, testAddRecords[0])

        newrecord = AugmentRecord(
            **testModifyRecords[0]
        )
        yield db.addAugmentRecords((newrecord,))

        newdb = AugmentXMLDB((newxmlfile.path,))

        for item in testRecords:
            yield self._checkRecord(newdb, item)
        yield self._checkRecord(newdb, testModifyRecords[0])
Exemplo n.º 11
0
    def test_read_default(self):

        dbpath = os.path.abspath(self.mktemp())
        db = self._db(dbpath)

        dbxml = AugmentXMLDB((xmlFileDefault,))
        yield db.addAugmentRecords(dbxml.db.values())

        for item in testRecords:
            yield self._checkRecord(db, item)

        for item in testRecordWildcardDefault:
            yield self._checkRecord(db, item)

        # Do a second time to test caching
        for item in testRecordWildcardDefault:
            yield self._checkRecord(db, item)
Exemplo n.º 12
0
    def test_read_typed_default(self):
        """
        Augments key ("uid" element in xml) can be any of the following, in
        this order of precedence:

        full uid
        <recordType>-XX*
        <recordType>-X*
        XX*
        X*
        <recordType>-Default
        Default
        """

        dbpath = os.path.abspath(self.mktemp())
        db = self._db(dbpath)

        dbxml = AugmentXMLDB((xmlFileDefault,))
        yield db.addAugmentRecords(dbxml.db.values())

        for recordType, item in testRecordTypeDefault:
            yield self._checkRecord(db, item, recordType)