def test_events_tickets_customers_delete(client, web2py): """ Is the delete permission for a workshop product customer working? """ url = '/default/user/login' client.get(url) assert client.status == 200 setup_permission_tests(web2py) populate_workshops_products_customers(web2py) web2py.auth.add_permission(200, 'read', 'workshops_products_customers', 0) web2py.db.commit() url = '/events/tickets_list_customers?wsID=1&wspID=2' client.get(url) assert client.status == 200 assert not 'ticket_delete_customer' in client.text # grant permission and check again web2py.auth.add_permission(200, 'delete', 'workshops_products_customers', 0) web2py.db.commit() client.get(url) assert client.status == 200 assert 'ticket_delete_customer' in client.text
def test_events(client, web2py): """ Is the list of workshops showing? """ setup_profile_tests(web2py) url = '/default/user/login' client.get(url) assert client.status == 200 populate_workshops_products_customers(web2py) wspc = web2py.db.workshops_products_customers(1) wspc.auth_customer_id = 300 wspc.update_record() web2py.db.commit() url = '/profile/events' client.get(url) assert client.status == 200 # check name of workshop on page wsp = web2py.db.workshops_products(wspc.workshops_products_id) ws = web2py.db.workshops(wsp.workshops_id) assert wsp.Name in client.text assert ws.Name in client.text assert str(ws.Startdate) in client.text
def test_events_activities_delete(client, web2py): """ Is the delete permission for a workshop activity working? """ url = '/default/user/login' client.get(url) assert client.status == 200 setup_permission_tests(web2py) populate_workshops_products_customers(web2py) web2py.auth.add_permission(200, 'read', 'workshops_activities', 0) web2py.db.commit() url = '/events/activities?wsID=1' client.get(url) assert client.status == 200 assert not 'fa-times' in client.text # grant permission and check again web2py.auth.add_permission(200, 'delete', 'workshops_activities', 0) web2py.db.commit() client.get(url) assert client.status == 200 assert 'fa-times' in client.text
def test_activity_update_attendance(client, web2py): """ Test if a record is inserted into workshops_activities_customers """ ## # Get random url to setup session environment in OpenStudio ## url = '/default/user/login' client.get(url) assert client.status == 200 populate_workshops_products_customers(web2py) # add url = '/events/activity_update_attendance.json' data = {'attending': 'on', 'cuID': 1001, 'wsaID': 1} client.post(url, data=data) assert client.status == 200 assert web2py.db(web2py.db.workshops_activities_customers).count() == 1 # remove url = '/events/activity_update_attendance.json' data = {'cuID': 1001, 'wsaID': 1} client.post(url, data=data) assert client.status == 200 assert web2py.db(web2py.db.workshops_activities_customers).count() == 0
def test_ticket_delete_customer(client, web2py): """ Can we delete a customer from a ticket and is the invoice cancelled? """ ## # Get random url to setup session environment in OpenStudio ## url = '/default/user/login' client.get(url) assert client.status == 200 populate_workshops_products_customers(web2py) query = (web2py.db.workshops_products_customers.id > 0) count_before = web2py.db(query).count() url = '/events/ticket_delete_customer?wsID=1&wsp_cuID=2' client.get(url) assert client.status == 200 count_after = web2py.db(query).count() assert count_before == count_after + 1 ## # Check that the invoice status has been set to cancelled ## query = (web2py.db.invoices.Status == 'cancelled') assert web2py.db(query).count() == 1
def test_pdf_show_template(client, web2py): """ Test pdf export for events """ ## # Get random url to setup session environment in OpenStudio ## url = '/default/user/login' client.get(url) assert client.status == 200 populate_workshops_products_customers( web2py) # this function adds an activity & product wsID = 1 url = '/events/pdf_template_show?wsID=' + unicode(wsID) client.get(url) assert client.status == 200 ws = web2py.db.workshops(wsID) assert ws.Name in client.text assert ws.Description in client.text activity = web2py.db.workshops_activities(1) assert unicode(activity.Activitydate) in unicode(client.text, 'utf-8') assert activity.Starttime.strftime('%H:%M') in client.text product = web2py.db.workshops_products(1) assert unicode(product.Price) in unicode(client.text, "utf-8")
def test_invoice_dont_show_duplicate_button_workshop(client, web2py): """ Does the Button not show when it is a workshop order? """ url = '/default/user/login' client.get(url) assert client.status == 200 populate_workshops_products_customers(web2py, 3) url = '/invoices/edit?iID=1' client.get(url) assert client.status == 200 assert 'Duplicate' not in client.text
def test_customers_inactive_dont_list_with_workshop_product(client, web2py): """ Customers attending an event (workshop) on or after given date """ from populate_os_tables import populate_workshops_products_customers url = '/reports/customers_inactive' client.get(url) assert client.status == 200 populate_workshops_products_customers(web2py, created_on=datetime.date(2012, 1, 1)) data = {'date': datetime.date(2014, 1, 1)} client.post(url, data=data) assert client.status == 200 assert web2py.db.auth_user(1001).first_name not in client.text
def test_wh_get_customer_info(client, web2py): ''' Tests the get_cutomer_info function from the WorkshopHelper class This function is used in workshops/products_get_customer so the output of that function is checked ''' url = '/default/user/login' client.get(url) assert client.status == 200 populate_workshops_products_customers(web2py) url = '/events/tickets_list_customers?wsID=1&wspID=1' client.get(url) assert client.status == 200 # check if the labels for the checkboxes are present assert 'no_table_WorkshopInfo' in client.text
def test_ticket_resend_info_mail(client, web2py): """ Is the function to (re)send an info mail working? """ ## # Get random url to setup session environment in OpenStudio ## url = '/default/user/login' client.get(url) assert client.status == 200 populate_workshops_products_customers(web2py) # this function adds an activity & product url = '/events/ticket_resend_info_mail?wspcID=1' client.get(url) assert client.status == 200 query = (web2py.db.messages.id > 0) assert web2py.db(query).count() == 1
def test_tickets_list_customers(client, web2py): """ Test listing of customers for a ticket Also check if the right label is displayed (should have ticket name) """ ## # Get random url to setup session environment in OpenStudio ## url = '/default/user/login' client.get(url) assert client.status == 200 populate_workshops_products_customers(web2py) url = '/events/tickets_list_customers?wsID=1&wspID=2' client.get(url) assert client.status == 200 product = web2py.db.workshops_products(2) assert product.Name.split(' ')[0] in client.text
def test_stats_top10cities(client, web2py): """ Make sure the cities of 2 customers are listed """ ## # Get random url to setup session environment in OpenStudio ## url = '/default/user/login' client.get(url) assert client.status == 200 populate_workshops_products_customers(web2py) url = '/events/stats?wsID=1' client.get(url) assert client.status == 200 city_cu1 = web2py.db.auth_user(id=1001).city.split(' ')[0] city_cu2 = web2py.db.auth_user(id=1002).city.split(' ')[0] assert city_cu1 in client.text assert city_cu2 in client.text
def test_activity_list_customers(client, web2py): """ Test wether a full workshop customer and a customer for another ticket show up in the list of an activity with the correct label """ ## # Get random url to setup session environment in OpenStudio ## url = '/default/user/login' client.get(url) assert client.status == 200 populate_workshops_products_customers(web2py) url = '/events/activity_list_customers?wsID=1&wsaID=1' client.get(url) assert client.status == 200 # Full workshop label (label-primary) assert '<span class="label label-primary">' in client.text # ticket label (default) assert '<span class="label label-default">' in client.text
def test_stats_revenue(client, web2py): """ Check if the total count for the revenue stats is correct """ ## # Get random url to setup session environment in OpenStudio ## url = '/default/user/login' client.get(url) assert client.status == 200 populate_workshops_products_customers(web2py) url = '/events/stats?wsID=1' client.get(url) assert client.status == 200 sum = web2py.db.invoices_amounts.TotalPriceVAT.sum() rows = web2py.db().select(sum) amount = rows.first()[sum] total = format(amount, '.2f') assert total in client.text
def test_ticket_cancel_customer(client, web2py): """ Test if a customer can be cancelled """ ## # Get random url to setup session environment in OpenStudio ## url = '/default/user/login' client.get(url) assert client.status == 200 populate_workshops_products_customers(web2py) url = '/events/ticket_cancel_customer?wsID=1&wsp_cuID=1' client.get(url) assert client.status == 200 query = (web2py.db.workshops_products_customers.Cancelled == True) assert web2py.db(query).count() == 1 # Check cancelled invoice query = (web2py.db.invoices.Status == 'cancelled') assert web2py.db(query).count() == 1