示例#1
0
def test_multiple_coupons_work_properly(admin_user, settings):
    configure(settings)
    shop = factories.get_default_shop()
    basket = factories.get_basket()
    shop_product = factories.get_default_shop_product()
    client = _get_client(admin_user)

    code_one = "DACODE"
    code_two = "DACODE1"
    coupon = Coupon.objects.create(code=code_one, active=True)
    get_default_campaign(coupon)

    payload = {
        'code': code_one
    }
    response = client.post('/api/shuup/basket/{}-{}/add_code/'.format(shop.pk, basket.key), payload)
    basket_data = json.loads(response.content.decode("utf-8"))
    assert response.status_code == status.HTTP_200_OK
    assert code_one in basket_data['codes']

    coupon1 = Coupon.objects.create(code=code_two, active=True)
    get_default_campaign(coupon1)
    payload = {
        'code': code_two
    }
    response = client.post('/api/shuup/basket/{}-{}/add_code/'.format(shop.pk, basket.key), payload)
    basket_data = json.loads(response.content.decode("utf-8"))
    assert response.status_code == status.HTTP_200_OK
    assert code_two in basket_data['codes']
    assert len(basket_data["codes"]) == 1
示例#2
0
def test_multiple_coupons_work_properly(admin_user, settings):
    configure(settings)
    shop = factories.get_default_shop()
    basket = factories.get_basket()
    shop_product = factories.get_default_shop_product()
    client = _get_client(admin_user)

    code_one = "DACODE"
    code_two = "DACODE1"
    coupon = Coupon.objects.create(code=code_one, active=True)
    get_default_campaign(coupon)

    payload = {'code': code_one}
    response = client.post(
        '/api/shuup/basket/{}-{}/add_code/'.format(shop.pk, basket.key),
        payload)
    basket_data = json.loads(response.content.decode("utf-8"))
    assert response.status_code == status.HTTP_200_OK
    assert code_one in basket_data['codes']

    coupon1 = Coupon.objects.create(code=code_two, active=True)
    get_default_campaign(coupon1)
    payload = {'code': code_two}
    response = client.post(
        '/api/shuup/basket/{}-{}/add_code/'.format(shop.pk, basket.key),
        payload)
    basket_data = json.loads(response.content.decode("utf-8"))
    assert response.status_code == status.HTTP_200_OK
    assert code_two in basket_data['codes']
    assert len(basket_data["codes"]) == 1
示例#3
0
def test_can_add_a_valid_campaign_code(admin_user, settings):
    configure(settings)
    shop = factories.get_default_shop()
    basket = factories.get_basket()
    shop_product = factories.get_default_shop_product()
    client = _get_client(admin_user)

    coupon = Coupon.objects.create(code="DACODE", active=True)
    get_default_campaign(coupon)

    payload = {'code': 'DACODE'}
    response = client.post(
        '/api/shuup/basket/{}-{}/add_code/'.format(shop.pk, basket.key),
        payload)
    basket_data = json.loads(response.content.decode("utf-8"))
    assert response.status_code == status.HTTP_200_OK
    assert 'DACODE' in basket_data['codes']
示例#4
0
def test_can_add_a_valid_campaign_code(admin_user, settings):
    configure(settings)
    shop = factories.get_default_shop()
    basket = factories.get_basket()
    shop_product = factories.get_default_shop_product()
    client = _get_client(admin_user)

    coupon = Coupon.objects.create(code="DACODE", active=True)
    get_default_campaign(coupon)

    payload = {
        'code': 'DACODE'
    }
    response = client.post('/api/shuup/basket/{}-{}/add_code/'.format(shop.pk, basket.key), payload)
    basket_data = json.loads(response.content.decode("utf-8"))
    assert response.status_code == status.HTTP_200_OK
    assert 'DACODE' in basket_data['codes']