def test_delete_shift_with_volunteer(self): # register event first to create job event = ['event-name', '2050-08-21', '2050-09-28'] created_event = create_event_with_details(event) # create job job = ['job', '2050-08-21', '2050-08-30', '', created_event] created_job = create_job_with_details(job) # create shift shift = ['2050-08-21', '09:00', '12:00', '10', created_job] created_shift = create_shift_with_details(shift) # create volunteer for shift volunteer = create_volunteer() register_volunteer_for_shift_utility(created_shift, volunteer) self.settings.go_to_events_page() settings = self.settings settings.live_server_url = self.live_server_url settings.navigate_to_shift_list_view() # delete shift self.delete_shift_from_list() # check error message displayed and shift not deleted self.assertEqual( settings.get_template_error_message(), 'You cannot delete a shift that a volunteer has signed up for.')
def test_delete_shift_with_volunteer(self): # register event first to create job event = ['event-name', '2050-08-21', '2050-09-28'] created_event = create_event_with_details(event) # create job job = ['job', '2050-08-21', '2050-08-30', '', created_event] created_job = create_job_with_details(job) # create shift shift = ['2050-08-21', '09:00', '12:00', '10', created_job] created_shift = create_shift_with_details(shift) # create volunteer for shift volunteer = create_volunteer() register_volunteer_for_shift_utility(created_shift, volunteer) self.settings.go_to_events_page() settings = self.settings settings.live_server_url = self.live_server_url settings.navigate_to_shift_list_view() # delete shift self.delete_shift_from_list() # check error message displayed and shift not deleted self.assertEqual(settings.get_template_error_message(), 'You cannot delete a shift that a volunteer has signed up for.')
def test_search_volunteers(self): register_event_utility() register_job_utility() shift = register_shift_utility() register_volunteer_for_shift_utility(shift, self.v1) # if no search parameters are given, # it returns all volunteers search_list = search_volunteers("", "", "", "", "", "", "", "") self.assertNotEqual(search_list, False) self.assertEqual(len(search_list), 3) self.assertIn(self.v1, search_list) self.assertIn(self.v2, search_list) self.assertIn(self.v3, search_list) search_list = search_volunteers(None, None, None, None, None, None, None, None) self.assertNotEqual(search_list, False) self.assertEqual(len(search_list), 3) self.assertIn(self.v1, search_list) self.assertIn(self.v2, search_list) self.assertIn(self.v3, search_list) # test exact search search_list = search_volunteers("Yoshi", "Turtle", "Nintendo Land", "Nintendo State", "Nintendo Nation", "Apple", "event", "job") self.assertNotEqual(search_list, False) self.assertEqual(len(search_list), 1) self.assertIn(self.v1, search_list) self.assertNotIn(self.v2, search_list) self.assertNotIn(self.v3, search_list) # test partial search search_list = search_volunteers("Yoshi", None, None, None, None, None, None, None) self.assertNotEqual(search_list, False) self.assertEqual(len(search_list), 1) self.assertIn(self.v1, search_list) self.assertNotIn(self.v2, search_list) self.assertNotIn(self.v3, search_list) search_list = search_volunteers(None, "Doe", None, None, None, None, None, None) self.assertNotEqual(search_list, False) self.assertEqual(len(search_list), 2) self.assertIn(self.v3, search_list) self.assertIn(self.v2, search_list) # test no search matches search_list = search_volunteers("Billy", "Doe", "Montreal", "Quebec", "Canada", "Ubisoft", "eventq", "jobq") self.assertEqual(len(search_list), 0) self.assertNotIn(self.v1, search_list) self.assertNotIn(self.v2, search_list) self.assertNotIn(self.v3, search_list)
def test_search_volunteers(self): register_event_utility() register_job_utility() shift = register_shift_utility() register_volunteer_for_shift_utility(shift, self.v1) # if no search parameters are given, # it returns all volunteers search_list = search_volunteers("", "", "", "", "", "", "", "") self.assertNotEqual(search_list, False) self.assertEqual(len(search_list), 3) self.assertIn(self.v1, search_list) self.assertIn(self.v2, search_list) self.assertIn(self.v3, search_list) search_list = search_volunteers(None, None, None, None, None, None, None, None) self.assertNotEqual(search_list, False) self.assertEqual(len(search_list), 3) self.assertIn(self.v1, search_list) self.assertIn(self.v2, search_list) self.assertIn(self.v3, search_list) # test exact search search_list = search_volunteers("Yoshi", "Turtle", "Nintendo Land", "Nintendo State", "Nintendo Nation", "Apple", "event", "job") self.assertNotEqual(search_list, False) self.assertEqual(len(search_list), 1) self.assertIn(self.v1, search_list) self.assertNotIn(self.v2, search_list) self.assertNotIn(self.v3, search_list) # test partial search search_list = search_volunteers("Yoshi", None, None, None, None, None, None, None) self.assertNotEqual(search_list, False) self.assertEqual(len(search_list), 1) self.assertIn(self.v1, search_list) self.assertNotIn(self.v2, search_list) self.assertNotIn(self.v3, search_list) search_list = search_volunteers(None, "Doe", None, None, None, None, None, None) self.assertNotEqual(search_list, False) self.assertEqual(len(search_list), 2) self.assertIn(self.v3, search_list) self.assertIn(self.v2, search_list) # test no search matches search_list = search_volunteers("Billy", "Doe", "Montreal", "Quebec", "Canada", "Ubisoft", "eventq", "jobq") self.assertEqual(len(search_list), 0) self.assertNotIn(self.v1, search_list) self.assertNotIn(self.v2, search_list) self.assertNotIn(self.v3, search_list)
def test_delete_shift_with_volunteer(self): """ Test deletion of shift with volunteer linked with it. """ # register event first to create job event = { 'name': 'event-name', 'start_date': '2050-08-21', 'end_date': '2050-09-28', 'address': 'event-address', 'venue': 'event-venue', 'description': 'event-description' } created_event = create_event_with_details(event) # create job job = { 'name': 'job', 'start_date': '2050-08-21', 'end_date': '2050-08-30', 'description': '', 'event': created_event } created_job = create_job_with_details(job) # create shift shift = { 'date': '2050-08-21', 'start_time': '09:00', 'end_time': '12:00', 'max_volunteers': '10', 'job': created_job, 'address': 'shift-address', 'venue': 'shift-venue' } created_shift = create_shift_with_details(shift) # create volunteer for shift volunteer = create_volunteer() register_volunteer_for_shift_utility(created_shift, volunteer) self.settings.go_to_events_page() settings = self.settings settings.live_server_url = self.live_server_url settings.navigate_to_shift_list_view() # delete shift self.delete_shift_from_list() # check error message displayed and shift not deleted self.assertEqual( settings.get_template_error_message(), 'You cannot delete a shift that a volunteer has signed up for.')
def test_past_shifts_donot_appear_in_upcoming_shifts(self): register_past_event_utility() register_past_job_utility() shift = register_past_shift_utility() register_volunteer_for_shift_utility(shift, self.v1) upcoming_shift_page = self.upcoming_shift_page upcoming_shift_page.live_server_url = self.live_server_url upcoming_shift_page.view_upcoming_shifts() self.assertEqual(upcoming_shift_page.get_info_box(), upcoming_shift_page.no_shift_message) self.assertRaisesRegexp(NoSuchElementException, 'Unable to locate element: //table', upcoming_shift_page.get_result_container)
def test_past_shifts_donot_appear_in_upcoming_shifts(self): register_past_event_utility() register_past_job_utility() shift = register_past_shift_utility() register_volunteer_for_shift_utility(shift, self.v1) upcoming_shift_page = self.upcoming_shift_page upcoming_shift_page.live_server_url = self.live_server_url upcoming_shift_page.view_upcoming_shifts() self.assertEqual(upcoming_shift_page.get_info_box(), upcoming_shift_page.no_shift_message) self.assertRaisesRegexp(NoSuchElementException, 'Unable to locate element: //table', upcoming_shift_page.get_result_container)
def create_volunteer_shift(shift, volunteer): """ Utility function to link a shift to a volunteer. :return: VolunteerShift type object """ vol_shift = register_volunteer_for_shift_utility(shift, volunteer) return vol_shift
def test_only_logged_shifts_are_reported(self): # register dataset org = create_organization_with_details('organization-one') volunteer = create_volunteer() volunteer.organization = org volunteer.save() # register event first to create job event = ['Hackathon', '2017-08-21', '2017-09-28'] created_event = create_event_with_details(event) # create job job = ['Developer', '2017-08-21', '2017-08-30', '',created_event] created_job = create_job_with_details(job) # create shift shift = ['2017-08-21', '09:00', '15:00', '10', created_job] created_shift = create_shift_with_details(shift) # shift is assigned to volunteer-one, but hours have not been logged volunteer_shift = register_volunteer_for_shift_utility(created_shift, volunteer) report_page = self.report_page # check admin report with null fields, should not return the above shift report_page.fill_report_form(['','','','','']) self.assertEqual(report_page.get_alert_box_text(),report_page.no_results_message)
def register_unlogged_dataset(self): """ Utility function to register data for testing. """ created_event = create_event_with_details({ 'name': 'event-unlogged', 'start_date': '2015-06-01', 'end_date': '2015-06-10', 'description': 'event-description', 'address': 'event-address', 'venue': 'event-venue' }) created_job = create_job_with_details({ 'name': 'jobUnlogged', 'start_date': '2015-06-01', 'end_date': '2015-06-10', 'description': 'job description', 'event': created_event }) created_shift = create_shift_with_details({ 'date': '2015-06-01', 'start_time': '09:00', 'end_time': '15:00', 'max_volunteers': '10', 'job': created_job, 'address': 'shift-address', 'venue': 'shift-venue' }) registered_shift =\ register_volunteer_for_shift_utility(created_shift, self.v1)
def test_view_with_only_registered_volunteers(self): """ Test display of shift details with registered volunteer. """ shift_details_page = self.shift_details_page shift_details_page.live_server_url = self.live_server_url org_obj = create_organization_with_details(self.org_detail) volunteer = create_volunteer_with_details(self.volunteer_detail, org_obj) volunteer_shift = register_volunteer_for_shift_utility( self.shift, volunteer) self.wait_for_home_page() shift_details_page.navigate_to_shift_details_view() # verify that the shift slot is decreased by 1 self.assertEqual(shift_details_page.get_shift_job(), 'job') self.assertEqual(shift_details_page.get_max_shift_volunteer(), '5') # verify that assigned volunteers shows up but no logged hours yet self.assertEqual(len(shift_details_page.get_registered_volunteers()), 1) self.assertEqual(shift_details_page.get_registered_volunteer_name(), 'Michael') self.assertEqual(shift_details_page.get_registered_volunteer_email(), '*****@*****.**') self.assertEqual(shift_details_page.get_message_box(), 'There are no logged hours at the moment')
def test_only_logged_shifts_are_reported(self): # register dataset org = create_organization_with_details('organization-one') volunteer = create_volunteer() volunteer.organization = org volunteer.save() # register event first to create job event = ['Hackathon', '2017-08-21', '2017-09-28'] created_event = create_event_with_details(event) # create job job = ['Developer', '2017-08-21', '2017-08-30', '', created_event] created_job = create_job_with_details(job) # create shift shift = ['2017-08-21', '09:00', '15:00', '10', created_job] created_shift = create_shift_with_details(shift) # shift is assigned to volunteer-one, but hours have not been logged volunteer_shift = register_volunteer_for_shift_utility( created_shift, volunteer) report_page = self.report_page # check admin report with null fields, should not return the above shift report_page.fill_report_form(['', '', '', '', '']) self.assertEqual(report_page.get_alert_box_text(), report_page.no_results_message)
def test_shift_sign_up_with_no_slots(self): registered_event = register_event_utility() registered_job = register_job_utility() sign_up_page = self.sign_up_page # create shift with no slot shift_2 = [ "2050-05-11", "9:00", "15:00", 1, Job.objects.get(name='job') ] s2 = create_shift_with_details(shift_2) # Create another volunteer volunteer_2 = [ 'volunteer-2', "Sam", "Turtle", "Mario Land", "Nintendo Land", "Nintendo State", "Nintendo Nation", "2374983247", "*****@*****.**" ] org_name = 'volunteer-organization' org_obj = create_organization_with_details(org_name) v2 = create_volunteer_with_details(volunteer_2, org_obj) # Assign shift to the volunteer registered_vol_shift = register_volunteer_for_shift_utility(s2, v2) # open Shift Sign Up sign_up_page.navigate_to_sign_up() # on event page self.assertEqual(sign_up_page.get_info_box().text, sign_up_page.no_event_message)
def register_dataset(self): created_event = create_event_with_details(['event-four', '2017-06-01', '2017-06-10']) created_job = create_job_with_details( ['jobOneInEventFour', '2017-06-01', '2017-06-10', 'job description', created_event] ) created_shift = create_shift_with_details(['2017-06-01', '09:00', '15:00', '10', created_job]) registered_shift = register_volunteer_for_shift_utility(created_shift, self.v1)
def register_dataset(self): created_event = create_event_with_details( ['event-four', '2017-06-01', '2017-06-10']) created_job = create_job_with_details([ 'jobOneInEventFour', '2017-06-01', '2017-06-10', 'job description', created_event ]) created_shift = create_shift_with_details( ['2017-06-01', '09:00', '15:00', '10', created_job]) registered_shift = register_volunteer_for_shift_utility( created_shift, self.v1)
def test_shift_sign_up_with_no_slots(self): """ Test signing up for a shift for which volunteer needed is zero. """ registered_event = register_event_utility() registered_job = register_job_utility() sign_up_page = self.sign_up_page # create shift with no slot shift_2 = { 'date': "2016-05-11", 'start_time': "9:00", 'end_time': "15:00", 'max_volunteers': 1, 'job': Job.objects.get(name='job'), 'address': 'shift-address', 'venue': 'shift-venue' } s2 = create_shift_with_details(shift_2) # Create another volunteer org_name = 'volunteer-organization' org_obj = create_organization_with_details(org_name) second_country = create_second_country() second_state = create_second_state() second_city = create_second_city() volunteer_2 = { 'username': '******', 'first_name': "Sam", 'last_name': "Turtle", 'address': "Mario Land", 'city': second_city, 'state': second_state, 'country': second_country, 'phone_number': "2374983247", 'email': "*****@*****.**" } v2 = create_volunteer_with_details(volunteer_2, org_obj) # Assign shift to the volunteer registered_vol_shift = register_volunteer_for_shift_utility(s2, v2) # open Shift Sign Up sign_up_page.navigate_to_sign_up() # on event page self.assertEqual(sign_up_page.get_info_box().text, sign_up_page.no_event_message)
def test_view_with_only_registered_volunteers(self): shift_details_page = self.shift_details_page shift_details_page.live_server_url = self.live_server_url volunteer = create_volunteer_with_details(self.volunteer_detail) volunteer_shift = register_volunteer_for_shift_utility( self.shift, volunteer) shift_details_page.navigate_to_shift_details_view() # verify that the shift slot is decreased by 1 self.assertEqual(shift_details_page.get_shift_job(), 'job') self.assertEqual(shift_details_page.get_max_shift_volunteer(), '5') # verify that assigned volunteers shows up but no logged hours yet self.assertEqual(len(shift_details_page.get_registered_volunteers()), 1) self.assertEqual(shift_details_page.get_registered_volunteer_name(), 'Michael') self.assertEqual(shift_details_page.get_registered_volunteer_email(), '*****@*****.**') self.assertEqual(shift_details_page.get_message_box(),'There are no logged hours at the moment')
def test_volunteer_job_field(self): """ Test volunteer search form using the job field of the volunteers. """ search_page = self.search_page search_page.live_server_url = self.live_server_url credentials_1 = [ 'volunteer-username', 'volunteer-first-name', 'volunteer-last-name', 'volunteer-address', 'volunteer-city', 'volunteer-state', 'volunteer-country', '9999999999', '*****@*****.**' ] org_name = 'volunteer-organization' org_obj = create_organization_with_details(org_name) volunteer_1 = create_volunteer_with_details(credentials_1, org_obj) credentials_2 = [ 'volunteer-usernameq', 'volunteer-first-nameq', 'volunteer-last-nameq', 'volunteer-addressq', 'volunteer-cityq', 'volunteer-stateq', 'volunteer-countryq', '9999999999', '*****@*****.**' ] org_name = 'volunteer-organizationq' org_obj = create_organization_with_details(org_name) volunteer_2 = create_volunteer_with_details(credentials_2, org_obj) register_event_utility() register_job_utility() shift = register_shift_utility() expected_result_one = ['volunteer-first-name', 'volunteer-last-name', 'volunteer-address', 'volunteer-city', 'volunteer-state', 'volunteer-country', 'volunteer-organization', '9999999999', '*****@*****.**', 'View' ] expected_result_two = ['volunteer-first-nameq', 'volunteer-last-nameq', 'volunteer-addressq', 'volunteer-cityq', 'volunteer-stateq', 'volunteer-countryq', 'volunteer-organizationq', '9999999999', '*****@*****.**', 'View' ] # volunteer_1 and volunteer_2 registered for job register_volunteer_for_shift_utility(shift, volunteer_1) register_volunteer_for_shift_utility(shift, volunteer_2) # search job search_page.navigate_to_volunteer_search_page() search_page.search_job_field("job") search_page.submit_form() search_results = search_page.get_search_results() result = search_page.get_results_list(search_results) self.assertEqual(len(result), 2) self.assertTrue(expected_result_one in result) self.assertTrue(expected_result_two in result) # search incorrect job search_page.navigate_to_volunteer_search_page() search_page.search_job_field("wrong-job") search_page.submit_form() self.assertRaisesRegexp(NoSuchElementException, 'Unable to locate element: //table//tbody', search_page.get_search_results)
def test_intersection_of_all_fields(self): """ Test volunteer search form using multiple fields of the volunteers. """ search_page = self.search_page search_page.live_server_url = self.live_server_url credentials_1 = [ 'volunteer-username', 'VOLUNTEER-FIRST-NAME', 'volunteer-last-name', 'volunteer-address', 'volunteer-city', 'volunteer-state', 'volunteer-country', '9999999999', '*****@*****.**' ] org_name = 'volunteer-organization' org_obj = create_organization_with_details(org_name) volunteer_1 = create_volunteer_with_details(credentials_1, org_obj) credentials_2 = [ 'volunteer-usernameq', 'volunteer-first-name', 'volunteer-last-nameq', 'volunteer-addressq', 'volunteer-cityq', 'volunteer-stateq', 'volunteer-countryq', '9999999999', '*****@*****.**' ] org_name = 'volunteer-organizationq' org_obj = create_organization_with_details(org_name) volunteer_2 = create_volunteer_with_details(credentials_2, org_obj) search_page.navigate_to_volunteer_search_page() search_page.search_first_name_field('volunteer') search_page.search_last_name_field('volunteer') search_page.search_city_field('volunteer') search_page.search_state_field('volunteer') search_page.search_country_field('volunteer') search_page.search_organization_field('volunteer') search_page.submit_form() search_results = search_page.get_search_results() result = search_page.get_results_list(search_results) expected_result_one = ['VOLUNTEER-FIRST-NAME', 'volunteer-last-name', 'volunteer-address', 'volunteer-city', 'volunteer-state', 'volunteer-country', 'volunteer-organization', '9999999999', '*****@*****.**', 'View' ] expected_result_two = ['volunteer-first-name', 'volunteer-last-nameq', 'volunteer-addressq', 'volunteer-cityq', 'volunteer-stateq', 'volunteer-countryq', 'volunteer-organizationq', '9999999999', '*****@*****.**', 'View' ] register_event_utility() register_job_utility() shift = register_shift_utility() register_volunteer_for_shift_utility(shift, volunteer_1) register_volunteer_for_shift_utility(shift, volunteer_2) search_page.navigate_to_volunteer_search_page() search_page.search_first_name_field('volunteer') search_page.search_last_name_field('volunteer') search_page.search_city_field('volunteer') search_page.search_state_field('volunteer') search_page.search_country_field('volunteer') search_page.search_organization_field('volunteer') search_page.search_event_field('event') search_page.search_job_field('job') search_page.submit_form() search_results = search_page.get_search_results() result = search_page.get_results_list(search_results) self.assertEqual(len(result), 2) self.assertTrue(expected_result_one in result) self.assertTrue(expected_result_two in result) search_page.search_first_name_field('volunteer') search_page.search_country_field('wrong-country') search_page.search_organization_field('org') search_page.submit_form() self.assertRaisesRegexp(NoSuchElementException, 'Unable to locate element: //table//tbody', search_page.get_search_results) search_page.search_last_name_field('volunteer') search_page.search_city_field('wrong-city') search_page.submit_form() self.assertRaisesRegexp(NoSuchElementException, 'Unable to locate element: //table//tbody', search_page.get_search_results)
def test_intersection_of_all_fields(self): """ Test volunteer search form using multiple fields of the volunteers. """ search_page = self.search_page search_page.live_server_url = self.live_server_url country = create_country() state = create_state() city = create_city() credentials_1 = { 'username': '******', 'first_name': 'volunteer-first-name', 'last_name': 'volunteer-last-name', 'address': 'volunteer-address', 'city': city, 'state': state, 'country': country, 'phone_number': '9999999999', 'email': '*****@*****.**' } org_name = 'volunteer-organization' org_obj = create_organization_with_details(org_name) volunteer_1 = create_volunteer_with_details(credentials_1, org_obj) credentials_2 = { 'username': '******', 'first_name': 'volunteer-first-nameq', 'last_name': 'volunteer-last-nameq', 'address': 'volunteer-addressq', 'city': city, 'state': state, 'country': country, 'phone_number': '9999999999', 'email': '*****@*****.**' } org_name = 'volunteer-organizationq' org_obj = create_organization_with_details(org_name) volunteer_2 = create_volunteer_with_details(credentials_2, org_obj) search_page.navigate_to_volunteer_search_page() search_page.search_first_name_field('volunteer') search_page.search_last_name_field('volunteer') search_page.search_city_field('Roorkee') search_page.search_state_field('Uttarakhand') search_page.search_country_field('India') search_page.search_organization_field('volunteer') search_page.submit_form() search_results = search_page.get_search_results() result = search_page.get_results_list(search_results) register_event_utility() register_job_utility() shift = register_shift_utility() register_volunteer_for_shift_utility(shift, volunteer_1) register_volunteer_for_shift_utility(shift, volunteer_2) expected_result_one = [ 'volunteer-first-name', 'volunteer-last-name', 'volunteer-address', 'Roorkee,', 'Uttarakhand,', 'India', 'Uttarakhand,', 'India', 'India', 'volunteer-organization', '9999999999', '*****@*****.**', 'View' ] expected_result_two = [ 'volunteer-first-nameq', 'volunteer-last-nameq', 'volunteer-addressq', 'Roorkee,', 'Uttarakhand,', 'India', 'Uttarakhand,', 'India', 'India', 'volunteer-organizationq', '9999999999', '*****@*****.**', 'View' ] search_page.navigate_to_volunteer_search_page() search_page.search_first_name_field('volunteer') search_page.search_last_name_field('volunteer') search_page.search_city_field('Roorkee') search_page.search_state_field('Uttarakhand') search_page.search_country_field('India') search_page.search_organization_field('volunteer') search_page.search_event_field('event') search_page.search_job_field('job') search_page.submit_form() search_results = search_page.get_search_results() result = search_page.get_results_list(search_results) self.assertEqual(len(result), 2) self.assertTrue(expected_result_one in result) self.assertTrue(expected_result_two in result) search_page.search_first_name_field('volunteer') search_page.search_country_field('wrong-country') search_page.search_organization_field('org') search_page.submit_form() self.assertRaisesRegexp(NoSuchElementException, 'Unable to locate element: //table//tbody', search_page.get_search_results) search_page.search_last_name_field('volunteer') search_page.search_city_field('wrong-city') search_page.submit_form() self.assertRaisesRegexp(NoSuchElementException, 'Unable to locate element: //table//tbody', search_page.get_search_results)