From 0fd23995fa21c32c2a6005b2fd70b0bd99d13214 Mon Sep 17 00:00:00 2001 From: BonfaceKilz Date: Thu, 17 Sep 2020 18:05:54 +0300 Subject: Mock "SECRET_HMAC_CODE" * wqflask/tests/utility/test_hmac.py: Mock app.config's "SECRET_HMAC_CODE" value. --- wqflask/tests/utility/test_hmac.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/wqflask/tests/utility/test_hmac.py b/wqflask/tests/utility/test_hmac.py index c7927685..16b50771 100644 --- a/wqflask/tests/utility/test_hmac.py +++ b/wqflask/tests/utility/test_hmac.py @@ -12,24 +12,28 @@ from utility.hmac import hmac_creation class TestHmacUtil(unittest.TestCase): """Test Utility method for hmac creation""" + @mock.patch("utility.hmac.app.config", {'SECRET_HMAC_CODE': "secret"}) def test_hmac_creation(self): """Test hmac creation with a utf-8 string""" - self.assertEqual(hmac_creation("ファイ"), "21fa1d935bbbb07a7875") + self.assertEqual(hmac_creation("ファイ"), "7410466338cfe109e946") + @mock.patch("utility.hmac.app.config", {'SECRET_HMAC_CODE': "secret"}) def test_data_hmac(self): """Test data_hmac fn with a utf-8 string""" - self.assertEqual(data_hmac("ファイ"), "ファイ:21fa1d935bbbb07a7875") + self.assertEqual(data_hmac("ファイ"), "ファイ:7410466338cfe109e946") + @mock.patch("utility.hmac.app.config", {'SECRET_HMAC_CODE': "secret"}) @mock.patch("utility.hmac.url_for") def test_url_for_hmac_with_plain_url(self, mock_url): """Test url_for_hmac without params""" mock_url.return_value = "https://mock_url.com/ファイ/" self.assertEqual(url_for_hmac("ファイ"), - "https://mock_url.com/ファイ/?hm=a62896a50d9ffcff7deb") + "https://mock_url.com/ファイ/?hm=05bc39e659b1948f41e7") + @mock.patch("utility.hmac.app.config", {'SECRET_HMAC_CODE': "secret"}) @mock.patch("utility.hmac.url_for") def test_url_for_hmac_with_param_in_url(self, mock_url): """Test url_for_hmac with params""" mock_url.return_value = "https://mock_url.com/?ファイ=1" self.assertEqual(url_for_hmac("ファイ"), - "https://mock_url.com/?ファイ=1&hm=b2128fb28bc32da3b5b7") + "https://mock_url.com/?ファイ=1&hm=4709c1708270644aed79") -- cgit v1.2.3