identity
identity copied to clipboard
Testing Auth with PyTest
Firstly thanks for your project, it is making it much easier to setup a login then doing it through MSAL.
I am new to working with AZURE and trying to do basic login etc. I am trying to update my tests. How can I simulate a login to then allow the testing of protected api?
Curerntly they looks like:
def test_form_submit_filtered():
with app.app.test_client() as c:
rv = c.post(
"/search",
data={
"searchQuery": "",
"includeModeRail": "on",
"includeModeMarine": "on",
"yearSlider-min": "2010",
"yearSlider-max": "2024",
"relevanceCutoff": "0.7",
"includeSafetyIssues": "on",
"includeRecommendations": "on",
"includeReportSection": "on",
},
follow_redirects=True,
)
assert rv.status == "200 OK"
df = pd.read_html(StringIO(json.loads(rv.data)["html_table"]))[0]
assert df["year"].isin(range(2010, 2025)).all()
assert df["mode"].isin(["Rail", "Marine"]).all()