def test_get_time_coordinates(self) -> None: db = create_bundle_db_in_memory() db.create_tables() fits_product_lidvid = "urn:nasa:pds:hst_13012:data_acs_raw:jbz504eoq_raw::2.3" os_filepath = path_to_testfile("jbz504eoq_raw.fits") populate_database_from_fits_file(db, os_filepath, fits_product_lidvid) file_basename = basename(os_filepath) card_dicts = db.get_card_dictionaries(fits_product_lidvid, file_basename) nb = get_time_coordinates( get_start_stop_times( DictLookup("test_get_time_coordinates", card_dicts))) doc = xml.dom.getDOMImplementation().createDocument(None, None, None) str: bytes = nb(doc).toxml().encode() str = pretty_print(str) expected = b"""<?xml version="1.0"?> <Time_Coordinates> <start_date_time>2012-09-27T20:23:28Z</start_date_time> <stop_date_time>2012-09-27T20:27:58Z</stop_date_time> </Time_Coordinates> """ self.assertEqual(expected, str)
def setUp(self) -> None: self.db = create_bundle_db_in_memory() self.db.create_tables() (handle, filepath) = tempfile.mkstemp(suffix="_raw.fits", prefix="i") os.write(handle, os.urandom(32)) os.close(handle) self.dummy_os_filepath = filepath
def test_get_acs_parameters(self) -> None: db = create_bundle_db_in_memory() db.create_tables() def get_card_dicts(suffix: str) -> CARD_SET: fits_product_lidvid = ( f"urn:nasa:pds:hst_13012:data_acs_{suffix}:jbz504eoq_{suffix}::1.0" ) os_filepath = path_to_testfile(f"jbz504eoq_{suffix}.fits") populate_database_from_fits_file(db, os_filepath, fits_product_lidvid) file_basename = basename(os_filepath) return db.get_card_dictionaries(fits_product_lidvid, file_basename) RAWish_lookups = make_hdu_lookups("test_get_acs_parameters:RAW", get_card_dicts("raw")) SHFish_lookup = DictLookup("test_get_acs_parameters:SHF", get_card_dicts("spt")) nb = get_hst_parameters(RAWish_lookups, SHFish_lookup) doc = xml.dom.getDOMImplementation().createDocument(None, None, None) text: bytes = nb(doc).toxml().encode() text = pretty_print(text) assert_golden_file_equal(self, "test_hst_parameters.golden.xml", text)
def setUp(self) -> None: self.db = create_bundle_db_in_memory() self.db.create_tables() self.db.create_bundle(_BUNDLE_LIDVID) self.db.create_other_collection(_COLLECTION_LIDVID, _BUNDLE_LIDVID) self.db.create_fits_product(_FITS_PRODUCT_LIDVID, _COLLECTION_LIDVID)
def setUp(self) -> None: self.db = create_bundle_db_in_memory() self.db.create_tables() self.db.create_bundle(_BUNDLE_LIDVID) self.db.create_other_collection(_COLLECTION_LIDVID, _BUNDLE_LIDVID) self.db.create_fits_product(_FITS_PRODUCT_LIDVID, _COLLECTION_LIDVID) self.info = Citation_Information.create_test_citation_information() # Create start/stop time in db for testing purpose self.db.update_fits_product_time( _FITS_PRODUCT_LIDVID, "2005-01-19T14:58:56Z", "2005-01-19T15:41:05Z", ) # Create target identifications db for testing purpose target_id = "09059_1" target_identifications: List[Tuple] = [( "762 Pulcova", [ "(762) Pulcova", "(762) 1913SQ", "1913SQ", "(762) 1952 QM1", "1952 QM1", "Pulcova", "Minor Planet 762", "NAIF ID 2000762", ], "Asteroid", [], "urn:nasa:pds:context:target:asteroid.762_pulcova", )] self.db.add_record_to_target_identification_db(target_id, target_identifications) # Create wavelength range in db for testing purpose self.db.update_wavelength_range( _FITS_PRODUCT_LIDVID, ["Ultraviolet", "Visible", "Near Infrared", "Infrared"], ) context_products_for_test = [ ( "urn:nasa:pds:context:investigation:individual.hst_09059::1.0", "investigation", ), ( "urn:nasa:pds:context:instrument_host:spacecraft.hst::1.0", "instrument_host", ), ("urn:nasa:pds:context:instrument:hst.acs::1.0", "instrument"), ("urn:nasa:pds:context:target:asteroid.762_pulcova::1.0", "target"), ] for id, ref_type in context_products_for_test: self.db.create_context_product(id, ref_type)
def setUp(self) -> None: self.db = create_bundle_db_in_memory() self.db.create_tables() self.db.create_bundle(_BUNDLE_LIDVID) self.db.create_other_collection(_COLLECTION_LIDVID, _BUNDLE_LIDVID) self.db.create_fits_product(_FITS_PRODUCT_LIDVID, _COLLECTION_LIDVID) self.db.create_document_collection(_DOC_COLLECTION_LIDVID, _BUNDLE_LIDVID) self.db.create_document_product(_DOC_PRODUCT_LIDVID, _DOC_COLLECTION_LIDVID) self.info = Citation_Information.create_test_citation_information() # Create start/stop time in db for testing purpose self.db.update_fits_product_time( _FITS_PRODUCT_LIDVID, "2005-01-19T14:58:56Z", "2005-01-19T15:41:05Z", ) # Create wavelength range in db for testing purpose self.db.update_wavelength_range( _FITS_PRODUCT_LIDVID, ["Visible", "Near Infrared", "Infrared"], ) # Create target identifications db for testing purpose target_id = "09059_1" target_identifications: List[Tuple] = [( "762 Pulcova", [ "(762) Pulcova", "(762) 1913SQ", "1913SQ", "(762) 1952 QM1", "1952 QM1", "Pulcova", "Minor Planet 762", "NAIF ID 2000762", ], "Asteroid", [], "urn:nasa:pds:context:target:asteroid.762_pulcova", )] self.db.add_record_to_target_identification_db(target_id, target_identifications) # Create data collection title in db for testing purpose data_collection_title = ( "Raw, uncalibrated ACS/HRC image files from HST Program 9059.") self.db.update_fits_product_collection_title(_COLLECTION_LIDVID, data_collection_title)
def setUp(self) -> None: self.db = create_bundle_db_in_memory() self.db.create_tables() self.db.create_bundle(_BUNDLE_LIDVID) # TODO add a document collection to check reference_types self.db.create_other_collection(_COLLECTION_LIDVID, _BUNDLE_LIDVID) self.db.create_fits_product(_FITS_PRODUCT_LIDVID, _COLLECTION_LIDVID) self.info = Citation_Information.create_test_citation_information() # Create start/stop time in db for testing purpose self.db.update_fits_product_time( _FITS_PRODUCT_LIDVID, "2005-01-19T14:58:56Z", "2005-01-19T15:41:05Z", ) # Create target identifications db for testing purpose target_id = "09059_1" target_identifications: List[Tuple] = [ ( "762 Pulcova", [ "(762) Pulcova", "(762) 1913SQ", "1913SQ", "(762) 1952 QM1", "1952 QM1", "Pulcova", "Minor Planet 762", "NAIF ID 2000762", ], "Asteroid", [], "urn:nasa:pds:context:target:asteroid.762_pulcova", ) ] self.db.add_record_to_target_identification_db( target_id, target_identifications ) # Create wavelength range in db for testing purpose self.db.update_wavelength_range( _FITS_PRODUCT_LIDVID, ["Ultraviolet", "Visible", "Near Infrared", "Infrared"], )
def setUp(self) -> None: self.db = create_bundle_db_in_memory() self.db.create_tables() # Create target identifications db for testing purpose target_id = "15678_1" target_identifications: List[Tuple] = [( "6478 Gaul", [ "(6478) Gault", "(6478) 1988 JC1", "1988 JC1", "(6478) 1995 KC1", "1995 KC1", "Gault", "Minor Planet 6478", "NAIF ID 2006478", ], "Asteroid", [], "urn:nasa:pds:context:target:asteroid.6478_gault", )] self.db.add_record_to_target_identification_db(target_id, target_identifications)
def setUp(self) -> None: self.db = create_bundle_db_in_memory() self.db.create_tables()
def setUp(self) -> None: self.db = create_bundle_db_in_memory() self.db.create_tables() self.info = Citation_Information.create_test_citation_information()
def setUp(self) -> None: self.db = create_bundle_db_in_memory() (handle, filepath) = tempfile.mkstemp() os.close(handle) self.dummy_os_filepath = filepath
def test_get_file_contents(self) -> None: db = create_bundle_db_in_memory() db.create_tables() fits_product_lidvid = "urn:nasa:pds:hst_13012:data_acs_raw:jbz504eoq_raw::2.0" os_filepath = path_to_testfile("jbz504eoq_raw.fits") populate_database_from_fits_file(db, os_filepath, fits_product_lidvid) file_basename = basename(os_filepath) card_dicts = db.get_card_dictionaries(fits_product_lidvid, file_basename) fb = get_file_contents(db, card_dicts, "acs", fits_product_lidvid) doc = _fragment_wrapper({"frag": fb}) str: bytes = doc.toxml().encode() str = pretty_print(str) expected = b"""<?xml version="1.0"?> <Wrapper> <Header> <local_identifier>hdu_0</local_identifier> <offset unit="byte">0</offset> <object_length unit="byte">14400</object_length> <parsing_standard_id>FITS 3.0</parsing_standard_id> <description>Global FITS Header</description> </Header> <Header> <local_identifier>hdu_1</local_identifier> <offset unit="byte">14400</offset> <object_length unit="byte">8640</object_length> <parsing_standard_id>FITS 3.0</parsing_standard_id> <description>FITS Header</description> </Header> <Array_2D_Image> <offset unit="byte">23040</offset> <axes>2</axes> <axis_index_order>Last Index Fastest</axis_index_order> <Element_Array> <data_type>SignedMSB2</data_type> </Element_Array> <Axis_Array> <axis_name>Line</axis_name> <elements>1024</elements> <sequence_number>1</sequence_number> </Axis_Array> <Axis_Array> <axis_name>Sample</axis_name> <elements>1024</elements> <sequence_number>2</sequence_number> </Axis_Array> </Array_2D_Image> <Header> <local_identifier>hdu_2</local_identifier> <offset unit="byte">2122560</offset> <object_length unit="byte">5760</object_length> <parsing_standard_id>FITS 3.0</parsing_standard_id> <description>FITS Header</description> </Header> <Header> <local_identifier>hdu_3</local_identifier> <offset unit="byte">2128320</offset> <object_length unit="byte">5760</object_length> <parsing_standard_id>FITS 3.0</parsing_standard_id> <description>FITS Header</description> </Header> </Wrapper> """ self.assertEqual(expected, str)
def setUp(self) -> None: self.bundle_db = create_bundle_db_in_memory() self.bundle_db.create_tables() self.bundle_db.create_bundle(_BUNDLE_LIDVID)
def setUp(self) -> None: self.tmpdir = tempfile.mkdtemp() self.bundle_db = create_bundle_db_in_memory() self.bundle_db.create_tables() self.bundle_db.create_bundle(_BUNDLE_LIDVID)