示例#1
0
    def setUp(self):
        """
        make a dataset with 10 images with 2 ligthcurves + one empty image
        """
        self.session = self.database.Session()
        self.band = gen_band(central=150**6)
        self.dataset = gen_dataset('expiring runningcatalog test')
        skyregion = gen_skyregion(self.dataset)
        datapoints = 10

        start = datetime.fromtimestamp(0)
        ten_sec = timedelta(seconds=10)
        xtrsrcs1 = []
        xtrsrcs2 = []
        images = []
        assocs = []
        for i in range(datapoints):
            taustart_ts = start + ten_sec * i
            image = gen_image(self.band, self.dataset, skyregion, taustart_ts)

            if i == 5:
                image.int = 10
            images.append(image)
            xtrsrcs1.append(gen_extractedsource(image))
            xtrsrcs2.append(gen_extractedsource(image))

        # now we can make runningcatalog, we use first xtrsrc as trigger src
        self.runningcatalog1 = gen_runningcatalog(xtrsrcs1[0], self.dataset)
        runningcatalog2 = gen_runningcatalog(xtrsrcs2[0], self.dataset)
        assocskyrgn1 = gen_assocskyrgn(self.runningcatalog1, skyregion)
        assocskyrgn2 = gen_assocskyrgn(runningcatalog2, skyregion)

        # create the associations. Can't do this directly since the
        # association table has non nullable columns
        for xtrsrc in xtrsrcs1:
            assocs.append(gen_assocxtrsource(self.runningcatalog1, xtrsrc))
        for xtrsrc in xtrsrcs2:
            assocs.append(gen_assocxtrsource(runningcatalog2, xtrsrc))

        self.empty_image = gen_image(self.band, self.dataset, skyregion,
                                     taustart_ts)

        self.session.add_all([
            self.band, skyregion, self.runningcatalog1, runningcatalog2,
            assocskyrgn1, assocskyrgn2, self.empty_image
        ] + images + xtrsrcs1 + xtrsrcs2 + assocs)
        self.session.flush()
        self.session.commit()
示例#2
0
    def setUp(self):
        """
        make a dataset with 10 images with 2 ligthcurves + one empty image
        """
        self.session = self.database.Session()
        self.band = gen_band(central=150**6)
        self.dataset = gen_dataset('expiring runningcatalog test')
        skyregion = gen_skyregion(self.dataset)
        datapoints = 10

        start = datetime.fromtimestamp(0)
        ten_sec = timedelta(seconds=10)
        xtrsrcs1 = []
        xtrsrcs2 = []
        images = []
        assocs = []
        for i in range(datapoints):
            taustart_ts = start + ten_sec * i
            image = gen_image(self.band, self.dataset, skyregion, taustart_ts)

            if i == 5:
                image.int = 10
            images.append(image)
            xtrsrcs1.append(gen_extractedsource(image))
            xtrsrcs2.append(gen_extractedsource(image))

        # now we can make runningcatalog, we use first xtrsrc as trigger src
        self.runningcatalog1 = gen_runningcatalog(xtrsrcs1[0], self.dataset)
        runningcatalog2 = gen_runningcatalog(xtrsrcs2[0], self.dataset)
        assocskyrgn1 = gen_assocskyrgn(self.runningcatalog1, skyregion)
        assocskyrgn2 = gen_assocskyrgn(runningcatalog2, skyregion)

        # create the associations. Can't do this directly since the
        # association table has non nullable columns
        for xtrsrc in xtrsrcs1:
            assocs.append(gen_assocxtrsource(self.runningcatalog1, xtrsrc))
        for xtrsrc in xtrsrcs2:
            assocs.append(gen_assocxtrsource(runningcatalog2, xtrsrc))

        self.empty_image = gen_image(self.band, self.dataset, skyregion, taustart_ts)

        self.session.add_all([self.band, skyregion, self.runningcatalog1, runningcatalog2,
                              assocskyrgn1, assocskyrgn2, self.empty_image] +
                             images + xtrsrcs1 + xtrsrcs2 + assocs)
        self.session.flush()
        self.session.commit()
示例#3
0
    def test_delete_dataset(self):
        db = Database()
        dataset = gen_dataset('delete test')
        band = gen_band(dataset)
        skyregion = gen_skyregion(dataset)
        image = gen_image(band, dataset, skyregion)
        extractedsource = gen_extractedsource(image)
        runningcatalog = gen_runningcatalog(extractedsource, dataset)
        db.session.add_all((
            dataset, band, skyregion, image, extractedsource, runningcatalog,
        ))
        db.session.flush()

        db.session.delete(dataset)
        db.session.flush()

        images = db.session.query(Image).filter(Image.dataset==dataset).all()
        self.assertEqual(len(images), 0)
示例#4
0
    def test_delete_dataset(self):
        db = Database()
        dataset = gen_dataset('delete test')
        band = gen_band(dataset)
        skyregion = gen_skyregion(dataset)
        image = gen_image(band, dataset, skyregion)
        extractedsource = gen_extractedsource(image)
        runningcatalog = gen_runningcatalog(extractedsource, dataset)
        db.session.add_all((
            dataset,
            band,
            skyregion,
            image,
            extractedsource,
            runningcatalog,
        ))
        db.session.flush()

        db.session.delete(dataset)
        db.session.flush()

        images = db.session.query(Image).filter(Image.dataset == dataset).all()
        self.assertEqual(len(images), 0)