Esempio n. 1
0
def test_create_customer_invalid_origin_system():
    """
    GIVEN create a stripe customer
    WHEN An invalid origin system is provided
    THEN An exception should be raised
    """
    origin_system = "NOT_VALID"
    with pytest.raises(InvalidRequestError) as request_error:
        create_customer(
            g.subhub_account,
            user_id="test_mozilla",
            source_token="tok_visa",
            email="*****@*****.**",
            origin_system=origin_system,
            display_name="John Tester",
        )
    msg = f"origin_system={origin_system} not one of allowed origin system values, please contact a system administrator in the #subscription-platform channel."
    assert msg == str(request_error.value)
Esempio n. 2
0
def test_create_customer_invalid_origin_system():
    """
    GIVEN create a stripe customer
    WHEN An invalid origin system is provided
    THEN An exception should be raised
    """
    origin_system = "NOT_VALID"
    with pytest.raises(InvalidRequestError) as request_error:
        create_customer(
            g.subhub_account,
            user_id="test_mozilla",
            source_token="tok_visa",
            email="*****@*****.**",
            origin_system=origin_system,
            display_name="John Tester",
        )
    msg = f"origin_system={origin_system} not one of {CFG.ALLOWED_ORIGIN_SYSTEMS}"
    assert msg == str(request_error.value)
Esempio n. 3
0
def create_customer_for_processing():
    uid = uuid.uuid4()
    customer = create_customer(
        g.subhub_account,
        user_id="process_customer",
        source_token="tok_visa",
        email="test_fixture@{}tester.com".format(uid.hex),
        origin_system="Test_system",
    )
    yield customer
def test_create_customer_tok_avsUnchecked():
    """
    GIVEN create a stripe customer
    WHEN provided an invalid test token and test userid
    THEN validate the customer metadata is correct
    """
    customer = create_customer(
        g.subhub_account,
        user_id="test_mozilla",
        source_token="tok_avsUnchecked",
        email="*****@*****.**",
        origin_system="Test_system",
    )
    assert customer["metadata"]["userid"] == "test_mozilla"
def test_create_customer_tok_invalid():
    """
    GIVEN create a stripe customer
    WHEN provided an invalid test token and test userid
    THEN validate the customer metadata is correct
    """
    with pytest.raises(stripe.error.InvalidRequestError):
        customer = create_customer(
            g.subhub_account,
            user_id="test_mozilla",
            source_token="tok_invalid",
            email="*****@*****.**",
            origin_system="Test_system",
        )
Esempio n. 6
0
def test_create_customer_tok_mastercard():
    """
    GIVEN create a stripe customer
    WHEN provided a test mastercard token and test userid
    THEN validate the customer metadata is correct
    """
    customer = create_customer(
        g.subhub_account,
        user_id="test_mozilla",
        source_token="tok_mastercard",
        email="*****@*****.**",
        origin_system="Test_system",
        display_name="John Tester",
    )
    assert customer["metadata"]["userid"] == "test_mozilla"
def test_create_customer_tok_visa():
    """
    GIVEN create a stripe customer
    WHEN provided a test visa token and test fxa
    THEN validate the customer metadata is correct
    """
    customer = create_customer(
        g.subhub_account,
        user_id="test_mozilla",
        source_token="tok_visa",
        email="*****@*****.**",
        origin_system="Test_system",
    )
    pytest.customer = customer
    assert customer["metadata"]["userid"] == "test_mozilla"