From be8dc21c5a8de429ed6f9a4bce0e2cf600223a8c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BE=9D=E7=91=AA=E8=B2=93?= Date: Tue, 7 Feb 2023 00:38:41 +0800 Subject: [PATCH] Revised the code in the test_l10n test of the CurrencyTestCase test case. --- tests/test_currency.py | 38 +++++++++++++++++--------------------- 1 file changed, 17 insertions(+), 21 deletions(-) diff --git a/tests/test_currency.py b/tests/test_currency.py index f0b5a7e..c8abce2 100644 --- a/tests/test_currency.py +++ b/tests/test_currency.py @@ -469,6 +469,8 @@ class CurrencyTestCase(unittest.TestCase): from accounting.models import Currency from test_site import db zza_code, zza_name = "ZZA", "Testing Dollar #A" + detail_uri: str = f"/accounting/currencies/{zza_code}" + update_uri: str = f"/accounting/currencies/{zza_code}/update" with self.app.app_context(): zza: Currency = db.session.get(Currency, zza_code) @@ -477,14 +479,12 @@ class CurrencyTestCase(unittest.TestCase): set_locale(self, self.client, self.csrf_token, "zh_Hant") - response = self.client.post( - f"/accounting/currencies/{zza_code}/update", - data={"csrf_token": self.csrf_token, - "code": zza_code, - "name": f"{zza_name}-zh_Hant"}) + response = self.client.post(update_uri, + data={"csrf_token": self.csrf_token, + "code": zza_code, + "name": f"{zza_name}-zh_Hant"}) self.assertEqual(response.status_code, 302) - self.assertEqual(response.headers["Location"], - f"/accounting/currencies/{zza_code}") + self.assertEqual(response.headers["Location"], detail_uri) with self.app.app_context(): zza: Currency = db.session.get(Currency, zza_code) @@ -494,14 +494,12 @@ class CurrencyTestCase(unittest.TestCase): set_locale(self, self.client, self.csrf_token, "en") - response = self.client.post( - f"/accounting/currencies/{zza_code}/update", - data={"csrf_token": self.csrf_token, - "code": zza_code, - "name": f"{zza_name}-2"}) + response = self.client.post(update_uri, + data={"csrf_token": self.csrf_token, + "code": zza_code, + "name": f"{zza_name}-2"}) self.assertEqual(response.status_code, 302) - self.assertEqual(response.headers["Location"], - f"/accounting/currencies/{zza_code}") + self.assertEqual(response.headers["Location"], detail_uri) with self.app.app_context(): zza: Currency = db.session.get(Currency, zza_code) @@ -511,14 +509,12 @@ class CurrencyTestCase(unittest.TestCase): set_locale(self, self.client, self.csrf_token, "zh_Hant") - response = self.client.post( - f"/accounting/currencies/{zza_code}/update", - data={"csrf_token": self.csrf_token, - "code": zza_code, - "name": f"{zza_name}-zh_Hant-2"}) + response = self.client.post(update_uri, + data={"csrf_token": self.csrf_token, + "code": zza_code, + "name": f"{zza_name}-zh_Hant-2"}) self.assertEqual(response.status_code, 302) - self.assertEqual(response.headers["Location"], - f"/accounting/currencies/{zza_code}") + self.assertEqual(response.headers["Location"], detail_uri) with self.app.app_context(): zza: Currency = db.session.get(Currency, zza_code)