Example #1
0
def test_index_memberships(client, web2py):
    """
        Are current memberships on the index page?
    """
    setup_profile_tests(web2py)

    url = '/profile/index'
    client.get(url)
    assert client.status == 200

    populate_customers_with_memberships(web2py)

    cm = web2py.db.customers_memberships(1)
    cm.auth_customer_id = 300
    cm.Enddate = None
    cm.update_record()

    web2py.db.commit()

    client.get(url)
    assert client.status == 200

    sm = web2py.db.school_memberships(1)
    assert sm.Name in client.text
    assert str(cm.Startdate) in client.text
def test_automation_customers_memberships_renew_expired(client, web2py):
    """
        Can we create subscription invoices for a month?
    """
    from populate_os_tables import populate_customers_with_memberships
    import datetime

    # from openstudio/os_customer_membership import CustomerMembership
    # Get random url to initialize OpenStudio environment
    url = '/default/user/login'
    client.get(url)
    assert client.status == 200

    populate_customers_with_subscriptions(web2py, 1)
    populate_customers_with_memberships(web2py, customers_populated=True)

    memberships_count = web2py.db(web2py.db.customers_memberships).count()

    url = '/test_automation_customer_memberships/' + \
          'test_memberships_renew_expired' + \
          '?month=1&year=2014'
    client.get(url)
    assert client.status == 200

    # Get membership
    previous_membership = web2py.db.customers_memberships(1)
    new_id = memberships_count + 1
    new_membership = web2py.db.customers_memberships(new_id)

    # Check membership
    assert new_membership.Startdate == previous_membership.Enddate + datetime.timedelta(
        days=1)
    assert new_membership.Note == 'Renewal for membership 1'

    # Check invoice
    invcm = web2py.db.invoices_customers_memberships(
        customers_memberships_id=new_id)
    invoice = web2py.db.invoices(invcm.invoices_id)

    assert invoice.Status == 'sent'

    query = (web2py.db.invoices_items.invoices_id == invoice.id)
    rows = web2py.db(query).select(web2py.db.invoices_items.ALL)
    for row in rows:
        assert "Membership" in row.ProductName
        assert unicode(new_membership.Startdate) in row.Description
        assert unicode(new_membership.Enddate) in row.Description
def test_invoice_dont_show_duplicate_button_membership(client, web2py):
    """
    Does the Button not show when it is a membership?
    """
    url = '/default/user/login'
    client.get(url)
    assert client.status == 200
    populate_customers_with_memberships(web2py, invoices=True)

    # url = '/customers/invoices?cuID=1001'
    # client.get(url)
    # assert client.status == 200

    url = '/invoices/edit?iID=1'
    client.get(url)
    assert client.status == 200

    assert 'Duplicate' not in client.text
Example #4
0
def test_memberships(client, web2py):
    """
        Is the list of memberships showing? 
    """
    url = '/profile/memberships'
    client.get(url)
    assert client.status == 200

    setup_profile_tests(web2py)

    populate_customers_with_memberships(web2py)

    cm = web2py.db.customers_memberships(1)
    cm.auth_customer_id = 300
    cm.update_record()

    web2py.db.commit()

    client.get(url)
    assert client.status == 200

    sm = web2py.db.school_memberships(1)
    assert sm.Name in client.text
    assert str(cm.Startdate) in client.text