Merge pull request #417 from chill117/fastapi-tests

Unit tests for FastAPI branch
This commit is contained in:
Arc
2021-12-05 22:13:10 +00:00
committed by GitHub
19 changed files with 344 additions and 46 deletions
+10 -9
View File
@@ -65,15 +65,16 @@ async def fetch_fiat_exchange_rate(currency: str, provider: str):
}
url = exchange_rate_providers[provider]["api_url"]
for key in replacements.keys():
url = url.replace("{" + key + "}", replacements[key])
if url:
for key in replacements.keys():
url = url.replace("{" + key + "}", replacements[key])
async with httpx.AsyncClient() as client:
r = await client.get(url)
r.raise_for_status()
data = r.json()
else:
data = {}
getter = exchange_rate_providers[provider]["getter"]
async with httpx.AsyncClient() as client:
r = await client.get(url)
r.raise_for_status()
data = r.json()
rate = float(getter(data, replacements))
rate = float(getter(data, replacements))
return rate
+2 -2
View File
@@ -121,8 +121,8 @@ async def api_bleskomat_lnurl(req: Request):
except LnurlHttpError as e:
return {"status": "ERROR", "reason": str(e)}
except Exception:
traceback.print_exc()
except Exception as e:
print(str(e))
return {"status": "ERROR", "reason": "Unexpected error"}
return {"status": "OK"}
+2 -1
View File
@@ -124,7 +124,8 @@ class BleskomatLnurl(BaseModel):
)
except (ValueError, PermissionError, PaymentFailure) as e:
raise LnurlValidationError("Failed to pay invoice: " + str(e))
except Exception:
except Exception as e:
print(str(e))
raise LnurlValidationError("Unexpected error")
async def use(self, conn) -> bool: