예제 #1
0
def test_get_or_create_anonymous_checkout_from_token(anonymous_checkout, user_checkout):
    queryset = Checkout.objects.all()
    checkouts = list(queryset)
    checkout = utils.get_or_create_anonymous_checkout_from_token(anonymous_checkout.token)
    assert Checkout.objects.all().count() == 2
    assert checkout == anonymous_checkout

    # test against new token
    checkout = utils.get_or_create_anonymous_checkout_from_token(uuid4())
    assert Checkout.objects.all().count() == 3
    assert checkout not in checkouts
    assert checkout.user is None
    checkout.delete()

    # test against getting checkout assigned to user
    checkout = utils.get_or_create_anonymous_checkout_from_token(user_checkout.token)
    assert Checkout.objects.all().count() == 3
    assert checkout not in checkouts
    assert checkout.user is None
예제 #2
0
파일: test_cart.py 프로젝트: mirumee/saleor
def test_get_or_create_anonymous_checkout_from_token(anonymous_checkout, user_checkout):
    queryset = Checkout.objects.all()
    checkouts = list(queryset)
    checkout = utils.get_or_create_anonymous_checkout_from_token(
        anonymous_checkout.token
    )
    assert Checkout.objects.all().count() == 2
    assert checkout == anonymous_checkout

    # test against new token
    checkout = utils.get_or_create_anonymous_checkout_from_token(uuid4())
    assert Checkout.objects.all().count() == 3
    assert checkout not in checkouts
    assert checkout.user is None
    checkout.delete()

    # test against getting checkout assigned to user
    checkout = utils.get_or_create_anonymous_checkout_from_token(user_checkout.token)
    assert Checkout.objects.all().count() == 3
    assert checkout not in checkouts
    assert checkout.user is None