Beispiel #1
0
def test_removing_a_talk_fails_unless_grid_is_open():
    _set_global_settings(EventState.DOORS_OPEN)
    user = User.objects.create(username="******")
    talk = _create_talk(owner=user, title="A talk")

    with pytest.raises(ValueError):
        GridMutation.resolve_remove_talk(
            None,
            GraphQLInfo(user),
            slot_id=talk.slot.id,
        )
Beispiel #2
0
def test_moving_a_talk_fails_unless_landing_slot_is_clear():
    _set_global_settings(EventState.GRID_OPEN)
    user = User.objects.create(username="******")
    talk = _create_talk(owner=user, title="A talk")
    other_talk = _create_talk(owner=user, title="A talk")

    with pytest.raises(ValueError):
        GridMutation.resolve_move_talk(None,
                                       GraphQLInfo(user),
                                       talk_id=talk.id,
                                       to_slot=other_talk.slot_id)
Beispiel #3
0
def test_moving_a_talk_fails_once_session_has_started():
    _set_global_settings(EventState.DOORS_OPEN)
    user = User.objects.create(username="******")
    talk = _create_talk(owner=user, title="A talk")
    slot = _create_slot()

    with pytest.raises(ValueError):
        GridMutation.resolve_move_talk(None,
                                       GraphQLInfo(user),
                                       talk_id=talk.id,
                                       to_slot=slot.id)
Beispiel #4
0
def test_moving_a_talk_succeeds():
    _set_global_settings(EventState.GRID_OPEN)
    user = User.objects.create(username="******")
    talk = _create_talk(owner=user, title="A talk")
    slot = _create_slot()

    GridMutation.resolve_move_talk(None,
                                   GraphQLInfo(user),
                                   talk_id=talk.id,
                                   to_slot=slot.id)

    slot.refresh_from_db()
    assert slot.talk == talk
Beispiel #5
0
def test_updating_a_talk_fails_unless_grid_is_open():
    _set_global_settings(EventState.DOORS_OPEN)
    user = User.objects.create(username="******")
    talk = _create_talk(owner=user, title="A talk")

    with pytest.raises(ValueError):
        GridMutation.resolve_update_talk(
            None,
            GraphQLInfo(user),
            talk_id=talk.id,
            title="A new title",
            additional_speakers=[],
            is_open_discussion=True,
        )
Beispiel #6
0
def test_removing_a_talk_fails_once_session_has_ended():
    _set_global_settings(EventState.GRID_OPEN)
    user = User.objects.create(username="******")
    talk = _create_talk(owner=user, title="A talk")
    talk.slot.session.start_time = datetime.now(tz=utc) - timedelta(hours=1)
    talk.slot.session.end_time = datetime.now(tz=utc) - timedelta(minutes=30)
    talk.slot.session.save()

    with pytest.raises(ValueError):
        GridMutation.resolve_remove_talk(
            None,
            GraphQLInfo(user),
            slot_id=talk.slot.id,
        )
Beispiel #7
0
def test_updating_a_talk_fails_once_it_has_ended():
    _set_global_settings(EventState.GRID_OPEN)
    user = User.objects.create(username="******")
    talk = _create_talk(owner=user, title="A talk")
    talk.slot.session.start_time = datetime.now(tz=utc) - timedelta(hours=1)
    talk.slot.session.end_time = datetime.now(tz=utc) - timedelta(minutes=30)
    talk.slot.session.save()

    with pytest.raises(ValueError):
        GridMutation.resolve_update_talk(
            None,
            GraphQLInfo(user),
            talk_id=talk.id,
            title="A new title",
            additional_speakers=[],
            is_open_discussion=True,
        )
Beispiel #8
0
def test_adding_a_talk_fails_when_slot_is_already_in_use():
    _set_global_settings(EventState.GRID_OPEN)
    user = User.objects.create(username="******")
    talk = _create_talk(owner=user, title="A talk")

    with pytest.raises(ValueError):
        GridMutation.resolve_add_talk(
            None,
            GraphQLInfo(user),
            slot_id=talk.slot.id,
            title="A new title",
            additional_speakers=[],
            is_open_discussion=True,
        )

    talk.refresh_from_db()

    assert talk.slot.talk == talk
Beispiel #9
0
def test_updating_a_talk_you_own():
    _set_global_settings(EventState.GRID_OPEN)
    user = User.objects.create(username="******")
    speaker = User.objects.create(username="******")
    talk = _create_talk(owner=user, title="A talk")

    GridMutation.resolve_update_talk(
        None,
        GraphQLInfo(user),
        talk_id=talk.id,
        title="A new title",
        additional_speakers=[speaker.id],
        is_open_discussion=True,
    )

    talk.refresh_from_db()
    assert talk.title == "A new title"
    assert talk.open_discussion is True
    assert [speaker] == list(talk.other_speakers.all())
Beispiel #10
0
def test_updating_a_talk_you_do_not_own_fails():
    _set_global_settings(EventState.GRID_OPEN)
    user = User.objects.create(username="******")
    owner = User.objects.create(username="******")
    talk = _create_talk(owner=owner, title="A talk")

    with pytest.raises(ValueError):
        GridMutation.resolve_update_talk(
            None,
            GraphQLInfo(user),
            talk_id=talk.id,
            title="A new title",
            additional_speakers=[],
            is_open_discussion=True,
        )

    talk.refresh_from_db()
    assert talk.title == "A talk"
    assert talk.open_discussion is False
Beispiel #11
0
def test_removing_a_talk_succeeds():
    _set_global_settings(EventState.GRID_OPEN)
    user = User.objects.create(username="******")
    talk = _create_talk(owner=user, title="A talk")

    slot = GridMutation.resolve_remove_talk(
        None,
        GraphQLInfo(user),
        slot_id=talk.slot.id,
    )

    with pytest.raises(Slot.talk.RelatedObjectDoesNotExist):
        assert slot.talk is None
    with pytest.raises(Talk.DoesNotExist):
        Talk.objects.get(id=talk.id)
Beispiel #12
0
def test_adding_a_talk_succeeds_grid_is_open():
    _set_global_settings(EventState.GRID_OPEN)
    user = User.objects.create(username="******")
    speaker = User.objects.create(username="******")
    slot = _create_slot()

    talk_slot = GridMutation.resolve_add_talk(
        None,
        GraphQLInfo(user),
        slot_id=slot.id,
        title="A new title",
        additional_speakers=[speaker.id],
        is_open_discussion=True,
    )

    assert talk_slot == slot
    assert talk_slot.talk.title == "A new title"
    assert talk_slot.talk.open_discussion is True
    assert talk_slot.talk.owner == user
    assert [speaker] == list(talk_slot.talk.other_speakers.all())