From 469f186fb31cb5405260f631ce41c171404b5609 Mon Sep 17 00:00:00 2001 From: Monal Shadi Date: Wed, 13 Jun 2018 22:45:01 +0530 Subject: [PATCH] Tests for Event app (#707) --- vms/event/models.py | 2 +- vms/event/tests/test_event.py | 154 ++++++++++++++++++++++++ vms/event/tests/test_model.py | 115 ++++++++++++++++++ vms/event/tests/test_services.py | 1 - vms/event/tests/test_shiftSignUp.py | 160 ++++++++++--------------- vms/event/tests/test_unit.py | 4 - vms/pom/locators/eventsPageLocators.py | 3 +- vms/pom/pages/basePage.py | 1 + vms/pom/pages/eventSignUpPage.py | 11 +- vms/pom/pages/eventsPage.py | 20 +++- vms/shift/utils.py | 11 +- 11 files changed, 366 insertions(+), 116 deletions(-) create mode 100644 vms/event/tests/test_event.py create mode 100644 vms/event/tests/test_model.py delete mode 100644 vms/event/tests/test_unit.py diff --git a/vms/event/models.py b/vms/event/models.py index d20588254..1431ea654 100644 --- a/vms/event/models.py +++ b/vms/event/models.py @@ -58,4 +58,4 @@ class Event(models.Model): ) def __str__(self): - return self.name + return str(self.name) diff --git a/vms/event/tests/test_event.py b/vms/event/tests/test_event.py new file mode 100644 index 000000000..cb8916ad9 --- /dev/null +++ b/vms/event/tests/test_event.py @@ -0,0 +1,154 @@ +# third party +from selenium import webdriver + +# Django +from django.contrib.staticfiles.testing import LiveServerTestCase + +# local Django +from pom.pages.authenticationPage import AuthenticationPage +from pom.pages.eventsPage import EventsPage +from shift.utils import (create_admin, create_event_with_details) + + +class EventDetails(LiveServerTestCase): + """ + Contains Tests for Job app in aspect of + an admin's view of website. + """ + + @classmethod + def setUpClass(cls): + cls.driver = webdriver.Firefox() + cls.driver.implicitly_wait(5) + cls.driver.maximize_window() + cls.event_details_page = EventsPage(cls.driver) + cls.authentication_page = AuthenticationPage(cls.driver) + super(EventDetails, cls).setUpClass() + + @classmethod + def tearDownClass(cls): + cls.driver.quit() + super(EventDetails, cls).tearDownClass() + + def setUp(self): + create_admin() + self.login_admin() + + def tearDown(self): + self.authentication_page.logout() + + @staticmethod + def register_valid_event(): + created_event = create_event_with_details(['event', '2050-06-11', '2050-06-19']) + return created_event + + def check_error_messages(self): + event_details_page = self.event_details_page + self.assertEqual(len(event_details_page.get_help_blocks()), 3) + self.assertEqual(event_details_page.get_event_name_error(), event_details_page.FIELD_REQUIRED) + self.assertEqual(event_details_page.get_event_start_date_error(), event_details_page.FIELD_REQUIRED) + self.assertEqual(event_details_page.get_event_end_date_error(), event_details_page.FIELD_REQUIRED) + + def login_admin(self): + authentication_page = self.authentication_page + authentication_page.server_url = self.live_server_url + authentication_page.login( + { + 'username': 'admin', + 'password': 'admin' + } + ) + + def test_event_details_view(self): + # Navgate to event view + event_details_page = self.event_details_page + event_details_page.live_server_url = self.live_server_url + event_details_page.go_to_events_page() + + self.assertEqual(event_details_page.get_message_context(), + event_details_page.NO_EVENT_PRESENT) + + # Create a valid event + created_event = EventDetails.register_valid_event() + + # Verify Details + event_details_page.navigate_to_event_list_view() + self.assertEqual(event_details_page.get_event_name(), created_event.name) + self.assertEqual(event_details_page.get_event_start_date(), 'June 11, 2050') + self.assertEqual(event_details_page.get_event_end_date(), 'June 19, 2050') + + def test_valid_event_create(self): + created_event = EventDetails.register_valid_event() + + event_details_page = self.event_details_page + event_details_page.live_server_url = self.live_server_url + event_details_page.go_to_events_page() + + # Check event creation + self.assertEqual(event_details_page.get_event_name(), created_event.name) + self.assertEqual(event_details_page.get_event_start_date(), 'June 11, 2050') + self.assertEqual(event_details_page.get_event_end_date(), 'June 19, 2050') + + def test_invalid_event_create(self): + event_details_page = self.event_details_page + event_details_page.live_server_url = self.live_server_url + event_details_page.go_to_events_page() + + # Create empty job + event = ['', '', ''] + event_details_page.go_to_create_event_page() + event_details_page.fill_event_form(event) + + # Check error messages + self.check_error_messages() + + def test_invalid_event_edit(self): + registered_event = EventDetails.register_valid_event() + event_details_page = self.event_details_page + event_details_page.live_server_url = self.live_server_url + event_details_page.go_to_events_page() + + event_details_page.go_to_edit_event_page() + + null_valued_event = ['', '', ''] + event_details_page.fill_event_form(null_valued_event) + self.check_error_messages() + + def test_valid_event_edit(self): + registered_event = EventDetails.register_valid_event() + event_details_page = self.event_details_page + event_details_page.live_server_url = self.live_server_url + event_details_page.go_to_events_page() + + edit_job = ['newevent', '2050-06-12', '2050-06-20'] + event_details_page.go_to_edit_event_page() + event_details_page.fill_event_form(edit_job) + event_details_page.navigate_to_event_list_view() + + self.assertEqual(event_details_page.get_event_name(), edit_job[0]) + self.assertEqual(event_details_page.get_event_start_date(), 'June 12, 2050') + self.assertEqual(event_details_page.get_event_end_date(), 'June 20, 2050') + + def test_event_delete(self): + registered_event = EventDetails.register_valid_event() + event_details_page = self.event_details_page + event_details_page.live_server_url = self.live_server_url + event_details_page.go_to_events_page() + + self.assertEqual(event_details_page.get_delete_event_element('').text, 'Delete') + event_details_page.get_delete_event_element('//a').click() + self.assertEqual(event_details_page.get_deletion_context(), 'Delete Event') + event_details_page.submit_form() + + def test_start_date_after_end_date(self): + event_details_page = self.event_details_page + event_details_page.live_server_url = self.live_server_url + event_details_page.go_to_events_page() + event_details_page.go_to_create_event_page() + + event_start_after_end = ['event name', '2050-06-17', '2050-06-16'] + event_details_page.fill_event_form(event_start_after_end) + + # Check error. + self.assertEqual(event_details_page.get_event_start_date_error(), + event_details_page.START_BEFORE_END) diff --git a/vms/event/tests/test_model.py b/vms/event/tests/test_model.py new file mode 100644 index 000000000..92e7c2b87 --- /dev/null +++ b/vms/event/tests/test_model.py @@ -0,0 +1,115 @@ +# third party + +# Django +from django.core.exceptions import ValidationError +from django.db.models import Q +from django.test.testcases import TestCase + +# local Django +from event.models import Event +from shift.utils import create_event_with_details +from pom.pages.eventsPage import EventsPage + + +class EventModelTests(TestCase): + + def setUp(self): + pass + + def tearDown(self): + pass + + @staticmethod + def create_event(): + event = ['event-name', '2050-05-24', '2050-05-28'] + created_event = create_event_with_details(event) + return created_event + + def test_valid_model_create(self): + event = ['event-name', '2050-05-24', '2050-05-28'] + create_event_with_details(event) + + # Check database for instance creation + self.assertNotEqual(len(Event.objects.all()), 0) + + event_in_db = Event.objects.get(Q(name='event-name')) + # Verify correctness + self.assertEqual(event_in_db.name, event[0]) + self.assertEqual(str(event_in_db.start_date), event[1]) + self.assertEqual(str(event_in_db.end_date), event[2]) + + def test_invalid_model_create(self): + event = ['event~name', '2050-05-21', '2050-05-24'] + event = create_event_with_details(event) + + self.assertRaisesRegexp(ValidationError, EventsPage.ENTER_VALID_VALUE, event.full_clean) + + # Check database for instance creation + self.assertNotEqual(len(Event.objects.all()), 0) + + def test_model_edit_with_valid_values(self): + created_event = EventModelTests.create_event() + + # Check db for instance creation + self.assertEqual(len(Event.objects.all()), 1) + + event_in_db = Event.objects.get(Q(name='event-name')) + # Check if correct event retrieved + self.assertEqual(event_in_db.name, created_event.name) + + # Edit job + event_in_db.name = 'new-event-name' + event_in_db.save() + + event_in_db = Event.objects.get(Q(name='new-event-name')) + # Check if save is success + self.assertEqual(event_in_db.name, 'new-event-name') + self.assertEqual(len(Event.objects.all()), 1) + + def test_model_edit_with_invalid_values(self): + created_event = EventModelTests.create_event() + + # Check db for instance creation + self.assertEqual(len(Event.objects.all()), 1) + + event_in_db = Event.objects.get(Q(name='event-name')) + # Check if correct event retrieved + self.assertEqual(event_in_db.name, created_event.name) + + # Edit job + event_in_db.name = 'new~event~name' + event_in_db.save() + + self.assertRaisesRegexp(ValidationError, + EventsPage.ENTER_VALID_VALUE, + event_in_db.full_clean) + + # Check database for instance creation + self.assertNotEqual(len(Event.objects.all()), 0) + + def test_model_delete(self): + created_event = EventModelTests.create_event() + + # Check db for instance creation + self.assertEqual(len(Event.objects.all()), 1) + + event_in_db = Event.objects.get(Q(name='event-name')) + # Check if correct job retrieved + self.assertEqual(event_in_db.name, created_event.name) + + # Delete job + event_in_db.delete() + + # Check if delete is successful + self.assertEqual(len(Event.objects.all()), 0) + + def test_model_representation(self): + EventModelTests.create_event() + + # Check db for instance creation + self.assertEqual(len(Event.objects.all()), 1) + + event_in_db = Event.objects.get(Q(name='event-name')) + + # Check __str__ + self.assertEqual(str(event_in_db), event_in_db.name) diff --git a/vms/event/tests/test_services.py b/vms/event/tests/test_services.py index fae6bde27..3146f4edd 100644 --- a/vms/event/tests/test_services.py +++ b/vms/event/tests/test_services.py @@ -242,7 +242,6 @@ class EventWithVolunteerTest(unittest.TestCase): @classmethod def setup_test_data(cls): - cls.e1 = e1 cls.e2 = e2 cls.e3 = e3 diff --git a/vms/event/tests/test_shiftSignUp.py b/vms/event/tests/test_shiftSignUp.py index b84d1a15d..f8816b15b 100644 --- a/vms/event/tests/test_shiftSignUp.py +++ b/vms/event/tests/test_shiftSignUp.py @@ -6,21 +6,20 @@ from selenium.common.exceptions import NoSuchElementException # local Django -# from job.models import Job +from job.models import Job from pom.pages.authenticationPage import AuthenticationPage from pom.pages.eventSignUpPage import EventSignUpPage -from shift.models import VolunteerShift from shift.utils import ( create_volunteer, register_event_utility, register_job_utility, - register_shift_utility) + register_shift_utility, create_shift_with_details, create_volunteer_with_details, + register_volunteer_for_shift_utility) -# Class contains failing test cases which have been documented -# Test class commented out to prevent travis build failure -""" class ShiftSignUp(LiveServerTestCase): - ''' - ''' + """ + Tests dealing with Event app in aspect + of Volunteer's view of website. + """ @classmethod def setUpClass(cls): @@ -32,7 +31,7 @@ def setUpClass(cls): super(ShiftSignUp, cls).setUpClass() def setUp(self): - self.volunteer = create_volunteer() + create_volunteer() self.login_volunteer() def tearDown(self): @@ -40,6 +39,7 @@ def tearDown(self): @classmethod def tearDownClass(cls): + cls.authentication_page.logout() cls.driver.quit() super(ShiftSignUp, cls).tearDownClass() @@ -53,116 +53,102 @@ def login_volunteer(self): def test_events_page_with_no_events(self): sign_up_page = self.sign_up_page sign_up_page.navigate_to_sign_up() - self.assertEqual(sign_up_page.get_info_box().text, - sign_up_page.no_event_message) + self.assertEqual(sign_up_page.get_info_box().text, sign_up_page.no_event_message) def test_signup_shifts_with_registered_shifts(self): - - created_event = register_event_utility() - created_job = register_job_utility() - created_shift = register_shift_utility() + registered_event = register_event_utility() + registered_job = register_job_utility() + registered_shift = register_shift_utility() sign_up_page = self.sign_up_page - # open Shift Sign Up + # Open Shift Sign Up sign_up_page.navigate_to_sign_up() - # on event page + # On event page sign_up_page.click_to_view_jobs() - # on jobs page + # On jobs page sign_up_page.click_to_view_shifts() - # on shifts page + # On shifts page sign_up_page.click_to_sign_up() - # confirm shift assignment + # Confirm shift assignment sign_up_page.submit_form() with self.assertRaises(NoSuchElementException): sign_up_page.get_danger_box() # check shift signed up - self.assertEqual(sign_up_page.get_signed_up_shift_text(), - 'Upcoming Shifts') + self.assertEqual(sign_up_page.get_signed_up_shift_text(), 'Upcoming Shifts') self.assertEqual(sign_up_page.get_shift_job(), 'job') - self.assertEqual(sign_up_page.get_shift_date(), 'June 15, 2017') + self.assertEqual(sign_up_page.get_shift_date(), 'June 15, 2050') self.assertEqual(sign_up_page.get_shift_start_time(), '9 a.m.') self.assertEqual(sign_up_page.get_shift_end_time(), '3 p.m.') - # database check to ensure volunteer has signed up for the shift - self.assertEqual(len(VolunteerShift.objects.all()), 1) - self.assertNotEqual( - len( - VolunteerShift.objects.filter( - volunteer_id=self.volunteer.id, - shift_id=created_shift.id)), 0) - def test_signup_for_same_shift_again(self): - - register_event_utility() - register_job_utility() - register_shift_utility() + registered_event = register_event_utility() + registered_job = register_job_utility() + registered_shift = register_shift_utility() sign_up_page = self.sign_up_page - # open Shift Sign Up + # Open Shift Sign Up sign_up_page.navigate_to_sign_up() - # events shown in table + # Events shown in table with self.assertRaises(NoSuchElementException): sign_up_page.get_info_box() sign_up_page.click_to_view_jobs() - # on jobs page + # On jobs page sign_up_page.click_to_view_shifts() - # on shifts page, Sign up this shift ! + # On shifts page, Sign up this shift ! sign_up_page.click_to_sign_up() - # confirm on shift sign up + # Confirm on shift sign up sign_up_page.submit_form() with self.assertRaises(NoSuchElementException): sign_up_page.get_danger_box() - # sign up same shift again - # open Shift Sign Up + # Sign up same shift again + # Open Shift Sign Up sign_up_page.navigate_to_sign_up() - # events page - self.assertEqual(sign_up_page.get_info_box().text,sign_up_page.no_event_message) + # Events page + self.assertEqual(sign_up_page.get_info_box().text, sign_up_page.no_event_message) with self.assertRaises(NoSuchElementException): sign_up_page.find_table_tag() def test_empty_events(self): - - register_event_utility() + registered_event = register_event_utility() sign_up_page = self.sign_up_page - # open Shift Sign Up + # 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) + # On event page + self.assertEqual(sign_up_page.get_info_box().text, sign_up_page.no_event_message) with self.assertRaises(NoSuchElementException): sign_up_page.find_table_tag() sign_up_page.click_to_view_jobs() - register_job_utility() + registered_job = register_job_utility() - self.assertEqual(sign_up_page.get_info_box().text,sign_up_page.no_event_message) + self.assertEqual(sign_up_page.get_info_box().text, sign_up_page.no_event_message) with self.assertRaises(NoSuchElementException): sign_up_page.find_table_tag() def test_shift_sign_up_with_outdated_shifts(self): - - register_event_utility() - register_job_utility() + registered_event = register_event_utility() + registered_job = register_job_utility() sign_up_page = self.sign_up_page # create outdated shift - shift_1 = ["2016-05-11","9:00","15:00",6,Job.objects.get(name = 'job')] - s1 = create_shift_with_details(shift_1) + shift_1 = ["2016-05-11", "9:00", "15:00", 6, Job.objects.get(name='job')] + created_shift = create_shift_with_details(shift_1) # open Shift Sign Up sign_up_page.navigate_to_sign_up() @@ -172,77 +158,57 @@ def test_shift_sign_up_with_outdated_shifts(self): # on jobs page sign_up_page.click_to_view_shifts() - self.assertEqual(sign_up_page.get_info_box().text,'There are currently no shifts for the job job.') + self.assertEqual(sign_up_page.get_info_box().text, + sign_up_page.get_message_shift_not_available_for_job('job')) def test_shift_sign_up_with_no_slots(self): - - register_event_utility() - register_job_utility() + registered_event = register_event_utility() + registered_job = register_job_utility() sign_up_page = self.sign_up_page # create shift with no slot - shift_2 = ["2016-05-11","9:00","15:00",1,Job.objects.get(name = 'job')] + 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","volunteer2@volunteer.com"] + volunteer_2 = ['volunteer-2', "Sam", "Turtle", "Mario Land", "Nintendo Land", "Nintendo State", + "Nintendo Nation", "2374983247", "volunteer2@volunteer.com"] v2 = create_volunteer_with_details(volunteer_2) # Assign shift to the volunteer - vol_shift = register_volunteer_for_shift_utility(s2, v2) + 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) + self.assertEqual(sign_up_page.get_info_box().text, sign_up_page.no_event_message) def test_search_event(self): - register_event_utility() register_job_utility() register_shift_utility() sign_up_page = self.sign_up_page - # open Shift Sign Up + # Enter date range in which an event starts sign_up_page.navigate_to_sign_up() - - # enter date range in which an event starts - date = ['05/08/2016', '08/31/2017'] + date = ['05/08/2050', '05/31/2050'] sign_up_page.fill_search_form(date) - # verify that the event shows up + # Verify that the event shows up self.assertEqual(sign_up_page.get_event_name(), 'event') - # enter date range in which no event starts - date = ['10/08/2016', '08/31/2017'] - sign_up_page.fill_search_form(date) - # verify that no event shows up on event page - self.assertEqual(sign_up_page.get_info_box().text,sign_up_page.no_event_message) - - # comm - # enter only incorrect starting date - date = ['10/08/2016', ''] - sign_up_page.fill_search_form(date) - # verify that no event shows up on event page - self.assertEqual(sign_up_page.get_info_box().text,sign_up_page.no_event_message) - - # enter only correct starting date - date = ['05/10/2016', ''] - sign_up_page.fill_search_form(date) - # verify that the event shows up - self.assertEqual(sign_up_page.get_event_name() 'event') - - # enter only incorrect ending date - date = ['', '10/08/2015'] + # Enter only correct starting date + sign_up_page.navigate_to_sign_up() + date = ['05/10/2050', ''] sign_up_page.fill_search_form(date) - # verify that no event shows up on event page - self.assertEqual(sign_up_page.get_info_box().text,sign_up_page.no_event_message) + # Verify that the event shows up + self.assertEqual(sign_up_page.get_event_name(), 'event') - # enter correct ending date - date = ['', '06/15/2017'] + # Enter correct ending date + sign_up_page.navigate_to_sign_up() + date = ['', '06/15/2050'] sign_up_page.fill_search_form(date) - # verify that the event shows up + # Verify that the event shows up self.assertEqual(sign_up_page.get_event_name(), 'event') -""" diff --git a/vms/event/tests/test_unit.py b/vms/event/tests/test_unit.py deleted file mode 100644 index c1cc9e208..000000000 --- a/vms/event/tests/test_unit.py +++ /dev/null @@ -1,4 +0,0 @@ -# Django -from django.test import TestCase - -# Create your tests here. diff --git a/vms/pom/locators/eventsPageLocators.py b/vms/pom/locators/eventsPageLocators.py index 3b2f7dba3..d8d5c03fa 100644 --- a/vms/pom/locators/eventsPageLocators.py +++ b/vms/pom/locators/eventsPageLocators.py @@ -1,7 +1,8 @@ class EventsPageLocators(object): - # locators for events, jobs, shifts listed EVENT_NAME = '//table//tbody//tr[1]//td[1]' + EVENT_START_DATE = '//table//tbody//tr[1]//td[2]' + EVENT_END_DATE = '//table//tbody//tr[1]//td[3]' JOB_NAME = '//table//tbody//tr[1]//td[1]' JOB_EVENT = '//table//tbody//tr[1]//td[2]' SHIFT_DATE = '//table//tbody//tr[1]//td[1]' diff --git a/vms/pom/pages/basePage.py b/vms/pom/pages/basePage.py index 44d3b3fb1..25797c6d3 100644 --- a/vms/pom/pages/basePage.py +++ b/vms/pom/pages/basePage.py @@ -1,5 +1,6 @@ class BasePage(object): """Base class to initialize the base page that will be called from all pages""" + ENTER_VALID_VALUE = 'Enter a valid value.' def __init__(self, driver): self.driver = driver diff --git a/vms/pom/pages/eventSignUpPage.py b/vms/pom/pages/eventSignUpPage.py index 89e7c0904..ccbfbe001 100644 --- a/vms/pom/pages/eventSignUpPage.py +++ b/vms/pom/pages/eventSignUpPage.py @@ -7,11 +7,14 @@ class EventSignUpPage(BasePage): no_event_message = 'There are no events.' + live_server_url = '' + SHIFT_UNAVAILABLE_FOR_JOB = 'There are currently no shifts for the job {0}.' def __init__(self, driver): self.driver = driver self.home_page = HomePage(self.driver) self.elements = EventSignUpPageLocators() + super(EventSignUpPage, self).__init__(driver) def submit_form(self): @@ -36,7 +39,10 @@ def get_sign_up(self): return self.element_by_xpath(self.elements.SHIFT_SIGNUP_PATH).text def navigate_to_sign_up(self): - self.home_page.get_shift_signup_link().click() + self.get_page(self.get_sign_up_link(), '') + + def get_sign_up_link(self): + return self.home_page.get_shift_signup_link().get_attribute('href') def fill_search_form(self, date): self.element_by_id(self.elements.START_DATE_FROM).clear() @@ -74,3 +80,6 @@ def get_signed_up_shift_text(self): def get_remaining_slots(self): return self.element_by_xpath(self.elements.SLOTS_REMAINING_PATH).text + + def get_message_shift_not_available_for_job(self, job): + return self.SHIFT_UNAVAILABLE_FOR_JOB.format(job) diff --git a/vms/pom/pages/eventsPage.py b/vms/pom/pages/eventsPage.py index 56cbc33a5..c223e2b92 100644 --- a/vms/pom/pages/eventsPage.py +++ b/vms/pom/pages/eventsPage.py @@ -9,7 +9,6 @@ class EventsPage(BasePage): - event_list_page = PageUrls.event_list_page job_list_page = PageUrls.job_list_page shift_list_page = PageUrls.shift_list_page @@ -21,6 +20,9 @@ class EventsPage(BasePage): shift_tab = 'Shifts' organization_tab = 'Organizations' live_server_url = '' + FIELD_REQUIRED = 'This field is required.' + NO_EVENT_PRESENT = 'There are currently no events. Please create events first.' + START_BEFORE_END = 'Start date must be before the end date' def __init__(self, driver): self.driver = driver @@ -113,6 +115,9 @@ def go_to_create_organization_page(self): def get_deletion_box(self): return self.element_by_class_name(self.elements.DELETION_BOX) + def get_delete_event_element(self, relative): + return self.element_by_xpath(self.elements.DELETE_EVENT + relative) + def get_deletion_context(self): return self.element_by_class_name(self.elements.DELETION_TOPIC).text @@ -122,6 +127,12 @@ def get_message_context(self): def get_event_name(self): return self.element_by_xpath(self.elements.EVENT_NAME).text + def get_event_start_date(self): + return self.element_by_xpath(self.elements.EVENT_START_DATE).text + + def get_event_end_date(self): + return self.element_by_xpath(self.elements.EVENT_END_DATE).text + def get_warning_context(self): return self.element_by_class_name(self.elements.WARNING_CONTEXT).text @@ -177,12 +188,10 @@ def get_shift_start_time_error(self): return self.element_by_xpath(self.elements.SHIFT_START_TIME_ERROR).text def get_shift_end_time_error(self): - return self.driver.find_element_by_xpath( - self.elements.SHIFT_END_TIME_ERROR).text + return self.driver.find_element_by_xpath(self.elements.SHIFT_END_TIME_ERROR).text def get_shift_max_volunteer_error(self): - return self.element_by_xpath( - self.elements.SHIFT_MAX_VOLUNTEER_ERROR).text + return self.element_by_xpath(self.elements.SHIFT_MAX_VOLUNTEER_ERROR).text def get_shift_job(self): return self.element_by_xpath(self.elements.SHIFT_JOB).text @@ -231,3 +240,4 @@ def get_shift_end_time_value(self): def get_shift_max_volunteers(self): return self.get_value_for_xpath(self.elements.CREATE_SHIFT_MAX_VOLUNTEER) + diff --git a/vms/shift/utils.py b/vms/shift/utils.py index 3eba16e46..22f0e3313 100644 --- a/vms/shift/utils.py +++ b/vms/shift/utils.py @@ -12,6 +12,7 @@ from volunteer.models import Volunteer from organization.models import Organization + # Contains common functions which need to be frequently called by tests @@ -173,7 +174,6 @@ def create_country(): def create_admin(): - user_1 = User.objects.create_user(username='admin', password='admin') admin = Administrator.objects.create( @@ -190,7 +190,6 @@ def create_admin(): def create_volunteer(): - user_1 = User.objects.create_user( username='volunteer', password='volunteer') @@ -209,7 +208,7 @@ def create_volunteer(): def register_event_utility(): event = Event.objects.create( - name='event', start_date='2016-05-10', end_date='2018-06-16') + name='event', start_date='2050-05-10', end_date='2050-06-16') return event @@ -217,8 +216,8 @@ def register_event_utility(): def register_job_utility(): job = Job.objects.create( name='job', - start_date='2016-05-10', - end_date='2017-06-15', + start_date='2050-05-10', + end_date='2050-06-15', event=Event.objects.get(name='event')) return job @@ -226,7 +225,7 @@ def register_job_utility(): def register_shift_utility(): shift = Shift.objects.create( - date='2017-06-15', + date='2050-06-15', start_time='09:00', end_time='15:00', max_volunteers='6',