예제 #1
0
def test_membership_buy_now(client, web2py):
    """
    Is the membership buy now function working?
    """
    # Get random url to init env
    url = '/default/user/login'
    client.get(url)
    assert client.status == 200


    setup_profile_tests(web2py)
    populate_school_memberships(web2py)

    web2py.db.sys_properties.insert(
        Property='mollie_website_profile',
        PropertyValue=mollie_key # Mollie test key
    )

    web2py.db.commit()

    url = '/mollie/membership_buy_now?smID=1'
    client.get(url)
    assert client.status == 200

    cm = web2py.db.customers_memberships(1)
    assert cm.auth_customer_id == 300
    assert cm.Startdate == datetime.date.today()
    assert cm.school_memberships_id == 1
    assert cm.DateID == datetime.date.today().strftime('%Y%m%d') + '00001'
    assert not cm.Barcode == None
def test_membership_price_edit(client, web2py):
    """
        Can we edit a memberships price?
    """
    populate_school_memberships(web2py)

    assert web2py.db(web2py.db.school_memberships).count() == 1
    assert web2py.db(web2py.db.school_memberships_price).count() == 1

    url = '/school_properties/membership_price_edit?smID=1&smpID=1'
    client.get(url)
    assert client.status == 200
    assert 'Edit membership price' in client.text

    data = dict(id           = 1,
                Startdate    = '2014-01-01',
                Price        = 12345,
                tax_rates_id = 1)
    client.post(url, data=data)
    assert client.status == 200
    assert 'Edit membership' in client.text # verify redirection

    assert format(data['Price'], '.2f') in client.text

    assert web2py.db(web2py.db.school_memberships_price).count() == 1
def test_memberships(client, web2py):
    """
        Is the index page showing?
        Is the current price showing?
    """
    populate_school_memberships(web2py)

    url = '/school_properties/memberships'
    client.get(url)
    assert client.status == 200
    assert 'Memberships' in client.text

    sm = web2py.db.school_memberships(1)

    assert sm.Name in client.text
    assert format(sm.Price, '.2f') in client.text