def testRemove(self):
        metrics = makeExampleMetrics()
        datastore = PosixDatastore(config=self.configFile,
                                   registry=self.registry)
        # Put
        dataUnits = frozenset(("visit", "filter"))
        dataId = {"visit": 638, "filter": "U"}

        sc = self.storageClassFactory.getStorageClass("StructuredData")
        ref = self.makeDatasetRef("metric", dataUnits, sc, dataId)
        datastore.put(metrics, ref)

        # Does it exist?
        self.assertTrue(datastore.exists(ref))

        # Get
        metricsOut = datastore.get(ref)
        self.assertEqual(metrics, metricsOut)
        # Remove
        datastore.remove(ref)

        # Does it exist?
        self.assertFalse(datastore.exists(ref))

        # Do we now get a predicted URI?
        uri = datastore.getUri(ref, predict=True)
        self.assertTrue(uri.endswith("#predicted"))

        # Get should now fail
        with self.assertRaises(FileNotFoundError):
            datastore.get(ref)
        # Can only delete once
        with self.assertRaises(FileNotFoundError):
            datastore.remove(ref)
Esempio n. 2
0
    def testRemove(self):
        catalog = self.makeExampleCatalog()
        datastore = PosixDatastore(config=self.configFile,
                                   registry=self.registry)

        # Put
        storageClass = self.storageClassFactory.getStorageClass(
            "SourceCatalog")
        dataUnits = frozenset(("visit", "filter"))
        dataId = {"visit": 1234567, "filter": "blue"}

        ref = self.makeDatasetRef("calexp", dataUnits, storageClass, dataId)
        datastore.put(catalog, ref)

        # Does it exist?
        self.assertTrue(datastore.exists(ref))

        # Get
        catalogOut = datastore.get(ref)
        self.assertCatalogEqual(catalog, catalogOut)

        # Remove
        datastore.remove(ref)

        # Does it exist?
        self.assertFalse(datastore.exists(ref))

        # Get should now fail
        with self.assertRaises(FileNotFoundError):
            datastore.get(ref)
        # Can only delete once
        with self.assertRaises(FileNotFoundError):
            datastore.remove(ref)