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
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