def test_activity_add(client, web2py): """ Can we add a activity to a event? """ populate_workshops(web2py, teachers=True) url = '/events/activity_add/1' client.get(url) assert client.status == 200 assert 'name="Activity"' in client.text # is the event teacher predefined workshop = web2py.db.workshops(1) teacher = web2py.db.auth_user(workshop.auth_teacher_id) teacher2 = web2py.db.auth_user(workshop.auth_teacher_id2) assert teacher.first_name.split(' ')[0] in client.text assert teacher2.first_name.split(' ')[0] in client.text data = dict(Activity="Cherries", Activitydate='2999-01-01', school_locations_id=1, Starttime='09:00:00', Endtime='23:00:00', Spaces='20') client.post(url, data=data) assert client.status == 200 assert 'Event' in client.text # verify redirection back to workshop main page assert data['Activity'] in client.text # is the activity showing in the list? assert web2py.db(web2py.db.workshops_activities).count() == 1 # 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_get_subtitle(client, web2py): """ Are the start and enddate in the subtitle? """ populate_workshops(web2py) url = '/events/activities?wsID=1' client.get(url) assert client.status == 200 workshop = web2py.db.workshops(1) sd = workshop.Startdate ed = workshop.Enddate date = unicode(sd) + ' - ' + unicode(ed) assert date in client.text
def test_event_archive(client, web2py): """ Is the archive function working? """ populate_workshops(web2py) url = '/events/event_archive?wsID=1' # Archive client.get(url) assert client.status == 200 assert 'Events' in client.text # verify redirection assert web2py.db.workshops(1).Archived == True # Unarchive (move to current) client.get(url) assert client.status == 200 assert 'Events' in client.text # verify redirection assert not web2py.db.workshops(1).Archived
def test_event_edit(client, web2py): """ Can we edit a event? """ populate_workshops(web2py) url = '/events/event_edit?wsID=1' client.get(url) assert client.status == 200 data = dict(id=1, Name="Mysore_week", Startdate='2014-01-01', Enddate='2014-12-31', Price='250') client.post(url, data=data) assert client.status == 200 assert 'Events' in client.text # verify redirection assert data['Name'] in client.text assert web2py.db(web2py.db.workshops).count() > 0
def test_events_delete(client, web2py): """ Is the delete permission for a workshop working? """ setup_permission_tests(web2py) populate_workshops(web2py) web2py.auth.add_permission(200, 'read', 'workshops', 0) web2py.db.commit() url = '/events/index' 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', 0) web2py.db.commit() client.get(url) assert client.status == 200 assert 'fa-times' in client.text