aboutsummaryrefslogtreecommitdiff
path: root/wqflask
diff options
context:
space:
mode:
authorBonfaceKilz2020-09-17 18:05:54 +0300
committerBonfaceKilz2020-09-17 18:05:54 +0300
commit0fd23995fa21c32c2a6005b2fd70b0bd99d13214 (patch)
tree5b286c7e801c2a7eb62c7d9e0d93a5d70bb390e6 /wqflask
parent8da6a70916d2cf18e476ab0adf47f802c481205d (diff)
downloadgenenetwork2-0fd23995fa21c32c2a6005b2fd70b0bd99d13214.tar.gz
Mock "SECRET_HMAC_CODE"
* wqflask/tests/utility/test_hmac.py: Mock app.config's "SECRET_HMAC_CODE" value.
Diffstat (limited to 'wqflask')
-rw-r--r--wqflask/tests/utility/test_hmac.py12
1 files 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")