def make_visit(seat: arm.Seat, person: str, tfrom="03:00", tto="04:00") -> arm.Visit: now = djut.localtime() present_from = aud.make_dt(now, tfrom) present_to = aud.make_dt(now, tto) assert present_from < present_to v = arm.Visit(givenname=person, familyname="fn", street_and_number="sn", zipcode="12345", town="t", phone=person, email=f"{person}@fn.de", status_3g=arm.G_IMPFT, submission_dt=now, present_from_dt=present_from, present_to_dt=present_to, seat=seat) v.save() return v
def test_make_dt_with_tz(): tzname = djut.get_current_timezone_name() now = djut.localtime() result = aud.make_dt(now, "12:34") print(tzname, now.tzname(), result.tzname()) assert result.tzinfo.utcoffset(result) == \ pytz.timezone(settings.TIME_ZONE).utcoffset(result) assert result.day == now.day assert result.hour == 12 assert result.minute == 34 assert result.second == 0
def test_make_dt_with_tz(): tzname = djut.get_current_timezone_name() now = djut.localtime() result = aud.make_dt(now, "12:34") print(f"TZ:{tzname}, now:{now.tzname()}, result:{result.tzname()}") print(result.isoformat()) assert result.tzname() == now.tzname() assert result.day == now.day assert result.hour == 12 assert result.minute == 34 assert result.second == 0
def freeze_at(ts: str): return freeze_time(aud.make_dt('now', ts))
def test_make_dt_illformed(): with pytest.raises(AssertionError) as ex: aud.make_dt(djut.localtime(), "23.45") assert "hh:mm" in str(ex.value)
def test_make_dt_naive(): with pytest.raises(AssertionError): aud.make_dt(dt.datetime.now(), "01:23")
def freeze_at(daytime_string: str): return freeze_time(aud.make_dt('now', daytime_string))