def setUpClass(cls): volunteer_1 = [ 'Yoshi', "Yoshi", "Turtle", "Mario Land", "Nintendo Land", "Nintendo State", "Nintendo Nation", "2374983247", "*****@*****.**" ] volunteer_2 = [ 'John', "John", "Doe", "7 Alpine Street", "Maplegrove", "Wyoming", "USA", "23454545", "*****@*****.**" ] volunteer_3 = [ 'Ash', "Ash", "Doe", "Pallet Town", "Kanto", "Gameboy", "Japan", "23454545", "*****@*****.**" ] o1 = 'Apple' cls.org_obj = create_organization_with_details(o1) cls.v1 = create_volunteer_with_details(volunteer_1, cls.org_obj) o2 = 'Google' cls.org_obj = create_organization_with_details(o2) cls.v2 = create_volunteer_with_details(volunteer_2, cls.org_obj) o3 = 'Government of Canada' cls.org_obj = create_organization_with_details(o3) cls.org_obj.approved_status = 0 cls.org_obj.save() cls.v3 = create_volunteer_with_details(volunteer_3, cls.org_obj)
def test_volunteer_valid_organization_field(self): """ Test volunteer search form using the organization 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-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) 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' ] search_page.navigate_to_volunteer_search_page() 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) self.assertEqual(len(result), 2) self.assertTrue(expected_result_one in result) self.assertTrue(expected_result_two in result) search_page.navigate_to_volunteer_search_page() search_page.search_organization_field('v') 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)
def test_creating_duplicate_organization(self): # Create Organization create_organization_with_details('DummyOrg') # Check database for org creation self.assertEqual(len(Organization.objects.all()), 1) # Create duplicate Organization and check Error message error_message = 'duplicate key value violates unique constraint "organization_organization_name_key' error_statement = Organization.objects.create self.assertRaisesRegexp(IntegrityError, error_message, error_statement, name='DummyOrg')
def setUpClass(cls): country_name = 'India' country = get_country_by_name(country_name) state_name = 'Uttarakhand' state = get_state_by_name(state_name) city_name = 'Roorkee' city = get_city_by_name(city_name) volunteer_1 = { 'username': '******', 'first_name': "Yoshi", 'last_name': "Turtle", 'address': "Mario Land", 'city': city, 'state': state, 'country': country, 'phone_number': "2374983247", 'email': "*****@*****.**" } volunteer_2 = { 'username': '******', 'first_name': "John", 'last_name': "Doe", 'address': "7 Alpine Street", 'city': city, 'state': state, 'country': country, 'phone_number': "23454545", 'email': "*****@*****.**" } volunteer_3 = { 'username': '******', 'first_name': "Ash", 'last_name': "Ketchum", 'address': "Pallet Town", 'city': city, 'state': state, 'country': country, 'phone_number': "23454545", 'email': "*****@*****.**" } o1 = 'Apple' cls.org_obj = create_organization_with_details(o1) cls.v1 = create_volunteer_with_details(volunteer_1, cls.org_obj) o2 = 'Google' cls.org_obj = create_organization_with_details(o2) cls.v2 = create_volunteer_with_details(volunteer_2, cls.org_obj) o3 = 'Government of Canada' cls.org_obj = create_organization_with_details(o3) cls.org_obj.approved_status = 0 cls.org_obj.save() cls.v3 = create_volunteer_with_details(volunteer_3, cls.org_obj)
def test_organization_delete(self): # Create Organization create_organization_with_details('DummyOrg') # Check database for Organization create self.assertEqual(len(Organization.objects.all()), 1) # Delete org org_in_db = Organization.objects.get(Q(name='DummyOrg')) org_in_db.delete() # Check if deleted. self.assertEqual(len(Organization.objects.all()), 0)
def test_organization_edit_with_invalid_values(self): # Create Organization create_organization_with_details('DummyOrg') # Check database for org creation self.assertEqual(len(Organization.objects.all()), 1) org_in_db = Organization.objects.get(Q(name='DummyOrg')) org_in_db.name = 'Dummy~Org' # Check Error message error_message = BasePage.ENTER_VALID_VALUE self.assertRaisesRegexp(ValidationError, error_message, org_in_db.full_clean)
def test_invalid_organization_create(self): # Create Organization org = create_organization_with_details('Dummy~Org') # Check if correct error is raised. error_message = BasePage.ENTER_VALID_VALUE self.assertRaisesRegexp(ValidationError, error_message, org.full_clean)
def test_check_report_volunteer(self): self.report_page.go_to_admin_report() country = create_country() state = create_state() city = create_city() credentials = { '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) vol = create_volunteer_with_details(credentials, org_obj) register_past_event_utility() register_past_job_utility() shift = register_past_shift_utility() start = datetime.time(hour=10, minute=0) end = datetime.time(hour=11, minute=0) logged_shift = log_hours_with_details(vol, shift, start, end) create_report_with_details(vol, logged_shift) report_page = self.report_page report_page.get_page(self.live_server_url, PageUrls.administrator_report_page) self.assertEqual(report_page.get_volunteer_name(), 'VOLUNTEER-FIRST-NAME volunteer-last-name')
def setup_test_data(cls): cls.e1 = e1 cls.e2 = e2 cls.e3 = e3 cls.e4 = e4 cls.e5 = e5 cls.s1 = s1 cls.s2 = s2 cls.s3 = s3 cls.s4 = s4 volunteer_1 = [ 'Yoshi', "Yoshi", "Turtle", "Mario Land", "Nintendo Land", "Nintendo State", "Nintendo Nation", "2374983247", "*****@*****.**" ] volunteer_2 = [ 'John', "John", "Doe", "7 Alpine Street", "Maplegrove", "Wyoming", "USA", "23454545", "*****@*****.**" ] volunteer_3 = [ 'Ash', "Ash", "Ketchum", "Pallet Town", "Kanto", "Gameboy", "Japan", "23454545", "*****@*****.**" ] org_name = 'volunteer-organization' cls.org_obj = create_organization_with_details(org_name) cls.v1 = create_volunteer_with_details(volunteer_1, cls.org_obj) cls.v2 = create_volunteer_with_details(volunteer_2, cls.org_obj) cls.v3 = create_volunteer_with_details(volunteer_3, cls.org_obj)
def test_access_another_existing_volunteer_view(self): """ Test error raised while volunteer is trying to access profile page of another existing volunteer. """ upcoming_shift_page = self.upcoming_shift_page upcoming_shift_page.live_server_url = self.live_server_url self.wait.until( EC.presence_of_element_located( (By.XPATH, "//h1[contains(text(), 'Volunteer Management System')]" ) ) ) upcoming_shift_page.view_upcoming_shifts() self.assertEqual(upcoming_shift_page.get_info_box(), upcoming_shift_page.no_shift_message) details = ['test_volunteer', '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) test_volunteer = create_volunteer_with_details(details, org_obj) upcoming_shift_page.get_page(upcoming_shift_page.live_server_url, upcoming_shift_page.view_shift_page + str(test_volunteer.id)) found = re.search('You don\'t have the required rights', self.driver.page_source) self.assertNotEqual(found, None)
def test_view_with_logged_hours(self): """ Test display of shift details with hours logged in the shift. """ 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) log_hours_with_details(volunteer, self.shift, '13:00', '14:00') 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 self.assertEqual(len(shift_details_page.get_registered_volunteers()), 1) self.assertEqual(shift_details_page.get_registered_volunteer_email(), '*****@*****.**') # verify that hours are logged by volunteer self.assertEqual(len(shift_details_page.get_logged_volunteers()), 1) self.assertEqual(shift_details_page.get_logged_volunteer_name(), 'Michael') self.assertEqual(shift_details_page.get_logged_start_time(), '1 p.m.') self.assertEqual(shift_details_page.get_logged_end_time(), '2 p.m.')
def test_check_volunteer_reports(self): 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) vol = create_volunteer_with_details(credentials_1, org_obj) register_past_event_utility() register_past_job_utility() shift = register_past_shift_utility() start=datetime.time(hour=10, minute=0) end=datetime.time(hour=11, minute=0) logged_shift = log_hours_with_details(vol, shift, start, end) report = create_report_with_details(vol, logged_shift) report.confirm_status = 1 report.save() search_page.navigate_to_volunteer_search_page() search_page.submit_form() self.assertEqual(search_page.element_by_xpath(self.elements.VIEW_REPORTS).text, 'View') search_page.element_by_xpath(self.elements.VIEW_REPORTS + '//a').click() self.assertEqual(search_page.remove_i18n(self.driver.current_url), self.live_server_url + PageUrls.volunteer_history_page + str(vol.id)) self.verify_report_details('1')
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 setup_test_data(cls): cls.e1 = e1 cls.j1 = j1 cls.j2 = j2 shift_1 = ["2015-08-23", "9:00", "15:00", 1, cls.j1] shift_2 = [date.today() + timedelta(7), "10:00", "16:00", 2, cls.j1] # one week date shift_3 = [date.today() + timedelta(1), "12:00", "18:00", 2, cls.j2] # tomorrow date cls.s1 = create_shift_with_details(shift_1) cls.s2 = create_shift_with_details(shift_2) cls.s3 = create_shift_with_details(shift_3) volunteer_1 = [ 'Jake', "Jake", "Flamoy", "Mario Land", "Nintendo Land", "Nintendo State", "Nintendo Nation", "2374983247", "*****@*****.**" ] volunteer_2 = [ 'Dora', "Dorothy", "Flamoy", "7 Alpine Street", "Maplegrove", "Wyoming", "USA", "23454545", "*****@*****.**" ] org_name = 'Google' cls.org_obj = create_organization_with_details(org_name) cls.v1 = create_volunteer_with_details(volunteer_1, cls.org_obj) cls.v2 = create_volunteer_with_details(volunteer_2, cls.org_obj)
def setup_test_data(cls): cls.e1 = e1 cls.j1 = j1 cls.j2 = j2 cls.s1 = s1 cls.s2 = s2 cls.s3 = s3 # Create volunteers who will register for the shifts volunteer_1 = [ 'Yoshi', "Yoshi", "Turtle", "Mario Land", "Nintendo Land", "Nintendo State", "Nintendo Nation", "2374983247", "*****@*****.**" ] volunteer_2 = [ 'John', "John", "Doe", "7 Alpine Street", "Maplegrove", "Wyoming", "USA", "23454545", "*****@*****.**" ] volunteer_3 = [ 'Ash', "Ash", "Ketchum", "Pallet Town", "Kanto", "Gameboy", "Japan", "23454545", "*****@*****.**" ] org_name = 'Locale' cls.org_obj = create_organization_with_details(org_name) cls.v1 = create_volunteer_with_details(volunteer_1, cls.org_obj) cls.v2 = create_volunteer_with_details(volunteer_2, cls.org_obj) cls.v3 = create_volunteer_with_details(volunteer_3, cls.org_obj)
def test_assign_shifts_with_no_shifts(self): """ Test no shift present at shifts sign up page for volunteer to sign up for. """ sign_up_page = self.sign_up_page manage_shift_page = self.manage_shift_page manage_shift_page.live_server_url = self.live_server_url # Register volunteers org_obj = create_organization_with_details(self.org_name) volunteer_1 = create_volunteer_with_details(self.volunteer_1, org_obj) # Create events event = ['event-name', '2017-05-20', '2017-05-20'] event_1 = create_event_with_details(event) # Create jobs job = ['job name', '2017-05-20', '2017-05-20', 'job description', event_1] job_1 = create_job_with_details(job) self.wait_for_home_page() # Open manage volunteer shift manage_shift_page.navigate_to_manage_shift_page() manage_shift_page.select_volunteer(1) manage_shift_page.assign_shift() # No events shown in table self.assertEqual(sign_up_page.get_info_box().text, sign_up_page.no_event_message)
def test_access_another_existing_volunteer_view(self): """ Test error raised while volunteer is trying to access profile page of another existing volunteer. """ upcoming_shift_page = self.upcoming_shift_page upcoming_shift_page.live_server_url = self.live_server_url self.wait.until( EC.presence_of_element_located( (By.XPATH, "//h1[contains(text(), 'Volunteer Management System')]"))) upcoming_shift_page.view_upcoming_shifts() self.assertEqual(upcoming_shift_page.get_info_box(), upcoming_shift_page.no_shift_message) details = [ 'test_volunteer', '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) test_volunteer = create_volunteer_with_details(details, org_obj) upcoming_shift_page.get_page( upcoming_shift_page.live_server_url, upcoming_shift_page.view_shift_page + str(test_volunteer.id)) found = re.search('You don\'t have the required rights', self.driver.page_source) self.assertNotEqual(found, None)
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 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_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 create_volunteer(): vol = [ "Goku", "Son", "Goku", "Kame House", "East District", "East District", "East District", "9999999999", "*****@*****.**" ] org_name = 'Google' org_obj = create_organization_with_details(org_name) return create_volunteer_with_details(vol, org_obj)
def test_model_representation(self): """ Test model representation of registered organization. """ # Create Organization org = create_organization_with_details('DummyOrg') # Check __str__ self.assertEqual(org.name, str(org))
def test_slots_remaining_in_shift(self): """ Test correct display of the remaining number of slots for shift. """ sign_up_page = self.sign_up_page manage_shift_page = self.manage_shift_page manage_shift_page.live_server_url = self.live_server_url # Register volunteers org_obj = create_organization_with_details(self.org_name) volunteer_1 = create_volunteer_with_details(self.volunteer_1, org_obj) volunteer_2 = create_volunteer_with_details(self.volunteer_2, org_obj) shift = ['09:00', '15:00', '1'] shift_1 = self.create_shift(shift) # Open manage volunteer shift manage_shift_page.navigate_to_manage_shift_page() # Volunteer-one does not have any registered shifts manage_shift_page.select_volunteer(1) self.assertEqual(manage_shift_page.get_info_box(), manage_shift_page.no_volunteer_shift_message) manage_shift_page.assign_shift() # Events shown in table self.assertRaisesRegexp(NoSuchElementException, 'Unable to locate element: .alert-info', sign_up_page.get_info_box) manage_shift_page.navigate_to_shift_assignment_page() # Confirm on shift assignment to volunteer-one manage_shift_page.submit_form() self.assertRaisesRegexp(NoSuchElementException, 'Unable to locate element: .alert-danger', sign_up_page.get_danger_box) # Check shift assignment to volunteer-one manage_shift_page.navigate_to_manage_shift_page() manage_shift_page.select_volunteer(1) self.check_job_details( ['job name', 'May 20, 2050', '9 a.m.', '3 p.m.']) # Open manage volunteer shift again to assign shift to volunteer two manage_shift_page.navigate_to_manage_shift_page() # Volunteer-two does not have any registered shifts manage_shift_page.select_volunteer(2) self.assertEqual(manage_shift_page.get_info_box(), manage_shift_page.no_volunteer_shift_message) manage_shift_page.assign_shift() # No events shown in table self.assertEqual(sign_up_page.get_info_box().text, sign_up_page.no_event_message)
def setup_test_data(cls): cls.e1 = e1 cls.j1 = j1 cls.j2 = j2 cls.s1 = s1 cls.s2 = s2 cls.s3 = s3 country_name = 'United States' country = get_country_by_name(country_name) state_name = 'Washington' state = get_state_by_name(state_name) city_name = 'Bothell' city = get_city_by_name(city_name) # Create volunteers who will register for the shifts volunteer_1 = { 'username': '******', 'first_name': "Yoshi", 'last_name': "Turtle", 'address': "Mario Land", 'city': city, 'state': state, 'country': country, 'phone_number': "2374983247", 'email': "*****@*****.**" } volunteer_2 = { 'username': '******', 'first_name': "John", 'last_name': "Doe", 'address': "7 Alpine Street", 'city': city, 'state': state, 'country': country, 'phone_number': "23454545", 'email': "*****@*****.**" } volunteer_3 = { 'username': '******', 'first_name': "Ash", 'last_name': "Ketchum", 'address': "Pallet Town", 'city': city, 'state': state, 'country': country, 'phone_number': "23454545", 'email': "*****@*****.**" } org_name = 'Locale' cls.org_obj = create_organization_with_details(org_name) cls.v1 = create_volunteer_with_details(volunteer_1, cls.org_obj) cls.v2 = create_volunteer_with_details(volunteer_2, cls.org_obj) cls.v3 = create_volunteer_with_details(volunteer_3, cls.org_obj)
def test_valid_organization_create(self): # Create Organization org = create_organization_with_details('DummyOrg') # Check database for org creation self.assertEqual(len(Organization.objects.all()), 1) org_in_db = Organization.objects.get(Q(name='DummyOrg')) # Verify correct name saved self.assertEqual(org_in_db.name, org.name) self.assertEqual(org_in_db.approved_status, 1)
def create_volunteer(): """ Utility function to create a valid volunteer. :return: Volunteer type object """ vol = [ "Goku", "Son", "Goku", "Kame House", "East District", "East District", "East District", "9999999999", "*****@*****.**" ] org_name = 'Google' org_obj = create_organization_with_details(org_name) return create_volunteer_with_details(vol, org_obj)
def create_invalid_vol(): """ Utility function to create an invalid volunteer. :return: Volunteer type object """ vol = [ 'Goku~', "Son", "Goku", "Kame House", "East District", "East District", "East District", "9999999999", "" ] org_name = 'org' org_obj = create_organization_with_details(org_name) return create_volunteer_with_details(vol, org_obj)
def setup_test_data(cls): cls.e1 = e1 cls.e2 = e2 cls.e3 = e3 cls.e4 = e4 cls.e5 = e5 cls.s1 = s1 cls.s2 = s2 cls.s3 = s3 cls.s4 = s4 volunteer_1 = { 'username': '******', 'first_name': "Yoshi", 'last_name': "Turtle", 'address': "Mario Land", 'city': city, 'state': state, 'country': country, 'phone_number': "2374983247", 'email': "*****@*****.**" } volunteer_2 = { 'username': '******', 'first_name': "John", 'last_name': "Doe", 'address': "7 Alpine Street", 'city': city, 'state': state, 'country': country, 'phone_number': "23454545", 'email': "*****@*****.**" } volunteer_3 = { 'username': '******', 'first_name': "Ash", 'last_name': "Ketchum", 'address': "Pallet Town", 'city': city, 'state': state, 'country': country, 'phone_number': "23454545", 'email': "*****@*****.**" } org_name = 'volunteer-organization' cls.org_obj = create_organization_with_details(org_name) cls.v1 = create_volunteer_with_details(volunteer_1, cls.org_obj) cls.v2 = create_volunteer_with_details(volunteer_2, cls.org_obj) cls.v3 = create_volunteer_with_details(volunteer_3, cls.org_obj)
def setUp(self): """ Method consists of statements to be executed before start of each test. """ vol = [ 'Goku', "Son", "Goku", "Kame House", "East District", "East District", "East District", "9999999999", "*****@*****.**" ] org_name='Detective' org_obj = create_organization_with_details(org_name) self.volunteer_1 = create_volunteer_with_details(vol, org_obj) self.login_correctly()
def test_assign_shifts_with_registered_shifts(self): """ Test assignment of shift present at shifts sign up page for volunteer to sign up for. """ sign_up_page = self.sign_up_page manage_shift_page = self.manage_shift_page manage_shift_page.live_server_url = self.live_server_url # Register volunteers org_obj = create_organization_with_details(self.org_name) volunteer_1 = create_volunteer_with_details(self.volunteer_1, org_obj) shift = ['09:00', '15:00', '1'] shift_1 = self.create_shift(shift) self.wait_for_home_page() # Volunteer-one does not have any registered shifts manage_shift_page.navigate_to_manage_shift_page() manage_shift_page.select_volunteer(1) self.assertEqual(manage_shift_page.get_info_box(), manage_shift_page.no_volunteer_shift_message) manage_shift_page.assign_shift() # Events shown in table self.assertRaisesRegexp(NoSuchElementException, 'Unable to locate element: .alert-info', sign_up_page.get_info_box) manage_shift_page.navigate_to_shift_assignment_page() # Confirm on shift assignment to volunteer-one manage_shift_page.submit_form() self.assertRaisesRegexp(NoSuchElementException, 'Unable to locate element: .alert-danger', sign_up_page.get_danger_box) # Check shift assignment to volunteer-one manage_shift_page.navigate_to_manage_shift_page() manage_shift_page.select_volunteer(1) self.check_job_details( ['job name', 'May 20, 2050', '9 a.m.', '3 p.m.']) # check shift assignment email mail.outbox = [] mail.send_mail("Shift Assigned", "message", "*****@*****.**", [volunteer_1.email]) self.assertEqual(len(mail.outbox), 1) msg = mail.outbox[0] self.assertEqual(msg.subject, 'Shift Assigned') self.assertEqual(msg.to, ['*****@*****.**'])
def setUp(self): """ Method consists of statements to be executed before start of each test. """ vol = [ 'Goku', "Son", "Goku", "Kame House", "East District", "East District", "East District", "9999999999", "*****@*****.**" ] org_name = 'Detective' org_obj = create_organization_with_details(org_name) self.volunteer_1 = create_volunteer_with_details(vol, org_obj) self.login_correctly()
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 setup_test_data(cls): cls.e1 = e1 cls.j1 = j1 cls.j3 = j3 # job with no shifts cls.j2 = j2 # job with shift which has no slot job_4 = [ "Information Technologist", "2012-11-2", "2012-12-2", "An IT job", e1 ] cls.j4 = create_job_with_details(job_4) shift_1 = ["2012-10-23", "1:00", "3:00", 1, cls.j1] shift_2 = ["2012-10-25", "2:00", "4:00", 2, cls.j1] shift_3 = ["2012-10-24", "12:00", "18:00", 4, cls.j3] # shift with no slots shift_4 = ["2012-11-7", "12:00", "18:00", 1, cls.j4] cls.s1 = create_shift_with_details(shift_1) cls.s2 = create_shift_with_details(shift_2) cls.s3 = create_shift_with_details(shift_3) cls.s4 = create_shift_with_details(shift_4) # creating volunteers who would register for the shifts volunteer_1 = [ 'Yoshi', "Yoshi", "Turtle", "Mario Land", "Nintendo Land", "Nintendo State", "Nintendo Nation", "2374983247", "*****@*****.**" ] volunteer_2 = [ 'John', "John", "Doe", "7 Alpine Street", "Maplegrove", "Wyoming", "USA", "23454545", "*****@*****.**" ] volunteer_3 = [ 'Ash', "Ash", "Ketchum", "Pallet Town", "Kanto", "Gameboy", "Japan", "23454545", "*****@*****.**" ] org_name = 'volunteer-organization' org_obj = create_organization_with_details(org_name) cls.v1 = create_volunteer_with_details(volunteer_1, org_obj) cls.v2 = create_volunteer_with_details(volunteer_2, org_obj) cls.v3 = create_volunteer_with_details(volunteer_3, org_obj)
def test_shift_edit_request(self): """ checks the edit request link received by admin """ org_obj = create_organization_with_details(self.org_name) volunteer_1 = create_volunteer_with_details(self.volunteer_1, org_obj) shift = ['09:00', '15:00', '1'] shift_1 = self.create_shift(shift) start = datetime.time(hour=10, minute=0) end = datetime.time(hour=14, minute=0) logged_shift = log_hours_with_details(volunteer_1, shift_1, start, end) start_time = datetime.time(hour=9, minute=30) end_time = datetime.time(hour=14, minute=0) edit_request = create_edit_request_with_details(start_time, end_time, logged_shift) response = self.client.get(reverse('shift:edit_request_manager', args=[shift_1.id, volunteer_1.id, edit_request.id])) self.assertEqual(response.status_code, 302)
def test_assign_same_shift_to_volunteer_twice(self): """ Test errors while assignment of same shift to volunteer to which they are already assigned. """ sign_up_page = self.sign_up_page manage_shift_page = self.manage_shift_page self.manage_shift_page.live_server_url = self.live_server_url # Register volunteers org_obj = create_organization_with_details(self.org_name) volunteer_1 = create_volunteer_with_details(self.volunteer_1, org_obj) shift = ['09:00', '15:00', '1'] shift_1 = self.create_shift(shift) self.wait_for_home_page() # Open manage volunteer shift manage_shift_page.navigate_to_manage_shift_page() # Volunteer-one does not have any registered shifts manage_shift_page.select_volunteer(1) self.assertEqual(manage_shift_page.get_info_box(), manage_shift_page.no_volunteer_shift_message) manage_shift_page.assign_shift() # Events shown in table self.assertRaisesRegexp(NoSuchElementException, 'Unable to locate element: .alert-info', sign_up_page.get_info_box) manage_shift_page.navigate_to_shift_assignment_page() # Confirm on shift assignment to volunteer-one manage_shift_page.submit_form() self.assertRaisesRegexp(NoSuchElementException, 'Unable to locate element: .alert-danger', sign_up_page.get_danger_box) # Assign same shift to voluteer-one again # Check volunteer-one has one registered shift now self.assertEqual(sign_up_page.get_shift_job(), 'job name') manage_shift_page.assign_shift() # Events page self.assertEqual(sign_up_page.get_info_box().text,sign_up_page.no_event_message)
def test_organization_edit_with_valid_values(self): # Create Organization org = create_organization_with_details('DummyOrg') # Check database for org creation self.assertEqual(len(Organization.objects.all()), 1) org_in_db = Organization.objects.get(Q(name='DummyOrg')) org_in_db.name = 'DummyOrgNew' org_in_db.approved_status = 2 org_in_db.save() org_in_db = Organization.objects.get(Q(name='DummyOrgNew')) # Check if save was successful self.assertNotEqual(org_in_db.name, org.name) self.assertNotEqual(org_in_db.approved_status,org.approved_status)
def test_landing_page_with_registered_volunteers(self): """ Test details on manage shifts page with data registered. """ manage_shift_page = self.manage_shift_page manage_shift_page.live_server_url = self.live_server_url # Register volunteer org_obj = create_organization_with_details(self.org_name) volunteer_1 = create_volunteer_with_details(self.volunteer_1, org_obj) self.wait_for_home_page() manage_shift_page.navigate_to_manage_shift_page() self.assertNotEqual(manage_shift_page.find_table_row(), None) manage_shift_page.select_volunteer(1) self.assertEqual(manage_shift_page.get_info_box(), manage_shift_page.no_volunteer_shift_message)
def setup_test_data(cls): cls.e1 = e1 cls.j1 = j1 shift_1 = ["2012-10-28", "9:00", "15:00", 1, cls.j1] shift_2 = ["2012-10-25", "10:00", "16:00", 2, cls.j1] cls.s1 = create_shift_with_details(shift_1) cls.s2 = create_shift_with_details(shift_2) volunteer_1 = [ 'Aaron', "Aaron", "Turtle", "Mario Land", "Nintendo Land", "Nintendo State", "Nintendo Nation", "2374983247", "*****@*****.**" ] org_name = 'organization' cls.org_obj = create_organization_with_details(org_name) cls.v1 = create_volunteer_with_details(volunteer_1, cls.org_obj)
def setUpClass(cls): volunteer_1 = [ 'Margaret', "Yoshi", "Turtle", "Mario Land", "Nintendo Land", "Nintendo State", "Nintendo Nation", "2374983247", "*****@*****.**" ] volunteer_2 = [ 'Miu', "John", "Doe", "7 Alpine Street", "Maplegrove", "Wyoming", "USA", "23454545", "*****@*****.**" ] volunteer_3 = [ 'Brock', "Ash", "Ketchum", "Pallet Town", "Kanto", "Gameboy", "Japan", "23454545", "*****@*****.**" ] org_name = 'volunteer-organization' cls.org_obj = create_organization_with_details(org_name) cls.v1 = create_volunteer_with_details(volunteer_1, cls.org_obj) cls.v2 = create_volunteer_with_details(volunteer_2, cls.org_obj) cls.v3 = create_volunteer_with_details(volunteer_3, cls.org_obj)
def test_check_report_volunteer(self): self.report_page.go_to_admin_report() credentials = [ '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) vol = create_volunteer_with_details(credentials, org_obj) register_past_event_utility() register_past_job_utility() shift = register_past_shift_utility() start=datetime.time(hour=10, minute=0) end=datetime.time(hour=11, minute=0) logged_shift = log_hours_with_details(vol, shift, start, end) create_report_with_details(vol, logged_shift) report_page = self.report_page report_page.get_page(self.live_server_url, PageUrls.administrator_report_page) self.assertEqual(report_page.get_volunteer_name(), 'VOLUNTEER-FIRST-NAME volunteer-last-name')
def test_table_layout(self): """ Test the shift table has details displayed correctly. """ sign_up_page = self.sign_up_page manage_shift_page = self.manage_shift_page manage_shift_page.live_server_url = self.live_server_url # Register volunteers org_obj = create_organization_with_details(self.org_name) volunteer_1 = create_volunteer_with_details(self.volunteer_1, org_obj) shift = ['09:00', '15:00', '1'] shift_1 = self.create_shift(shift) self.wait_for_home_page() # Open manage volunteer shift self.manage_shift_page.navigate_to_manage_shift_page() # Volunteer-one does not have any registered shifts manage_shift_page.select_volunteer(1) manage_shift_page.assign_shift() # Events shown in table self.assertRaisesRegexp(NoSuchElementException, 'Message: Unable to locate element: .alert-info', sign_up_page.get_info_box) self.assertEqual(sign_up_page.get_view_jobs(), manage_shift_page.VIEW_JOB) sign_up_page.click_to_view_jobs() # Arrived on page2 with jobs self.assertEqual(sign_up_page.get_view_shifts(), manage_shift_page.VIEW_SHIFT) sign_up_page.click_to_view_shifts() # Arrived on page3 with shifts, assign shift to volunteer one self.assertEqual(sign_up_page.get_sign_up(), manage_shift_page.shift_assignment_text)