Пример #1
0
def test_convert_to_item(user_factory, conference, submission_factory,
                         schedule_item_factory):
    user = user_factory()

    submission = submission_factory(speaker_id=user.id, conference=conference)
    item = schedule_item_factory(type="submission",
                                 submission=submission,
                                 conference=conference)

    endpoint = convert_user_to_endpoint(user)

    assert endpoint.to_item() == {
        "ChannelType": "EMAIL",
        "Address": endpoint.email,
        "Id": endpoint.id,
        "User": {
            "UserId": endpoint.id,
            "UserAttributes": {
                "Name": [endpoint.name],
                "FullName": [endpoint.full_name],
                "is_staff": [str(endpoint.is_staff)],
                "has_item_in_schedule": [item.conference.code],
                "has_cancelled_talks": [],
                "has_ticket": [],
                f"{item.conference.code}_items_in_schedule": [item.title],
            },
        },
    }
def test_adds_items_in_schedule_even_if_additional_speaker(
    user_factory,
    conference,
    submission_factory,
    schedule_item_factory,
    schedule_item_additional_speaker_factory,
):
    user = user_factory()
    additional_user = user_factory()

    submission = submission_factory(speaker_id=user.id, conference=conference)
    item = schedule_item_factory(
        type="submission", submission=submission, conference=conference
    )
    schedule_item_additional_speaker_factory(
        scheduleitem=item, user_id=additional_user.id
    )

    endpoint = convert_user_to_endpoint(additional_user)

    assert endpoint.id == str(additional_user.id)
    assert endpoint.name == additional_user.name
    assert endpoint.full_name == additional_user.full_name
    assert endpoint.is_staff == additional_user.is_staff
    assert endpoint.has_sent_submission_to == []
    assert endpoint.has_item_in_schedule == [conference.code]
    assert endpoint.has_cancelled_talks == []
def test_converts_one_user(user_factory):
    user = user_factory()

    endpoint = convert_user_to_endpoint(user)

    assert endpoint.id == str(user.id)
    assert endpoint.name == user.name
    assert endpoint.full_name == user.full_name
    assert endpoint.is_staff == user.is_staff
    assert endpoint.has_sent_submission_to == []
    assert endpoint.has_item_in_schedule == []
    assert endpoint.has_cancelled_talks == []
def test_adds_submissions_sent(user_factory, conference, submission_factory):
    user = user_factory()

    submission_factory(speaker_id=user.id, conference=conference)

    endpoint = convert_user_to_endpoint(user)

    assert endpoint.id == str(user.id)
    assert endpoint.name == user.name
    assert endpoint.full_name == user.full_name
    assert endpoint.is_staff == user.is_staff
    assert endpoint.has_sent_submission_to == [conference.code]
    assert endpoint.has_item_in_schedule == []
    assert endpoint.has_cancelled_talks == []
def test_has_list_of_talks_per_conference(
    user_factory, conference, submission_factory, schedule_item_factory
):
    user = user_factory()

    submission = submission_factory(speaker_id=user.id, conference=conference)
    item = schedule_item_factory(
        type="submission", submission=submission, conference=conference
    )

    endpoint = convert_user_to_endpoint(user)

    assert endpoint.id == str(user.id)
    assert endpoint.name == user.name
    assert endpoint.full_name == user.full_name
    assert endpoint.is_staff == user.is_staff
    assert endpoint.has_sent_submission_to == [conference.code]
    assert endpoint.has_item_in_schedule == [conference.code]
    assert endpoint.has_cancelled_talks == []
    assert endpoint.talks_by_conference == {conference.code: [item.title]}