Exemplo n.º 1
0
    def testDeleteCreatePair(self):
        # Test coverage for a bug which was present in Axiom: deleting
        # the newest item in a database and then creating a new item
        # re-used the deleted item's oid causing all manner of
        # ridiculuousness.
        st = store.Store()

        i = itemtest.PlainItem(store=st)

        oldStoreID = i.storeID
        i.deleteFromStore()
        j = itemtest.PlainItem(store=st)
        self.failIfEqual(oldStoreID, j.storeID)
Exemplo n.º 2
0
    def testLoadUnimportedPlainItem(self):
        """
        Test that an Item in the database can be loaded out of the
        database, even if the module defining its Python class has not
        been imported, as long as its class definition has not moved
        since it was added to the database.
        """
        storePath = filepath.FilePath(self.mktemp())
        st = store.Store(storePath)
        itemID = itemtest.PlainItem(store=st, plain=u'Hello, world!!!').storeID
        st.close()

        e = os.environ.copy()
        d = defer.Deferred()
        p = ProcessOutputCollector(d)
        try:
            reactor.spawnProcess(p, sys.executable, [
                sys.executable, '-Wignore',
                itemtestmain.__file__.rstrip('co'), storePath.path,
                str(itemID)
            ], e)
        except NotImplementedError:
            raise unittest.SkipTest("Implement processes here")

        def cbOutput(output):
            self.assertEquals(''.join(output).strip(), 'Hello, world!!!')

        def ebBlah(err):
            log.err(err)
            self.fail(''.join(err.value.args[0].error))

        return d.addCallbacks(cbOutput, ebBlah)
Exemplo n.º 3
0
 def testDeleteThenLoad(self):
     st = store.Store()
     i = itemtest.PlainItem(store=st)
     oldStoreID = i.storeID
     self.assertEquals(st.getItemByID(oldStoreID, default=1234), i)
     i.deleteFromStore()
     self.assertEquals(st.getItemByID(oldStoreID + 100, default=1234), 1234)
     self.assertEquals(st.getItemByID(oldStoreID, default=1234), 1234)
Exemplo n.º 4
0
 def testLoadLoadedPlainItem(self):
     """
     Test that loading an Item out of the store by its Store ID
     when a Python object representing that Item already exists in
     memory returns the same object as the one which already
     exists.
     """
     st = store.Store()
     item = itemtest.PlainItem(store=st)
     self.assertIdentical(item, st.getItemByID(item.storeID))
Exemplo n.º 5
0
 def testCreatePlainItem(self):
     st = store.Store()
     s = itemtest.PlainItem(store=st)
Exemplo n.º 6
0
 def testPersistentValuesWithoutValue(self):
     st = store.Store()
     pi = itemtest.PlainItem(store=st)
     self.assertEqual(pi.persistentValues(), {'plain': None})
Exemplo n.º 7
0
 def testPersistentValues(self):
     st = store.Store()
     pi = itemtest.PlainItem(store=st, plain=u'hello')
     self.assertEqual(pi.persistentValues(), {'plain': u'hello'})