当前位置: 首页>>代码示例>>Python>>正文


Python MagicMock.address方法代码示例

本文整理汇总了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
开发者ID:BlackWebWolf,项目名称:saleor,代码行数:34,代码来源:test_checkout.py

示例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')
开发者ID:BillTheBest,项目名称:hyper-c,代码行数:9,代码来源:test_neutron_contexts.py

示例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)
开发者ID:epigos,项目名称:saleor,代码行数:12,代码来源:tests.py

示例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)
开发者ID:rvnovaes,项目名称:saleor,代码行数:12,代码来源:tests.py

示例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
开发者ID:BlackWebWolf,项目名称:saleor,代码行数:14,代码来源:test_checkout.py

示例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)
开发者ID:BlackWebWolf,项目名称:saleor,代码行数:14,代码来源:test_checkout.py

示例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")
开发者ID:rvnovaes,项目名称:saleor,代码行数:14,代码来源:tests.py

示例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)
开发者ID:abnormal,项目名称:saleor,代码行数:14,代码来源:tests.py

示例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)
开发者ID:rvnovaes,项目名称:saleor,代码行数:16,代码来源:tests.py

示例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')
开发者ID:epigos,项目名称:saleor,代码行数:16,代码来源:tests.py

示例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)
开发者ID:abnormal,项目名称:saleor,代码行数:16,代码来源:tests.py

示例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
开发者ID:brdfdr,项目名称:qdb,代码行数:17,代码来源:test_cmd_manager.py

示例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')
开发者ID:abnormal,项目名称:saleor,代码行数:17,代码来源:tests.py

示例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
开发者ID:BlackWebWolf,项目名称:saleor,代码行数:18,代码来源:test_checkout.py

示例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)
开发者ID:epigos,项目名称:saleor,代码行数:20,代码来源:tests.py


注:本文中的mock.MagicMock.address方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。