def test_create_message_with_an_invalid_file_extension(spicy_file_extension, dd_event, config): dd_event = dd_event("OPN2101A") dd_event["name"] = f"dd_opn2101a.{spicy_file_extension}:my-bucket-name" with pytest.raises(InvalidFileExtension): create_message(dd_event, config)
def test_create_message_for_management_information(instrument, expected_tla, mi_event, config): mi_event = mi_event(instrument) actual_message = create_message(mi_event, config) assert (actual_message.description == "Management Information files uploaded to GCP bucket from Blaise5") assert actual_message.dataset == "blaise_mi" assert actual_message.iterationL1 == "BL5-test" assert actual_message.iterationL2 == expected_tla assert actual_message.iterationL3 == instrument.upper()
def test_create_message_for_data_delivery_opn(dd_event, config): dd_event = dd_event("OPN2101A") actual_message = create_message(dd_event, config) assert (actual_message.description == "Data Delivery files for OPN uploaded to GCP bucket from Blaise5") assert actual_message.dataset == "blaise_dde" assert actual_message.iterationL1 == "SYSTEMS" assert actual_message.iterationL2 == "survey_on_prem_subfolder" assert actual_message.iterationL3 == "OPN" assert actual_message.iterationL4 == "OPN2101A"
def test_create_message_for_data_delivery_lms(instrument, expected_survey_name, dd_event, config): dd_event = dd_event(instrument) actual_message = create_message(dd_event, config) assert ( actual_message.description == f"Data Delivery files for {expected_survey_name} uploaded to GCP bucket from Blaise5" ) assert actual_message.dataset == "blaise_dde_lms" assert actual_message.iterationL1 == "CLOUD" assert actual_message.iterationL2 == "test" assert actual_message.iterationL3 == instrument.upper() assert actual_message.iterationL4 == ""
def publishMsg(event, _context): config = Config.from_env() config.log() log_event(event) update_data_delivery_state(event, "in_nifi_bucket") if config.project_id is None: print("project_id not set, publish failed") return try: message = create_message(event, config) print(f"Message {message}") send_pub_sub_message(config, message) update_data_delivery_state(event, "nifi_notified") except Exception as error: print(repr(error)) update_data_delivery_state(event, "errored", repr(error))
def test_create_message_with_an_invalid_file_type(spicy_file_types, event, config): event = event(spicy_file_types) with pytest.raises(InvalidFileType): create_message(event, config)