diff --git a/skema/rest/tests/test_eqns_to_mets.py b/skema/rest/tests/test_eqns_to_mets.py index 66e47e4f8fc..97cb640edea 100644 --- a/skema/rest/tests/test_eqns_to_mets.py +++ b/skema/rest/tests/test_eqns_to_mets.py @@ -6,11 +6,24 @@ @pytest.mark.ci_only @pytest.mark.asyncio -async def test_post_eqns_to_mets_latex(): +async def test_post_eqns_to_mets_mathml_latex(): """ Test case for /equations-to-met. """ - latex_equations = ["E=mc^2", "c=\\frac{a}{b}"] + latex_equations = [ + """ + + E + = + m + + c + 2 + + + """, + "c=\\frac{a}{b}", + ] endpoint = "/equations-to-met" @@ -125,22 +138,12 @@ async def test_post_eqns_to_mets_latex(): @pytest.mark.ci_only @pytest.mark.asyncio -async def test_post_eqns_to_mets_mathml(): +async def test_post_eqns_to_mets_latex_mathml(): """ Test case for /equations-to-met. """ mathml_equations = [ - """ - - E - = - m - - c - 2 - - - """, + "E=mc^2", """ c diff --git a/skema/rest/workflows.py b/skema/rest/workflows.py index eaba8f47b33..e874a7067da 100644 --- a/skema/rest/workflows.py +++ b/skema/rest/workflows.py @@ -254,14 +254,12 @@ async def equations_to_met(data: schema.EquationToMET, client: httpx.AsyncClient print(r.json()) ``` """ - if "" in data.equations[0]: - eqns: List[str] = [ - utils.clean_mml(mml) for mml in data.equations - ] - else: - eqns: List[str] = [ - utils.clean_mml(eqn2mml.get_mathml_from_latex(tex)) for tex in data.equations - ] + eqns: List[str] = [] + for eqn in data.equations: + if "" in eqn: + eqns.append(utils.clean_mml(eqn)) + else: + eqns.append(utils.clean_mml(eqn2mml.get_mathml_from_latex(eqn))) res = await client.put(f"{SKEMA_RS_ADDESS}/mathml/met", json=eqns) if res.status_code != 200: @@ -296,14 +294,12 @@ async def equations_to_gamr(data: schema.EquationToMET, client: httpx.AsyncClien print(r.json()) ``` """ - if "" in data.equations[0]: - eqns: List[str] = [ - utils.clean_mml(mml) for mml in data.equations - ] - else: - eqns: List[str] = [ - utils.clean_mml(eqn2mml.get_mathml_from_latex(tex)) for tex in data.equations - ] + eqns: List[str] = [] + for eqn in data.equations: + if "" in eqn: + eqns.append(utils.clean_mml(eqn)) + else: + eqns.append(utils.clean_mml(eqn2mml.get_mathml_from_latex(eqn))) res = await client.put(f"{SKEMA_RS_ADDESS}/mathml/g-amr", json=eqns) if res.status_code != 200: