本文整理汇总了Python中mock.MagicMock.address方法的典型用法代码示例。如果您正苦于以下问题:Python MagicMock.address方法的具体用法?Python MagicMock.address怎么用?Python MagicMock.address使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mock.MagicMock
的用法示例。
在下文中一共展示了MagicMock.address方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_shipping_step_save_with_address_other_than_billing
# 需要导入模块: from mock import MagicMock [as 别名]
# 或者: from mock.MagicMock import address [as 别名]
def test_shipping_step_save_with_address_other_than_billing(rf):
address_data = {
'first_name': 'Billing Company LTD',
'last_name': 'Test',
'street_address_1': 'Test',
'street_address_2': 'Test',
'city': 'Test',
'phone': '12345678',
'postal_code': '987654',
'country': 'PL',
'country_area': '',
'company_name': 'Test'}
data = dict(
address_data,
method='dummy_shipping',
shipping_same_as_billing=False)
request = rf.post('/checkout/', data)
request.user = AnonymousUser()
request.session = {}
group = MagicMock()
group.address = None
storage = {
'address': {
'first_name': 'Billing Address',
'last_name': 'Test',
'id': 10}}
billing_address = Address(**address_data)
step = ShippingStep(request, storage, group, billing_address)
assert step.forms_are_valid()
step.save()
assert storage['address'] == address_data
示例2: test_get_host_ip_hostname_resolvable
# 需要导入模块: from mock import MagicMock [as 别名]
# 或者: from mock.MagicMock import address [as 别名]
def test_get_host_ip_hostname_resolvable(self, _query):
data = MagicMock()
data.address = '10.5.0.1'
_query.return_value = [data]
self.assertEquals(neutron_contexts.get_host_ip('myhost.example.com'),
'10.5.0.1')
_query.assert_called_with('myhost.example.com', 'A')
示例3: test_address_save_with_address_in_group
# 需要导入模块: from mock import MagicMock [as 别名]
# 或者: from mock.MagicMock import address [as 别名]
def test_address_save_with_address_in_group(self, mock_save):
self.request.POST = NEW_ADDRESS_POST
self.request.POST['method'] = 0
group = MagicMock()
group.address = Address()
group.get_delivery_methods.return_value = [DummyShipping(group)]
step = ShippingStep(self.checkout, self.request, group)
self.assertTrue(step.forms_are_valid(), 'Forms don\'t validate.')
step.save()
self.assertEqual(mock_save.call_count, 0)
示例4: test_address_save_with_address_in_group
# 需要导入模块: from mock import MagicMock [as 别名]
# 或者: from mock.MagicMock import address [as 别名]
def test_address_save_with_address_in_group(self, mock_save):
self.request.POST = NEW_ADDRESS.copy()
self.request.POST["method"] = "dummy_shipping"
group = MagicMock()
group.address = Address()
storage = {}
step = ShippingStep(self.request, storage, group)
self.assertTrue(step.forms_are_valid(), "Forms don't validate.")
step.save()
self.assertEqual(mock_save.call_count, 0)
示例5: test_shipping_step_save_with_address_in_group
# 需要导入模块: from mock import MagicMock [as 别名]
# 或者: from mock.MagicMock import address [as 别名]
def test_shipping_step_save_with_address_in_group(rf):
data = dict(NEW_ADDRESS, method='dummy_shipping')
request = rf.post('/checkout/', data)
request.user = AnonymousUser()
request.session = {}
group = MagicMock()
group.address = NEW_ADDRESS.copy()
storage = {'address': NEW_ADDRESS.copy()}
step = ShippingStep(request, storage, group)
assert step.forms_are_valid()
step.save()
assert storage['address'] == NEW_ADDRESS
示例6: test_shipping_step_save_without_address
# 需要导入模块: from mock import MagicMock [as 别名]
# 或者: from mock.MagicMock import address [as 别名]
def test_shipping_step_save_without_address(rf):
data = dict(NEW_ADDRESS, method='dummy_shipping')
request = rf.post('/checkout/', data)
request.user = AnonymousUser()
request.session = {STORAGE_SESSION_KEY: {}}
group = MagicMock()
group.address = None
storage = {'address': NEW_ADDRESS.copy()}
step = ShippingStep(request, storage, group)
assert step.forms_are_valid()
step.save()
assert isinstance(storage['address'], dict)
示例7: test_address_save_without_address
# 需要导入模块: from mock import MagicMock [as 别名]
# 或者: from mock.MagicMock import address [as 别名]
def test_address_save_without_address(self, mock_save):
self.request.POST = NEW_ADDRESS.copy()
self.request.POST["method"] = "dummy_shipping"
self.request.session = {STORAGE_SESSION_KEY: {}}
group = MagicMock()
group.address = None
storage = {}
step = ShippingStep(self.request, storage, group)
self.assertTrue(step.forms_are_valid(), "Forms don't validate.")
step.save()
self.assertEqual(mock_save.call_count, 0)
self.assertEqual(type(storage["address"]), Address, "Address instance expected")
示例8: test_address_save_with_address_in_group
# 需要导入模块: from mock import MagicMock [as 别名]
# 或者: from mock.MagicMock import address [as 别名]
def test_address_save_with_address_in_group(self, mock_save):
request = MagicMock()
request.user.is_authenticated.return_value = False
request.session = {}
request.POST = dict(NEW_ADDRESS, method='dummy_shipping')
group = MagicMock()
group.address = NEW_ADDRESS
storage = {'address': NEW_ADDRESS}
step = ShippingStep(request, storage, group)
self.assertTrue(step.forms_are_valid(), "Forms don't validate.")
step.save()
self.assertEqual(mock_save.call_count, 0)
示例9: test_address_save_with_address_in_checkout
# 需要导入模块: from mock import MagicMock [as 别名]
# 或者: from mock.MagicMock import address [as 别名]
def test_address_save_with_address_in_checkout(self, mock_save):
self.request.POST = NEW_ADDRESS.copy()
self.request.POST["method"] = "dummy_shipping"
original_billing_address_data = {"first_name": "Change", "last_name": "Me", "id": 10}
original_billing_address = Address(**original_billing_address_data)
group = MagicMock()
group.address = None
storage = {"address": original_billing_address}
step = ShippingStep(self.request, storage, group)
self.assertTrue(step.forms_are_valid(), "Forms don't validate.")
step.save()
self.assertEqual(mock_save.call_count, 0)
self.assertEqual(storage["address"], Address(**NEW_ADDRESS))
self.assertEqual(storage["address"].id, None)
示例10: test_address_save_without_address
# 需要导入模块: from mock import MagicMock [as 别名]
# 或者: from mock.MagicMock import address [as 别名]
def test_address_save_without_address(self, mock_save):
self.request.POST = NEW_ADDRESS_POST
self.request.POST['method'] = 0
group = MagicMock()
group.address = None
checkout = Checkout(self.request)
group.get_delivery_methods.return_value = [DummyShipping(group)]
step = ShippingStep(checkout, self.request, group)
self.assertTrue(step.forms_are_valid(), 'Forms don\'t validate.')
step.save()
self.assertEqual(mock_save.call_count, 0)
grup_storage = checkout.get_group(str(step))
self.assertEqual(type(grup_storage['address']), Address,
'Address instance expected')
示例11: test_address_save_with_address_in_checkout
# 需要导入模块: from mock import MagicMock [as 别名]
# 或者: from mock.MagicMock import address [as 别名]
def test_address_save_with_address_in_checkout(self, mock_save):
request = MagicMock()
request.user.is_authenticated.return_value = False
request.session = {}
request.POST = dict(NEW_ADDRESS, method='dummy_shipping')
original_billing_address = {'name': 'Change Me', 'id': 10}
group = MagicMock()
group.address = None
storage = {'address': original_billing_address}
step = ShippingStep(request, storage, group)
self.assertTrue(step.forms_are_valid(), "Forms don't validate.")
step.save()
self.assertEqual(mock_save.call_count, 0)
self.assertEqual(storage['address'], NEW_ADDRESS)
示例12: MockTracer
# 需要导入模块: from mock import MagicMock [as 别名]
# 或者: from mock.MagicMock import address [as 别名]
def MockTracer(self):
"""
Construct a mock tracer.
"""
tracer = MagicMock()
tracer.address = self.tracer_host, self.tracer_port
tracer.pause_signal = signal.SIGUSR2
tracer.retry_attepts = 1
tracer.local = 0, 0
tracer.uuid = 'mock'
tracer.watchlist = {}
tracer.curframe = sys._getframe()
tracer.stack = [(sys._getframe(), 1)] * 3
tracer.skip_fn = lambda _: False
return tracer
示例13: test_address_save_without_address
# 需要导入模块: from mock import MagicMock [as 别名]
# 或者: from mock.MagicMock import address [as 别名]
def test_address_save_without_address(self, mock_save):
request = MagicMock()
request.user.is_authenticated.return_value = False
request.session = {}
request.POST = dict(NEW_ADDRESS, method='dummy_shipping')
request.session = {STORAGE_SESSION_KEY: {}}
group = MagicMock()
group.address = None
storage = {'address': NEW_ADDRESS}
step = ShippingStep(request, storage, group)
self.assertTrue(step.forms_are_valid(), "Forms don't validate.")
step.save()
self.assertEqual(mock_save.call_count, 0)
self.assertTrue(isinstance(storage['address'], dict),
'dict expected')
示例14: test_shipping_step_save_with_address_in_checkout
# 需要导入模块: from mock import MagicMock [as 别名]
# 或者: from mock.MagicMock import address [as 别名]
def test_shipping_step_save_with_address_in_checkout(rf):
data = dict(NEW_ADDRESS, method='dummy_shipping')
request = rf.post('/checkout/', data)
request.user = AnonymousUser()
request.session = {}
group = MagicMock()
group.address = None
storage = {
'address': {
'first_name': 'Change',
'last_name': 'Me',
'id': 10}}
step = ShippingStep(request, storage, group)
assert step.forms_are_valid()
step.save()
assert storage['address'] == NEW_ADDRESS
示例15: test_address_save_with_address_in_checkout
# 需要导入模块: from mock import MagicMock [as 别名]
# 或者: from mock.MagicMock import address [as 别名]
def test_address_save_with_address_in_checkout(self, mock_save):
self.request.POST = NEW_ADDRESS_POST
self.request.POST['method'] = 0
original_billing_address_data = {'first_name': 'Change',
'last_name': 'Me',
'id': 10}
original_billing_address = Address(**original_billing_address_data)
self.checkout.billing_address = original_billing_address
group = MagicMock()
group.address = None
group.get_delivery_methods.return_value = [DummyShipping(group)]
step = ShippingStep(self.checkout, self.request, group)
self.assertTrue(step.forms_are_valid(), 'Forms don\'t validate.')
step.save()
self.assertEqual(mock_save.call_count, 0)
self.assertEqual(self.checkout.billing_address,
Address(**original_billing_address_data))
self.assertEqual(step.group['address'].id, None)