• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python factories.get_address函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中shuup.testing.factories.get_address函数的典型用法代码示例。如果您正苦于以下问题:Python get_address函数的具体用法?Python get_address怎么用?Python get_address使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了get_address函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: test_addressbook_has_addresses

def test_addressbook_has_addresses(regular_user):
    client, contact = initialize_test(regular_user)
    address = get_address()
    address.save()
    billing_name = address.name
    contact.default_billing_address = address
    contact.save()
    addressbook_url = reverse("shuup:address_book")
    soup = client.soup(addressbook_url)

    assert len(soup(text="Name:")) == 1
    elems = [p for p in soup.find_all("p") if p.text == "Name: %s" % billing_name]
    assert len(elems) == 1

    address = get_address(**{"name": "Kek Bur"})
    address.save()
    shipping_name = address.name
    contact.default_shipping_address = address
    contact.save()

    soup = client.soup(addressbook_url)

    elems = [p for p in soup.find_all("p") if p.text == "Name: %s" % billing_name]
    assert len(elems) == 1

    assert len(soup(text="Name:")) == 2
    elems = [p for p in soup.find_all("p") if p.text == "Name: %s" % shipping_name]
    assert len(elems) == 1
开发者ID:ruqaiya,项目名称:shuup,代码行数:28,代码来源:test_addressbook.py


示例2: test_methods_impossible

def test_methods_impossible(admin_user):
    contact = get_person_contact(admin_user)
    source = BasketishOrderSource(get_default_shop())

    default_product = get_default_product()
    default_product.width = 5000
    default_product.depth = 4000
    default_product.heith = 1300
    default_product.save()

    source.add_line(
        type=OrderLineType.PRODUCT,
        product=default_product,
        supplier=get_default_supplier(),
        quantity=1,
        base_unit_price=source.create_price(10),
        weight=Decimal("200"))
    billing_address = get_address()
    shipping_address = get_address(name="My House", country='BR')

    shipping_address.postal_code = "89070210"

    source.billing_address = billing_address
    source.shipping_address = shipping_address
    source.customer = contact

    source.shipping_method = get_correios_carrier_1()
    source.payment_method = get_payment_method(name="neat", price=4)
    assert source.shipping_method_id
    assert source.payment_method_id

    errors = list(source.get_validation_errors())
    assert len(errors) == 1
开发者ID:rockho-team,项目名称:shuup-correios,代码行数:33,代码来源:test_methods.py


示例3: create_simple_order

def create_simple_order(request, creator, customer):
    billing_address = get_address().to_immutable()
    shipping_address = get_address(name="Shippy Doge").to_immutable()
    shipping_address.save()
    shop = request.shop
    order = Order(
        creator=creator,
        customer=customer,
        shop=shop,
        payment_method=get_default_payment_method(),
        shipping_method=get_default_shipping_method(),
        billing_address=billing_address,
        shipping_address=shipping_address,
        order_date=now(),
        status=get_initial_order_status(),
        currency=shop.currency,
        prices_include_tax=shop.prices_include_tax,
    )
    order.full_clean()
    order.save()

    order.cache_prices()
    order.check_all_verified()
    order.save()
    return order
开发者ID:ruqaiya,项目名称:shuup,代码行数:25,代码来源:test_basic_order.py


示例4: _seed_source

def _seed_source(shop, user):
    source = BasketishOrderSource(shop)
    billing_address = get_address()
    shipping_address = get_address(name="Test street")
    source.status = get_initial_order_status()
    source.billing_address = billing_address
    source.shipping_address = shipping_address
    source.customer = get_person_contact(user)
    return source
开发者ID:gurch101,项目名称:shuup,代码行数:9,代码来源:test_order_total_behavior_component.py


示例5: seed_source

def seed_source(user):
    source = BasketishOrderSource(get_default_shop())
    billing_address = get_address()
    shipping_address = get_address(name="Shippy Doge")
    source.status = get_initial_order_status()
    source.billing_address = billing_address
    source.shipping_address = shipping_address
    source.customer = get_person_contact(user)
    source.payment_method = get_default_payment_method()
    source.shipping_method = get_default_shipping_method()
    assert source.payment_method_id == get_default_payment_method().id
    assert source.shipping_method_id == get_default_shipping_method().id
    return source
开发者ID:suutari,项目名称:shoop,代码行数:13,代码来源:test_order_creator.py


示例6: test_correios_delivery_time_2

def test_correios_delivery_time_2(rf, admin_user):
    with patch.object(CorreiosWS, 'get_preco_prazo', return_value=MOCKED_SUCCESS_RESULT):
        pac_carrier = get_correios_carrier_2()
        contact = get_person_contact(admin_user)
        p1 = create_product(sku='p1',
                            supplier=get_default_supplier(),
                            width=400,
                            depth=400,
                            height=400,
                            gross_weight=1250)

        # P2 é pesado pacas - é empacotado em uma caixa separada
        # só para dar problema na metade da entrega
        p2 = create_product(sku='p2',
                            supplier=get_default_supplier(),
                            width=400,
                            depth=400,
                            height=400,
                            gross_weight=31250)

        source = seed_source(admin_user)
        source.add_line(
            type=OrderLineType.PRODUCT,
            product=p1,
            supplier=get_default_supplier(),
            quantity=2,
            base_unit_price=source.create_price(10))

        source.add_line(
            type=OrderLineType.PRODUCT,
            product=p2,
            supplier=get_default_supplier(),
            quantity=1,
            base_unit_price=source.create_price(20))

        billing_address = get_address()
        shipping_address = get_address(name="My House", country='BR')
        shipping_address.postal_code = "89070210"
        source.billing_address = billing_address
        source.shipping_address = shipping_address
        source.customer = contact

        shipping = ShippingMethod.objects.filter(carrier=pac_carrier).first()

        bc = shipping.behavior_components.first()
        packages = bc._pack_source(source)
        assert len(packages) == 3

        results = bc._get_correios_results(source, packages)
        assert len(results) == 3
开发者ID:rockho-team,项目名称:shuup-correios,代码行数:50,代码来源:test_methods.py


示例7: get_source

def get_source(admin_user, service):
    contact = get_person_contact(admin_user)
    source = BasketishOrderSource(get_default_shop())

    billing_address = get_address()
    shipping_address = get_address(name="My House", country='BR')

    source.billing_address = billing_address
    source.shipping_address = shipping_address
    source.customer = contact

    source.shipping_method = service.carrier
    source.payment_method = get_payment_method(name="neat", price=4)

    return source
开发者ID:rockho-team,项目名称:shuup-shipping-table,代码行数:15,代码来源:test_models.py


示例8: test_methods

def test_methods(admin_user, country):
    contact = get_person_contact(admin_user)
    source = BasketishOrderSource(get_default_shop())
    source.add_line(
        type=OrderLineType.PRODUCT,
        product=get_default_product(),
        supplier=get_default_supplier(),
        quantity=1,
        base_unit_price=source.create_price(10),
        weight=Decimal("0.2")
    )
    billing_address = get_address()
    shipping_address = get_address(name="Shippy Doge", country=country)
    source.billing_address = billing_address
    source.shipping_address = shipping_address
    source.customer = contact

    source.shipping_method = get_expensive_sweden_shipping_method()
    source.payment_method = get_payment_method(name="neat", price=4)
    assert source.shipping_method_id
    assert source.payment_method_id

    errors = list(source.get_validation_errors())

    if country == "FI":
        # "Expenseefe-a Svedee Sheepping" will not allow shipping to
        # Finland, let's see if that holds true
        assert any([ve.code == "we_no_speak_finnish" for ve in errors])
        assert [x.code for x in errors] == ["we_no_speak_finnish"]
        return  # Shouldn't try the rest if we got an error here
    else:
        assert not errors

    final_lines = list(source.get_final_lines())

    assert any(line.type == OrderLineType.SHIPPING for line in final_lines)

    for line in final_lines:
        if line.type == OrderLineType.SHIPPING:
            if country == "SE":  # We _are_ using Expenseefe-a Svedee Sheepping after all.
                assert line.price == source.create_price("5.00")
            else:
                assert line.price == source.create_price("4.00")
            assert line.text == u"Expenseefe-a Svedee Sheepping"
        if line.type == OrderLineType.PAYMENT:
            assert line.price == source.create_price(4)
开发者ID:ahmadzai,项目名称:shuup,代码行数:46,代码来源:test_methods.py


示例9: test_new_mutable_address

def test_new_mutable_address():
    address = get_address()
    new_mutable = address.to_mutable()

    # New address should be unsaved
    assert new_mutable.pk == None
    assert isinstance(new_mutable, MutableAddress)
    assert get_data_dict(address).items() == get_data_dict(new_mutable).items()
开发者ID:NamiStudio,项目名称:shuup,代码行数:8,代码来源:test_addresses.py


示例10: test_set_shipping_address

def test_set_shipping_address(admin_user):
    shop = factories.get_default_shop()
    basket = factories.get_basket()
    factories.get_default_payment_method()
    factories.get_default_shipping_method()
    client = _get_client(admin_user)
    addr1 = factories.get_address()
    addr1.save()

    # use existing address
    payload = {
        'id': addr1.id
    }
    response = client.post('/api/shuup/basket/{}-{}/set_shipping_address/'.format(shop.pk, basket.key), payload)
    assert response.status_code == status.HTTP_200_OK
    response_data = json.loads(response.content.decode("utf-8"))
    shipping_addr = response_data["shipping_address"]
    assert shipping_addr["id"] == addr1.id
    assert shipping_addr["prefix"] == addr1.prefix
    assert shipping_addr["name"] == addr1.name
    assert shipping_addr["postal_code"] == addr1.postal_code
    assert shipping_addr["street"] == addr1.street
    assert shipping_addr["city"] == addr1.city
    assert shipping_addr["country"] == addr1.country

    # create a new address
    address_data = {
        'name': 'name',
        'prefix': 'prefix',
        'postal_code': 'postal_code',
        'street': 'street',
        'city': 'city',
        'country': 'BR'
    }
    response = client.post('/api/shuup/basket/{}-{}/set_shipping_address/'.format(shop.pk, basket.key), address_data)
    assert response.status_code == status.HTTP_200_OK
    response_data = json.loads(response.content.decode("utf-8"))
    shipping_addr = response_data["shipping_address"]
    assert shipping_addr["id"] == addr1.id+1
    assert shipping_addr["prefix"] == address_data["prefix"]
    assert shipping_addr["name"] == address_data["name"]
    assert shipping_addr["postal_code"] == address_data["postal_code"]
    assert shipping_addr["street"] == address_data["street"]
    assert shipping_addr["city"] == address_data["city"]
    assert shipping_addr["country"] == address_data["country"]

    # get the basket and check the address
    response = client.get('/api/shuup/basket/{}-{}/'.format(shop.pk, basket.key))
    assert response.status_code == status.HTTP_200_OK
    response_data = json.loads(response.content.decode("utf-8"))
    shipping_addr = response_data["shipping_address"]
    assert shipping_addr["id"] == addr1.id+1
    assert shipping_addr["prefix"] == address_data["prefix"]
    assert shipping_addr["name"] == address_data["name"]
    assert shipping_addr["postal_code"] == address_data["postal_code"]
    assert shipping_addr["street"] == address_data["street"]
    assert shipping_addr["city"] == address_data["city"]
    assert shipping_addr["country"] == address_data["country"]
开发者ID:suutari-ai,项目名称:shuup,代码行数:58,代码来源:test_basket_api.py


示例11: seed_source

def seed_source(shipping_method=None, produce_price=10):
    source = BasketishOrderSource(get_default_shop())
    billing_address = get_address()
    shipping_address = get_address(name="Shippy Doge")
    source.status = get_initial_order_status()
    source.billing_address = billing_address
    source.shipping_address = shipping_address
    source.customer = create_random_person()
    source.payment_method = get_default_payment_method()
    source.shipping_method = shipping_method if shipping_method else get_default_shipping_method()
    source.add_line(
        type=OrderLineType.PRODUCT,
        product=get_default_product(),
        supplier=get_default_supplier(),
        quantity=1,
        base_unit_price=source.create_price(produce_price),
    )
    return source
开发者ID:ruqaiya,项目名称:shuup,代码行数:18,代码来源:test_default_reports.py


示例12: test_methods_possible

def test_methods_possible(admin_user):
    with patch.object(CorreiosWS, 'get_preco_prazo', return_value=MOCKED_SUCCESS_RESULT):

        contact = get_person_contact(admin_user)
        source = BasketishOrderSource(get_default_shop())

        default_product = get_default_product()
        default_product.width = 500
        default_product.depth = 400
        default_product.heith = 130
        default_product.save()

        source.add_line(
            type=OrderLineType.PRODUCT,
            product=default_product,
            supplier=get_default_supplier(),
            quantity=1,
            base_unit_price=source.create_price(10),
            weight=Decimal("0.2"))
        billing_address = get_address()
        shipping_address = get_address(name="My House", country='BR')
        shipping_address.postal_code = "89070210"

        source.billing_address = billing_address
        source.shipping_address = shipping_address
        source.customer = contact

        source.shipping_method = get_correios_carrier_1()
        source.payment_method = get_payment_method(name="neat", price=4)
        assert source.shipping_method_id
        assert source.payment_method_id

        errors = list(source.get_validation_errors())
        # no errors
        assert len(errors) == 0

        final_lines = list(source.get_final_lines())

        assert any(line.type == OrderLineType.SHIPPING for line in final_lines)

        for line in final_lines:
            if line.type == OrderLineType.SHIPPING:
                assert line.text == "Correios - PAC #1"
开发者ID:rockho-team,项目名称:shuup-correios,代码行数:43,代码来源:test_methods.py


示例13: test_correios_delivery_time_1

def test_correios_delivery_time_1(rf, admin_user):

    with patch.object(CorreiosWS, 'get_preco_prazo', return_value=MOCKED_SUCCESS_RESULT):
        pac_carrier = get_correios_carrier_2()
        contact = get_person_contact(admin_user)
        p1 = create_product(sku='p1',
                            supplier=get_default_supplier(),
                            width=400,
                            depth=400,
                            height=400,
                            gross_weight=1250)

        source = seed_source(admin_user)
        source.add_line(
            type=OrderLineType.PRODUCT,
            product=p1,
            supplier=get_default_supplier(),
            quantity=1,
            base_unit_price=source.create_price(10))
        billing_address = get_address()
        shipping_address = get_address(name="My House", country='BR')
        shipping_address.postal_code = "89070210"
        source.billing_address = billing_address
        source.shipping_address = shipping_address
        source.customer = contact

        bc = ShippingMethod.objects.filter(carrier=pac_carrier).first().behavior_components.first()
        packages = bc._pack_source(source)
        assert len(packages) == 1

        results = bc._get_correios_results(source, packages)
        assert len(results) == 1
        assert results[0].erro == 0
        assert results[0].valor > Decimal(0)

        delivery_time = bc.get_delivery_time(ShippingMethod.objects.filter(carrier=pac_carrier).first(), source)
        assert delivery_time is not None
        assert delivery_time.max_duration == delivery_time.min_duration
        assert delivery_time.max_duration.days == results[0].prazo_entrega + bc.additional_delivery_time

        costs = list(bc.get_costs(ShippingMethod.objects.filter(carrier=pac_carrier).first(), source))
        assert len(costs) == 1
        assert source.create_price(results[0].valor + bc.additional_price) == costs[0].price
开发者ID:rockho-team,项目名称:shuup-correios,代码行数:43,代码来源:test_methods.py


示例14: seed_source

def seed_source(user, extra_addr=True):
    source = BasketishOrderSource(get_default_shop())
    billing_address = get_address()
    shipping_address = get_address(name="Shippy Doge")

    if extra_addr:
        billing_address.extra = ExtraMutableAddress.from_data(EXTRA_MUTABLE_ADDRESS_1)
    if extra_addr:
        shipping_address.extra = ExtraMutableAddress.from_data(EXTRA_MUTABLE_ADDRESS_2)

    source.status = get_initial_order_status()
    source.billing_address = billing_address
    source.shipping_address = shipping_address
    source.customer = get_person_contact(user)
    source.payment_method = get_default_payment_method()
    source.shipping_method = get_default_shipping_method()
    assert source.payment_method_id == get_default_payment_method().id
    assert source.shipping_method_id == get_default_shipping_method().id
    return source
开发者ID:rockho-team,项目名称:shuup-br,代码行数:19,代码来源:test_order_creator.py


示例15: delete_address

def delete_address(regular_user):
    client, contact = initialize_test(regular_user)
    address = get_address()
    address.save()

    sa = SavedAddress.objects.create(owner=contact, address=address)
    delete_url = reverse("shuup:address_book_delete", kwargs={"pk":sa.pk})
    response, soup = client.response_and_soup(delete_url)
    assert response.status_code == 302
    assert "Cannot remove address" not in soup

    user = User.objects.create_user('john', '[email protected]', 'doepassword')
    contact2 = get_person_contact(user)
    address2 = get_address()
    address2.save()

    sa2 = SavedAddress.objects.create(owner=contact2, address=address2)
    response, soup = client.response_and_soup(delete_url)
    assert response.status_code == 302
    assert "Cannot remove address" in soup
开发者ID:ruqaiya,项目名称:shuup,代码行数:20,代码来源:test_addressbook.py


示例16: test_order_address_immutability_unsaved_address

def test_order_address_immutability_unsaved_address(save):
    billing_address = get_address()
    if save:
        billing_address.save()
    order = Order(
        shop=get_default_shop(),
        billing_address=billing_address.to_immutable(),
        order_date=now(),
        status=get_initial_order_status()
    )
    order.save()
    order.billing_address.name = "Mute Doge"
    with pytest.raises(ValidationError):
        order.billing_address.save()
开发者ID:ruqaiya,项目名称:shuup,代码行数:14,代码来源:test_orders.py


示例17: test_address_ownership

def test_address_ownership(admin_user):
    address = get_address()
    address.save()
    saved = SavedAddress(address=address)
    saved.owner = get_person_contact(admin_user)
    assert saved.get_title(), u"get_title does what it should even if there is no explicit title"
    saved.title = u"My favorite address"
    assert saved.get_title() == saved.title, u"get_title does what it should when there is an explicit title"
    assert six.text_type(saved) == saved.get_title(), u"str() is an alias for .get_title()"
    saved.full_clean()
    saved.save()
    assert SavedAddress.objects.for_owner(get_person_contact(admin_user)).filter(address=address).exists(), \
        "contacts can save addresses"
    assert SavedAddress.objects.for_owner(None).count() == 0, "Ownerless saved addresses aren't a real thing"
开发者ID:NamiStudio,项目名称:shuup,代码行数:14,代码来源:test_addresses.py


示例18: test_immutable_address

def test_immutable_address():
    address = get_address()
    new_immutable = address.to_immutable()

    # New address should be saved
    assert new_immutable.pk != None
    assert isinstance(new_immutable, ImmutableAddress)
    assert get_data_dict(address).items() == get_data_dict(new_immutable).items()

    # Taking immutable for same address should return same object
    assert new_immutable == address.to_immutable()

    # Taking immutable from new_immutable should return same item
    assert new_immutable == new_immutable.to_immutable()
开发者ID:NamiStudio,项目名称:shuup,代码行数:14,代码来源:test_addresses.py


示例19: test_basic_address

def test_basic_address():
    address = get_address()
    address.full_clean()
    string_repr = str(address)
    for field, value in get_data_dict(address).items():
        if field == "country":  # We can't test this right now, it's formatted in the repr
            continue
        if not value:
            continue
        assert value in string_repr, "Field %s is not represented in %r" % (field, string_repr)

    assert address.is_european_union, "Dog Fort, UK is in the EU"
    assert list(address.split_name) == ["Dog", "Hello"], "Names split correctly"
    assert address.first_name == "Dog", "Names split correctly"
    assert address.last_name == "Hello", "Names split correctly"
    assert address.full_name == "Sir Dog Hello , Esq.", "Names join correctly"
开发者ID:NamiStudio,项目名称:shuup,代码行数:16,代码来源:test_addresses.py


示例20: test_addressbook_has_saved_addresses

def test_addressbook_has_saved_addresses(regular_user):
    client, contact = initialize_test(regular_user)
    address = get_address()
    address.save()
    address_title = "TestAddress"
    sa = SavedAddress.objects.create(owner=contact, address=address, title=address_title)
    addressbook_url = reverse("shuup:address_book")

    soup = client.soup(addressbook_url)
    elems = [h for h in soup.find_all("h2") if h.text.strip() == address_title]
    assert len(elems) == 1
    assert len(soup(text="Name:")) == 1

    second_address_title = "TestAddress2"
    sa = SavedAddress.objects.create(owner=contact, address=address, title=second_address_title)
    soup = client.soup(addressbook_url)
    elems = [h for h in soup.find_all("h2") if h.text.strip() == second_address_title]
    assert len(elems) == 1
    assert len(soup(text="Name:")) == 2
开发者ID:ruqaiya,项目名称:shuup,代码行数:19,代码来源:test_addressbook.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python factories.get_default_category函数代码示例发布时间:2022-05-27
下一篇:
Python factories.create_random_person函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap