def test_process_call_analytics_file(get_event_bus_stubber,
                                     get_transcribe_analytics_processor):
    s3_setup()
    stream_setup(os.environ["STREAM_NAME"])
    get_event_bus_stubber.add_response(
        "put_events",
        {
            "Entries": [{
                "EventId": "fakeeventid"
            }],
            "FailedEntryCount": 0
        },
        {
            "Entries": [{
                "EventBusName": os.environ["INTEGRATION_BUS_NAME"],
                "Source": os.environ["NAMESPACE"],
                "Detail": ANY,
                "DetailType": "TRANSCRIBE_METADATA",
            }]
        },
    )
    get_event_bus_stubber.activate()

    get_transcribe_analytics_processor.process_file(
        MOCK_BUCKET, MOCK_CALL_ANALYTICS_FILE_PREFIX)
    s3_tear_down()
    stream_tear_down(os.environ["STREAM_NAME"])
    get_event_bus_stubber.assert_no_pending_responses()
    get_event_bus_stubber.deactivate()
 def test_process_file(self):
     # setup s3 and kinesis stream and then process the file
     s3_setup()
     stream_setup(os.environ["STREAM_NAME"])
     self._processor.process_file(MOCK_BUCKET, MOCK_XLSX_FILE_PREFIX)
     s3_tear_down()
     stream_tear_down(os.environ["STREAM_NAME"])
 def test_process_single_json_file(self):
     s3_setup()
     stream_setup(os.environ["STREAM_NAME"])
     with mock.patch.dict("os.environ"):
         del os.environ["LIST_SELECTOR"]
         self.assertIsNone(os.environ.get("LIST_SELECTOR"))
         single_record_processor = JSONFileProcessor(
             os.environ[ID],
             os.environ[CREATED_DATE],
             os.environ[TEXT],
             os.environ[LANG],
             os.environ[ACCOUNT_NAME],
             os.environ[PLATFORM],
         )
         single_record_processor.process_file(MOCK_BUCKET, MOCK_JSON_FILE_PREFIX)
     s3_tear_down()
     stream_tear_down(os.environ["STREAM_NAME"])
def test_parent_id_not_set(get_event_bus_stubber):
    s3_setup()
    stream_setup(os.environ["STREAM_NAME"])
    get_event_bus_stubber.add_response(
        "put_events",
        {
            "Entries": [{
                "EventId": "fakeeventid"
            }],
            "FailedEntryCount": 0
        },
        {
            "Entries": [{
                "EventBusName": os.environ["INTEGRATION_BUS_NAME"],
                "Source": os.environ["NAMESPACE"],
                "Detail": ANY,
                "DetailType": "TRANSCRIBE_METADATA",
            }]
        },
    )
    get_event_bus_stubber.activate()

    # delete environment variable that triggers parent_id uuidv4 generation
    del os.environ["ID"]

    processor = TranscribeCallAnalyticsProcessor(
        None,
        os.environ[CREATED_DATE],
        os.environ[TEXT],
        os.environ[LANG],
        os.environ[ACCOUNT_NAME],
        os.environ[PLATFORM],
        os.environ[SENTIMENT],
        os.environ[LIST_SELECTOR],
    )

    processor.process_file(MOCK_BUCKET, MOCK_CALL_ANALYTICS_FILE_PREFIX)
    s3_tear_down()
    stream_tear_down(os.environ["STREAM_NAME"])
    get_event_bus_stubber.assert_no_pending_responses()
    get_event_bus_stubber.deactivate()
コード例 #5
0
 def setUp(self):
     s3_setup()
     stream_setup(os.environ["STREAM_NAME"])
 def test_process_mutli_json_file(self):
     s3_setup()
     stream_setup(os.environ["STREAM_NAME"])
     self._processor.process_file(MOCK_BUCKET, MOCK_MULTI_JSON_FILE_PREFIX)
     s3_tear_down()
     stream_tear_down(os.environ["STREAM_NAME"])