Test Rapla-File
This commit is contained in:
@ -188,10 +188,12 @@ async def buildICALfromKey(url, onlyUpdate, testing=True):
|
||||
if page.text[:10] == "BEGIN:VCAL":
|
||||
info = page.headers['content-disposition']
|
||||
kursname = info[info.find('filename=')+9:-4].upper()
|
||||
writeToFile(f"rapla{kursname}.ical", page)
|
||||
assert "TMB22" in kursname
|
||||
writeToFile(f"calendars/rapla{kursname}.ical", page)
|
||||
if not onlyUpdate:
|
||||
writeKursToDB(kursname, url)
|
||||
return url
|
||||
assert "TMB22" in Rapla.query.filter(Rapla.name == kursname).first().file
|
||||
return f"rapla{kursname}.ical"
|
||||
else:
|
||||
return 200
|
||||
else:
|
||||
@ -203,8 +205,12 @@ async def buildICALfromKey(url, onlyUpdate, testing=True):
|
||||
start = f'{(datetime.now() - relativedelta(days=183)):%Y-%m-%d}'
|
||||
end = f'{(datetime.now() + relativedelta(days=183)):%Y-%m-%d}'
|
||||
payload = {"url": url, "start": start, "end": end}
|
||||
req = await s.post(url="https://dh-api.paulmartin.cloud/rapla", data=payload,
|
||||
headers={'Content-Type': 'application/x-www-form-urlencoded'}, timeout=15)
|
||||
if testing:
|
||||
req = await s.post(url="https://dh-api.paulmartin.cloud/rapla", data=payload,
|
||||
headers={'Content-Type': 'application/x-www-form-urlencoded'}, timeout=20)
|
||||
else:
|
||||
req = await s.post(url="https://dh-api.paulmartin.cloud/rapla", data=payload,
|
||||
headers={'Content-Type': 'application/x-www-form-urlencoded'}, timeout=10)
|
||||
jsonresp = json.loads(req.text)
|
||||
if testing:
|
||||
assert len(jsonresp) > 0
|
||||
|
||||
Reference in New Issue
Block a user