Example #1
0
def test_timepad_post_text(monkeypatch, description):
    timepad_response_event = dict(
        moderation_status="moderated",
        **description,
    )

    def get(*args, **kwargs):
        return Response(ok=True, json_items=timepad_response_event)

    monkeypatch.setattr(requests, "get", get)

    tags = ("post_text", )
    event = Timepad().get_event(event_id=12345, tags=tags)

    assert event.post_text == "test"
Example #2
0
def test_timepad_price(monkeypatch, ticket_type, answ, is_registration_open):
    timepad_response_event = dict(
        moderation_status="moderated",
        registration_data=dict(
            price_min=2,
            price_max=2,
        ),
        ticket_types=[ticket_type],
    )
    timepad_response_event["registration_data"][
        "is_registration_open"] = is_registration_open

    def get(*args, **kwargs):
        return Response(ok=True, json_items=timepad_response_event)

    monkeypatch.setattr(requests, "get", get)
    tags = ("price", )
    event = Timepad().get_event(event_id=12345, tags=tags)

    assert event.price == answ
Example #3
0
def test_timepad_event_statuses():
    assert Timepad().event_statuses
Example #4
0
def test_timepad_event_catogories():
    assert Timepad().event_categories
Example #5
0
def test_timepad_token_in_environ():
    assert "TIMEPAD_TOKEN" in os.environ
    Timepad()
Example #6
0
def test_timepad_get_events_not_moderated(requests_get_events_not_moderated):
    assert len(Timepad().get_events()) == 1
Example #7
0
def test_timepad_get_event_without_args(requests_get_event):
    with pytest.raises(ValueError):
        Timepad().get_event()
Example #8
0
def test_timepad_get_event_by_url(requests_get_event):
    Timepad().get_event(event_url="https://test.test/event/12345/")
Example #9
0
def test_timepad_date_to(requests_get_event_date_to):
    tags = ("date_to", )
    event = Timepad().get_event(event_id=12345, tags=tags)

    assert isinstance(event.date_to, datetime)
Example #10
0
def test_timepad_adress_city4(requests_get_event_adress_city4):
    tags = ("adress", )

    with pytest.raises(TypeError):
        Timepad().get_event(event_id=12345, tags=tags)
Example #11
0
def test_timepad_adress_city3(requests_get_event_adress_city3):
    tags = ("adress", )
    event = Timepad().get_event(event_id=12345, tags=tags)

    assert event.adress == "1, 1"
Example #12
0
def test_timepad_token_without(remove_token):
    with pytest.raises(ValueError):
        Timepad()
Example #13
0
def test_timepad_adress_city1(requests_get_event_adress_city1):
    tags = ("adress", )
    event = Timepad().get_event(event_id=12345, tags=tags)

    assert event.adress == "Санкт-Петербург"
Example #14
0
def test_timepad_adress(requests_get_event_adress):
    tags = ("adress", )
    event = Timepad().get_event(event_id=12345, tags=tags)

    assert event.adress == "test_address, м.test subway"
Example #15
0
def test_timepad_ticket_statuses():
    assert Timepad().tickets_statuses
Example #16
0
def test_timepad_get_event_by_id(requests_get_event):
    Timepad().get_event(event_id=12345)
Example #17
0
def test_timepad_token_in_args():
    assert "TIMEPAD_TOKEN" in os.environ
    token = os.environ.get("TIMEPAD_TOKEN")
    Timepad(token=token)
Example #18
0
def test_timepad_get_event_with_tags(requests_get_event):
    tags = ("adress", "category")
    event = Timepad().get_event(event_id=12345, tags=tags)
    assert event._fields == tags
Example #19
0
def test_timepad_poster_imag(requests_get_event_poster_imag):
    tags = ("poster_imag", )
    event = Timepad().get_event(event_id=12345, tags=tags)

    assert event.poster_imag == "test_image"
Example #20
0
def test_timepad_get_event_not_moderated(requests_get_event_not_moderated):
    assert Timepad().get_event(event_id=12345) is None
Example #21
0
def test_timepad_get_events(requests_get_events):
    assert len(Timepad().get_events()) == 1