def test_parse_invalid_get_metadata_response(event):
    # ARRANGE
    xml = resources.load_xml_resource(event)
    event_parser = EventParser()

    # ACT
    with pytest.raises(InvalidEventException):
        event = event_parser.get_event("getMetadataResponse", xml)
Esempio n. 2
0
def test_get_message_root_tag(event):
    # ARRANGE
    xml = resources.load_xml_resource(event)

    # ACT
    root_tag = message_parser.get_message_root_tag(xml)

    # ASSERT
    assert root_tag == event
Esempio n. 3
0
def test_ebucore_transformation():
    # ARRANGE
    xml = resources.load_xml_resource("getMetadataResponse")

    # ACT
    ebu_xml = transform_to_ebucore(xml)

    # ASSERT
    assert b"ebuCoreMain" in ebu_xml
def test_invalid_timecode_to_frames(timecode):
    # ARRANGE
    xml = resources.load_xml_resource("getMetadataResponse")
    event_parser = EventParser()
    event = event_parser.get_event("getMetadataResponse", xml)

    # ACT
    with pytest.raises(InvalidEventException):
        event.metadata._VideoMetadata__timecode_to_frames(timecode[0], timecode[1])
def test_parse_get_metadata_response_with_subtitles():
    # ARRANGE
    xml = resources.load_xml_resource("getMetadataResponseWithSubtitles")
    event_parser = EventParser()

    # ACT
    event = event_parser.get_event("getMetadataResponse", xml)

    # ASSERT
    assert event.metadata.openOT_available == True
    assert event.metadata.closedOT_available == True
def test_timecode_to_frames(timecode):
    # ARRANGE
    xml = resources.load_xml_resource("getMetadataResponse")
    event_parser = EventParser()
    event = event_parser.get_event("getMetadataResponse", xml)

    # ACT
    frames = event.metadata._VideoMetadata__timecode_to_frames(timecode[0], timecode[1])

    # ASSERT
    assert frames == timecode[2]
Esempio n. 7
0
def test_construct_subtitle_request():
    # ARRANGE
    ot_type = "open"
    correlation_id = "correlationId"
    media_id = "mediaId"
    ref_xml = resources.load_xml_resource("makeSubtitleAvailableRequest")

    # ACT
    test_xml = generate_make_subtitle_available_request_xml(
        ot_type, correlation_id, media_id)

    # ASSERT
    assert ref_xml == test_xml
def test_parse_metadata_updated_event():
    # ARRANGE
    xml = resources.load_xml_resource("metadataUpdatedEvent")
    event_parser = EventParser()

    # ACT
    event = event_parser.get_event("metadataUpdatedEvent", xml)

    # ASSERT
    assert event.metadata.media_id == "TESTJEVANRUDOLF"
    assert event.timestamp == "2019-09-24T17:21:28.787+02:00"
    assert event.media_id == "TESTJEVANRUDOLF"
    assert event.metadata.raw is not None
Esempio n. 9
0
def test_construct_sidecar():
    # ARRANGE
    metadata_dict = {
        "PID": "abc123",
        "Md5": "a1b2c3d4e5f6",
        "MEDIA_ID": "media-id",
    }
    ref_xml = resources.load_xml_resource("MHSidecar")

    # ACT
    test_xml = construct_sidecar(metadata_dict)

    # ASSERT
    assert ref_xml == test_xml
def test_parse_calculate_resolution_xpath(event, res):
    # ARRANGE
    xml = resources.load_xml_resource(event)
    event_parser = EventParser()

    # ACT
    event_parser.event = event_parser._parse_event("getMetadataResponse", xml)
    resolution = event_parser._calculate_resolution_xpath()

    # ASSERT
    
    assert resolution == (
        f"//ebu:format[@formatDefinition='current'][./ebu:videoFormat[@videoFormatDefinition='{res}']]"
    )
def test_parse_get_metadata_response(event):
    # ARRANGE
    xml = resources.load_xml_resource(event)
    event_parser = EventParser()

    # ACT
    event = event_parser.get_event("getMetadataResponse", xml)

    # ASSERT
    assert event.metadata.media_id == "TEST_ID"
    assert event.timestamp == "2019-09-24T17:21:28.787+02:00"
    assert event.status == "SUCCESS"
    assert event.correlation_id == "test_correlation"
    assert event.metadata.raw is not None
    assert event.media_type in ["audio", "video"]
Esempio n. 12
0
def test_handle_message(event, mock_rabbit, mocker):
    # ARRANGE
    eventListener = EventListener()
    xml = resources.load_xml_resource(event)

    spy = mocker.spy(eventListener.rabbitClient, "send_message")
    channel_mock = mocker.MagicMock()
    method_mock = mocker.MagicMock()
    method_mock.delivery_tag = 1
    method_mock.routing_key = "test_key"

    expected_key = f"test_key.{event}"

    # ACT
    eventListener.handle_message(channel_mock, method_mock, None, xml)

    # ASSERT
    spy.assert_called_with(xml, expected_key)