本文整理汇总了Python中unittest.mock.MagicMock.GET方法的典型用法代码示例。如果您正苦于以下问题:Python MagicMock.GET方法的具体用法?Python MagicMock.GET怎么用?Python MagicMock.GET使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类unittest.mock.MagicMock
的用法示例。
在下文中一共展示了MagicMock.GET方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_process_data_redirects_to_success_on_payment_success
# 需要导入模块: from unittest.mock import MagicMock [as 别名]
# 或者: from unittest.mock.MagicMock import GET [as 别名]
def test_process_data_redirects_to_success_on_payment_success(self):
self.payment.status = 'preauth'
provider = DummyProvider(self.payment)
request = MagicMock()
request.GET = {}
response = provider.process_data(request)
self.assertEqual(response['location'], self.payment.get_success_url())
示例2: test_process_data_redirects_to_failure_on_payment_failure
# 需要导入模块: from unittest.mock import MagicMock [as 别名]
# 或者: from unittest.mock.MagicMock import GET [as 别名]
def test_process_data_redirects_to_failure_on_payment_failure(self):
self.payment.status = 'reject'
provider = WireProvider()
request = MagicMock()
request.GET = {}
response = provider.process_data(self.payment, request)
self.assertEqual(response['location'], self.payment.get_failure_url())
示例3: test_validate_shopify_hmac_returns_true_with_valid_hmac
# 需要导入模块: from unittest.mock import MagicMock [as 别名]
# 或者: from unittest.mock.MagicMock import GET [as 别名]
def test_validate_shopify_hmac_returns_true_with_valid_hmac(self):
"""Ensure that it matches a test/reference hmac we prepare."""
ref_hmac = get_ref_hmac()
request = MagicMock()
request.GET = dict(hmac=ref_hmac, foo='bar', biz='baz')
self.assertEqual(True, models.validate_shopify_hmac(request))
示例4: test_process_data_supports_verification_result
# 需要导入模块: from unittest.mock import MagicMock [as 别名]
# 或者: from unittest.mock.MagicMock import GET [as 别名]
def test_process_data_supports_verification_result(self):
provider = WireProvider()
verification_status = 'confirmed'
request = MagicMock()
request.GET = {'verification_result': verification_status}
response = provider.process_data(self.payment, request)
self.assertEqual(self.payment.status, verification_status)
self.assertEqual(response.status_code, 302)
self.assertEqual(response['location'], self.payment.get_success_url())
示例5: test_app_auth_calls_shopify_with_valid_get_params
# 需要导入模块: from unittest.mock import MagicMock [as 别名]
# 或者: from unittest.mock.MagicMock import GET [as 别名]
def test_app_auth_calls_shopify_with_valid_get_params(self, MockShopifyShop):
ref_hmac = get_ref_hmac()
request = MagicMock()
request.GET = dict(hmac=ref_hmac, biz='baz', foo='bar')
views.app_auth(request)
self.assertEqual(MockShopifyShop.send_auth_request.called, True)
示例6: test_create_method_noops_with_invalid_response
# 需要导入模块: from unittest.mock import MagicMock [as 别名]
# 或者: from unittest.mock.MagicMock import GET [as 别名]
def test_create_method_noops_with_invalid_response(self):
request = MagicMock()
request.GET = dict(shop='testshop')
test_resp = MagicMock()
test_resp.json.return_value = {}
ShopifyShop.create(test_resp, request)
self.assertEqual(ShopifyShop.objects.count(), 0)
示例7: test_otp_verify_never_cache
# 需要导入模块: from unittest.mock import MagicMock [as 别名]
# 或者: from unittest.mock.MagicMock import GET [as 别名]
def test_otp_verify_never_cache(self, m_otp_verify):
# never_cache requires valid HttpResponse
m_otp_verify.return_value = HttpResponse()
request = MagicMock()
request.GET = {}
request.POST = {}
admin_site = admin.AdminSite()
response = admin_site.otp_verify(request)
self.assertIn('Cache-Control', response)
示例8: test_otp_verify_redirect_field_in_post
# 需要导入模块: from unittest.mock import MagicMock [as 别名]
# 或者: from unittest.mock.MagicMock import GET [as 别名]
def test_otp_verify_redirect_field_in_post(self, m_otp_verify):
# never_cache requires valid HttpResponse
m_otp_verify.return_value = HttpResponse()
request = MagicMock()
request.GET = {}
request.POST = {REDIRECT_FIELD_NAME: '/'}
admin_site = admin.AdminSite()
admin_site.otp_verify(request)
args, kwargs = m_otp_verify.call_args
self.assertNotIn(REDIRECT_FIELD_NAME, kwargs['extra_context'])
示例9: test_create_method_creates_record_with_valid_response
# 需要导入模块: from unittest.mock import MagicMock [as 别名]
# 或者: from unittest.mock.MagicMock import GET [as 别名]
def test_create_method_creates_record_with_valid_response(self):
request = MagicMock()
request.GET = dict(shop='testshop')
test_resp = MagicMock()
test_resp.json.return_value = {
'access_token': '123faketoken',
'scope': 'read_scope, write_scope'
}
test_resp.status_code = 200
ShopifyShop.create(test_resp, request)
self.assertEqual(ShopifyShop.objects.count(), 1)
示例10: test_otp_verify
# 需要导入模块: from unittest.mock import MagicMock [as 别名]
# 或者: from unittest.mock.MagicMock import GET [as 别名]
def test_otp_verify(self, m_otp_verify):
# never_cache requires valid HttpResponse
m_otp_verify.return_value = HttpResponse()
request = MagicMock()
request.GET = {}
request.POST = {}
admin_site = admin.AdminSite()
admin_site.otp_verify(request)
args, kwargs = m_otp_verify.call_args
self.assertIn('site_title', kwargs['extra_context'])
self.assertIn('site_header', kwargs['extra_context'])
self.assertIn('site_url', kwargs['extra_context'])
self.assertIn('has_permission', kwargs['extra_context'])
self.assertIn('title', kwargs['extra_context'])
self.assertIn('app_path', kwargs['extra_context'])
self.assertIn(REDIRECT_FIELD_NAME, kwargs['extra_context'])
self.assertIn('current_app', kwargs)
self.assertEqual(kwargs['template_name'], 'admin/otp.html')
示例11: test_validate_shopify_hmac_returns_false_without_hmac_key
# 需要导入模块: from unittest.mock import MagicMock [as 别名]
# 或者: from unittest.mock.MagicMock import GET [as 别名]
def test_validate_shopify_hmac_returns_false_without_hmac_key(self):
request = MagicMock()
request.GET = {}
self.assertEqual(False, models.validate_shopify_hmac(request))
示例12: make_mock_request_for_year
# 需要导入模块: from unittest.mock import MagicMock [as 别名]
# 或者: from unittest.mock.MagicMock import GET [as 别名]
def make_mock_request_for_year(self, year):
fake_req = MagicMock()
fake_req.GET = QueryDict("year={}".format(year), mutable=True)
return fake_req