Exemple #1
0
    def test_populate_database_from_browse_file(self) -> None:
        fits_product_lidvid = "urn:nasa:pds:hst_09059:data_acs_raw:j6gp01lzq_raw::2.0"
        fits_collection_lidvid = "urn:nasa:pds:hst_09059:data_acs_raw::2.0"
        os_filepath = path_to_testfile("j6gp01lzq_raw.fits")

        self.db.create_fits_product(fits_product_lidvid,
                                    fits_collection_lidvid)

        browse_product_lidvid = (
            "urn:nasa:pds:hst_09059:browse_acs_raw:j6gp01lzq_raw::2.0")
        browse_collection_lidvid = "urn:nasa:pds:hst_09059:browse_acs_raw::1.6"
        browse_basename = "j6gp01lzq_raw.jpg"
        byte_size = 12347
        populate_database_from_browse_file(
            self.db,
            browse_product_lidvid,
            fits_product_lidvid,
            browse_collection_lidvid,
            os_filepath,
            browse_basename,
            byte_size,
        )
        self.assertTrue(
            self.db.browse_file_exists(browse_basename, browse_product_lidvid))

        file = self.db.get_file(browse_basename, browse_product_lidvid)
        self.assertTrue(file)
        # lidvid and basename are defined to be right (in get_file())
        self.assertTrue(isinstance(file, BrowseFile))
        browse_file = cast(BrowseFile, file)
        self.assertEqual(byte_size, browse_file.byte_size)
Exemple #2
0
    def test_file_offsets(self) -> None:
        fits_product_lidvid = "urn:nasa:pds:hst_09059:data_acs_raw:j6gp01lzq_raw::2.0"
        os_filepath = path_to_testfile("j6gp01lzq_raw.fits")

        populate_database_from_fits_file(self.db, os_filepath,
                                         fits_product_lidvid)

        offsets = get_file_offsets(self.db, fits_product_lidvid)
        self.assertEqual(4, len(offsets))
Exemple #3
0
    def test_populate_from_bad_fits_file(self) -> None:
        fits_product_lidvid = "urn:nasa:pds:hst_09059:data_acs_raw:j6gp02lzq_raw::2.0"
        os_filepath = path_to_testfile("j6gp02lzq_raw.fits")

        populate_database_from_fits_file(self.db, os_filepath,
                                         fits_product_lidvid)

        self.assertFalse(
            self.db.fits_file_exists(basename(os_filepath),
                                     fits_product_lidvid))

        self.assertTrue(
            self.db.bad_fits_file_exists(basename(os_filepath),
                                         fits_product_lidvid))
Exemple #4
0
    def test_get_card_dictionaries(self) -> None:
        fits_product_lidvid = "urn:nasa:pds:hst_09059:data_acs_raw:j6gp01lzq_raw::2.0"
        os_filepath = path_to_testfile("j6gp01lzq_raw.fits")

        populate_database_from_fits_file(self.db, os_filepath,
                                         fits_product_lidvid)

        file_basename = basename(os_filepath)

        card_dicts = get_card_dictionaries(self.db, fits_product_lidvid,
                                           file_basename)

        self.assertTrue(card_dicts)
        self.assertEqual(4, len(card_dicts))
        self.assertEqual(16, int(card_dicts[0]["BITPIX"]))
Exemple #5
0
    def test_populate_from_fits_file(self) -> None:
        fits_product_lidvid = "urn:nasa:pds:hst_09059:data_acs_raw:j6gp01lzq_raw::2.0"
        os_filepath = path_to_testfile("j6gp01lzq_raw.fits")

        populate_database_from_fits_file(self.db, os_filepath,
                                         fits_product_lidvid)

        file_basename = basename(os_filepath)

        self.assertTrue(
            self.db.fits_file_exists(file_basename, fits_product_lidvid))

        self.assertFalse(
            self.db.bad_fits_file_exists(file_basename, fits_product_lidvid))

        # test that we got some HDUS
        self.assertTrue(
            self.db.hdu_exists(0, file_basename, fits_product_lidvid))

        # test that we got some cards
        self.assertTrue(self.db.card_exists("BITPIX", 0, fits_product_lidvid))