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"
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
def test_timepad_event_statuses(): assert Timepad().event_statuses
def test_timepad_event_catogories(): assert Timepad().event_categories
def test_timepad_token_in_environ(): assert "TIMEPAD_TOKEN" in os.environ Timepad()
def test_timepad_get_events_not_moderated(requests_get_events_not_moderated): assert len(Timepad().get_events()) == 1
def test_timepad_get_event_without_args(requests_get_event): with pytest.raises(ValueError): Timepad().get_event()
def test_timepad_get_event_by_url(requests_get_event): Timepad().get_event(event_url="https://test.test/event/12345/")
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)
def test_timepad_adress_city4(requests_get_event_adress_city4): tags = ("adress", ) with pytest.raises(TypeError): Timepad().get_event(event_id=12345, tags=tags)
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"
def test_timepad_token_without(remove_token): with pytest.raises(ValueError): Timepad()
def test_timepad_adress_city1(requests_get_event_adress_city1): tags = ("adress", ) event = Timepad().get_event(event_id=12345, tags=tags) assert event.adress == "Санкт-Петербург"
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"
def test_timepad_ticket_statuses(): assert Timepad().tickets_statuses
def test_timepad_get_event_by_id(requests_get_event): Timepad().get_event(event_id=12345)
def test_timepad_token_in_args(): assert "TIMEPAD_TOKEN" in os.environ token = os.environ.get("TIMEPAD_TOKEN") Timepad(token=token)
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
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"
def test_timepad_get_event_not_moderated(requests_get_event_not_moderated): assert Timepad().get_event(event_id=12345) is None
def test_timepad_get_events(requests_get_events): assert len(Timepad().get_events()) == 1