def test_product_customer_update_info(client, web2py): """ Test as JSON Is the attendance info ajaj backend working? """ populate_workshops_with_activity(web2py) populate_customers(web2py, 1) web2py.db.workshops_products_customers.insert(workshops_products_id=1, auth_customer_id=1001) web2py.db.commit() url = '/events/ticket_customer_update_info.json' data = dict(id='1', WorkshopInfo='on') client.post(url, data=data) assert client.status == 200 assert 'success' in client.text assert web2py.db.workshops_products_customers(1).WorkshopInfo == True # unset info and payment confirmation. url = '/events/ticket_customer_update_info.json' data = dict(id='1') client.post(url, data=data) assert client.status == 200 assert 'success' in client.text assert web2py.db.workshops_products_customers(1).WorkshopInfo == False
def test_ticket_duplicate(client, web2py): """ Can we duplicate a event ticket? """ populate_workshops_with_activity(web2py) url = '/events/ticket_duplicate?wspID=1' client.get(url) assert client.status == 200 wsp_1 = web2py.db.workshops_products(1) wsp_2 = web2py.db.workshops_products(2) assert wsp_1.workshops_id == wsp_2.workshops_id assert wsp_2.FullWorkshop == False assert wsp_2.Deletable == True assert wsp_2.PublicProduct == False assert wsp_1.Name in wsp_2.Name assert wsp_1.Price == wsp_2.Price assert wsp_1.tax_rates_id == wsp_2.tax_rates_id assert wsp_1.Description == wsp_2.Description assert wsp_1.ExternalShopURL == wsp_2.ExternalShopURL assert wsp_1.AddToCartText == wsp_2.AddToCartText assert wsp_1.Donation == wsp_2.Donation assert wsp_1.accounting_glaccounts_id == wsp_2.accounting_glaccounts_id assert wsp_1.accounting_costcenters_id == wsp_2.accounting_costcenters_id # Check some activities have been added for workshop product assert web2py.db(web2py.db.workshops_products_activities. workshops_products_id == 2).count() > 0
def test_activity_edit(client, web2py): """ Can we edit an activity? """ populate_workshops_with_activity(web2py) url = '/events/activity_edit/1' client.get(url) assert client.status == 200 data = dict(id='1', Activity="Cherries", Activitydate='2999-01-01', Starttime='09:00:00', Endtime='11:12:00', Spaces='20', Price='250') client.post(url, data=data) assert client.status == 200 # verify redirection back to workshop main page assert 'Activities' in client.text # is the activity showing in the list? assert data['Activity'] in client.text # check the db assert web2py.db(web2py.db.workshops_activities).count() > 0 # Check updating of dates & times in workshop workshop = web2py.db.workshops(1) assert str(workshop.Enddate) == data['Activitydate'] assert str(workshop.Endtime) == data['Endtime']
def test_ticket_sell_to_customer_create_invoice_and_cancel_orders_when_sold_out(client, web2py): """ Test if we can sell a ticket to a customer and if an invoice is created """ populate_workshops_with_activity(web2py) populate_customers(web2py, 1) populate_customers_orders(web2py) populate_customers_orders_items(web2py, workshops_products=True) url = '/events/ticket_sell_to_customer?cuID=1001&wsID=1&wspID=1' client.get(url) assert client.status == 200 assert web2py.db(web2py.db.workshops_products_customers).count() == 1 assert web2py.db(web2py.db.invoices).count() == 1 invoice = web2py.db.invoices(1) assert invoice.invoices_groups_id == 100 ii_wsp = web2py.db.invoices_items_workshops_products_customers(1) assert ii_wsp.workshops_products_customers_id == 1 # check invoice amount price = web2py.db.workshops_products(1).Price amounts = web2py.db.invoices_amounts(1) assert amounts.TotalPriceVAT == price # check if all orders get cancelled assert web2py.db(web2py.db.customers_orders.Status == 'cancelled').count() > 0 # Check that a mail is sent (or at least it tried) assert web2py.db(web2py.db.messages).count() == 1 assert web2py.db(web2py.db.customers_messages).count() == 1
def test_ticket_delete_full_wsp_error(client, web2py): """ Test whether we get an error when trying to delete a full ws ticket """ populate_workshops_with_activity(web2py) url = '/events/ticket_delete?wsID=1&wspID=1' client.get(url) assert client.status == 200 assert web2py.db(web2py.db.workshops_products).count > 0
def test_ticket_sell_to_customer_waitinglist(client, web2py): """ Test if we can sell a ticket to a customer """ populate_workshops_with_activity(web2py) populate_customers(web2py, 1) url = '/events/ticket_sell_to_customer?cuID=1001&wsID=1&wspID=1&waiting=True' client.get(url) assert client.status == 200 assert web2py.db.workshops_products_customers(1).Waitinglist == True
def test_activity_duplicate(client, web2py): """ Is the duplication working? """ populate_workshops_with_activity(web2py) url = '/events/activity_duplicate/1' client.get(url) assert client.status == 200 assert 'duplicated' in client.text # is the flash message showing assert web2py.db(web2py.db.workshops_activities).count() == 2 assert web2py.db.workshops_activities(1).Activity + u' (Copy)' == web2py.db.workshops_activities(2).Activity
def test_ticket_delete(client, web2py): """ Test if we can delete a regular ticket """ populate_workshops_with_activity(web2py) populate(web2py.db.workshops_products, 1) url = '/events/ticket_delete?wsID=1&wspID=2' client.get(url) assert client.status == 200 # we inserted an extra product, so now there should only be one assert web2py.db(web2py.db.workshops_products).count() == 1
def test_ticket_activities_add(client, web2py): """ Test if we can add activities to a ticket """ populate_workshops_with_activity(web2py) url = '/events/ticket_activities?wsID=1&wspID=1' client.get(url) assert client.status == 200 data = {'1': 'on'} client.post(url, data=data) assert client.status == 200 assert web2py.db(web2py.db.workshops_products_activities).count() == 1
def test_ticket_list_customers_fullWS(client, web2py): """ Test listing of full workshop customers for a ticket """ populate_workshops_with_activity(web2py) populate_customers(web2py, 1) web2py.db.workshops_products_customers.insert(workshops_products_id=1, auth_customer_id=1001) web2py.db.commit() url = '/events/tickets_list_customers?wsID=1&wspID=1' client.get(url) assert client.status == 200 assert 'Full event' in client.text
def test_ticket_activities_remove(client, web2py): """ Test if we can remove activities from a ticket """ populate_workshops_with_activity(web2py) web2py.db.workshops_products_activities.insert(workshops_products_id=1, workshops_activities_id=1) web2py.db.commit() url = '/events/ticket_activities?wsID=1&wspID=1' client.get(url) assert client.status == 200 data = {'1': None} client.post(url, data=data) assert client.status == 200 assert web2py.db(web2py.db.workshops_products_activities).count() == 0
def test_ticket_remove_customer_from_waitinglist(client, web2py): """ Test if we can remove a customer from the waitinglist and add them to the regular list """ populate_workshops_with_activity(web2py) populate_customers(web2py, 1) web2py.db.workshops_products_customers.insert(workshops_products_id=1, auth_customer_id=1001, Waitinglist=True) web2py.db.commit() url = '/events/ticket_remove_customer_from_waitinglist?wsID=1&wsp_cuID=1' client.get(url) assert client.status == 200 # check there are no products customers left with waitinglist = True in db query = (web2py.db.workshops_products_customers.Waitinglist == True) assert web2py.db(query).count() == 0
def test_product_add(client, web2py): """ Test if we can add a new product """ populate_workshops_with_activity(web2py) url = '/events/ticket_add/1' client.get(url) assert client.status == 200 data = dict(Name='Bananas', Price='300', tax_rates_id=1, Description='Great with almonds when frozen and blended') client.post(url, data=data) assert client.status == 200 # Verify redirection to ticket_activities assert "Activities included" in client.text # make sure something was added to the db assert web2py.db(web2py.db.workshops_products).count > 1
def test_ticket_edit(client, web2py): """ Test if we can edit a ticket """ populate_workshops_with_activity(web2py) url = '/events/ticket_edit?wspID=1' client.get(url) assert client.status == 200 data = dict(id=1, Name='Bananas', tax_rates_id=1, Price='300', Description='Great with almonds when frozen and blended') client.post(url, data=data) assert client.status == 200 # check if we're at manage assert "Tickets" in client.text assert data['Name'] in client.text # make sure something was added to the db assert web2py.db(web2py.db.workshops_products).count > 1
def test_ticket_sell_to_customer_AutoSendInfoMail_False(client, web2py): """ Test if we can sell a ticket to a customer and if an invoice is created """ populate_workshops_with_activity(web2py) populate_customers(web2py, 1) populate_customers_orders(web2py) populate_customers_orders_items(web2py, workshops_products=True) ws = web2py.db.workshops(1) ws.AutoSendInfoMail = False ws.update_record() web2py.db.commit() url = '/events/ticket_sell_to_customer?cuID=1001&wsID=1&wspID=1' client.get(url) assert client.status == 200 assert web2py.db(web2py.db.workshops_products_customers).count() == 1 # Check that a mail is not sent assert web2py.db(web2py.db.messages).count() == 0 assert web2py.db(web2py.db.customers_messages).count() == 0