예제 #1
0
def test_returns_one_conversation_given_conversations_over_span_of_days():
    daily_start_datetime = datetime(year=2020, month=1, day=1, tzinfo=UTC)

    conversation_within_day = Gp2gpConversation(
        messages=test_cases.request_made(
            request_sent_date=datetime(year=2020, month=1, day=1, tzinfo=UTC)
        ),
        probe=mock_gp2gp_conversation_observability_probe,
    )
    conversation_before_day = Gp2gpConversation(
        messages=test_cases.request_made(
            request_sent_date=datetime(year=2019, month=12, day=31, tzinfo=UTC)
        ),
        probe=mock_gp2gp_conversation_observability_probe,
    )
    conversation_after_day = Gp2gpConversation(
        messages=test_cases.request_made(
            request_sent_date=datetime(year=2020, month=1, day=2, tzinfo=UTC)
        ),
        probe=mock_gp2gp_conversation_observability_probe,
    )

    gp2gp_conversations = [
        conversation_before_day,
        conversation_within_day,
        conversation_after_day,
    ]

    expected = [conversation_within_day]

    actual = filter_conversations_by_day(gp2gp_conversations, daily_start_datetime)

    assert list(actual) == expected
def test_extracts_date_requested_from_request_started_message():
    date_requested = a_datetime()

    gp2gp_messages: List[Message] = test_cases.request_made(request_sent_date=date_requested)

    conversation = Gp2gpConversation(gp2gp_messages, mock_gp2gp_conversation_observability_probe)

    actual = conversation.date_requested()

    assert actual == date_requested
def test_extracts_requesting_supplier():
    conversation = Gp2gpConversation(
        messages=test_cases.request_made(requesting_system="A System"),
        probe=mock_gp2gp_conversation_observability_probe,
    )

    actual = conversation.requesting_supplier()

    expected = "A System"

    assert actual == expected
예제 #4
0
def test_extracts_conversation_id():
    conversation = Gp2gpConversation(
        messages=test_cases.request_made(conversation_id="1234"),
        probe=mock_gp2gp_conversation_observability_probe,
    )

    expected = "1234"

    actual = conversation.conversation_id()

    assert actual == expected
def test_produces_none_as_last_sender_message_timestamp_given_request_made():
    conversation = Gp2gpConversation(
        messages=test_cases.request_made(),
        probe=mock_gp2gp_conversation_observability_probe,
    )
    mock_lookup = Mock()

    transfer_service = TransferService(
        message_stream=[],
        cutoff=timedelta(days=14),
        observability_probe=mock_transfer_observability_probe,
    )

    actual = transfer_service.derive_transfer(conversation, mock_lookup)

    assert actual.last_sender_message_timestamp is None
예제 #6
0
def test_returns_no_conversation_given_conversation_after_day():
    daily_start_datetime = datetime(year=2020, month=6, day=1, tzinfo=UTC)

    gp2gp_conversations = [
        Gp2gpConversation(
            messages=test_cases.request_made(
                request_sent_date=datetime(year=2020, month=6, day=5, tzinfo=UTC)
            ),
            probe=mock_gp2gp_conversation_observability_probe,
        )
    ]

    expected: List[Gp2gpConversation] = []

    actual = filter_conversations_by_day(gp2gp_conversations, daily_start_datetime)

    assert list(actual) == expected