本文整理汇总了Python中shift.utils.create_event_with_details函数的典型用法代码示例。如果您正苦于以下问题:Python create_event_with_details函数的具体用法?Python create_event_with_details怎么用?Python create_event_with_details使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了create_event_with_details函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_event_job_field
def test_event_job_field(self):
"""
Test search results for event job field
"""
search_page = self.search_page
search_page.live_server_url = self.live_server_url
credentials_1 = ['event-name', '2015-01-01', '2015-03-01']
event_1 = create_event_with_details(credentials_1)
credentials_2 = [
'event-nameq', '2015-02-01', '2015-04-01']
event_2 = create_event_with_details(credentials_2)
expected_result_one = ['event-name', 'Jan.', '1,', '2015', 'March', '1,', '2015', 'Details', 'Edit', 'Delete']
expected_result_two = ['event-nameq', 'Feb.', '1,', '2015', 'April', '1,', '2015', 'Details', 'Edit', 'Delete']
# job_1 for event_1, job_2 for event_2
job = ['job-name', '2015-02-01', '2015-02-15', 'job-description', event_1]
job_1 = create_job_with_details(job)
job = ['job-nameq', '2015-02-02', '2015-02-15', 'job-descriptionq', event_2]
job_2 = create_job_with_details(job)
# search job_1 and job_2
search_page.navigate_to_event_search_page()
search_page.search_job_field("job-name")
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)
示例2: setUp
def setUp(self):
event = ['event', '2015-02-05', '2015-05-05']
self.event_1 = create_event_with_details(event)
self.event_1.city = 'city'
self.event_1.state = 'state'
self.event_1.country = 'country'
self.event_1.address = 'address'
self.event_1.venue = 'venue'
self.event_1.save()
self.expected_result_one = {'event_name': 'event',
'start_date': '2015-02-05',
'end_date': '2015-05-05',
'address': 'address',
'city': 'city',
'state': 'state',
'country': 'country',
'venue': 'venue'}
event = ['eventq', '2050-02-05', '2050-05-05']
self.event_2 = create_event_with_details(event)
self.event_2.city = 'cityq'
self.event_2.state = 'stateq'
self.event_2.country = 'countryq'
self.event_2.address = 'addressq'
self.event_2.venue = 'venueq'
self.event_2.save()
self.expected_result_two = {'event_name': 'eventq',
'start_date': '2050-02-05',
'end_date': '2050-05-05',
'address': 'addressq',
'city': 'cityq',
'state': 'stateq',
'country': 'countryq',
'venue': 'venueq'}
示例3: test_event_city_field
def test_event_city_field(self):
"""
Test search results for event city
"""
search_page = self.search_page
search_page.live_server_url = self.live_server_url
search_page.navigate_to_event_search_page()
credentials_1 = ['event-name', '2015-01-01', '2015-03-01']
event_1 = create_event_with_details(credentials_1)
event_1.city = 'event-city'
event_1.save()
credentials_2 = [
'event-nameq', '2015-02-01', '2015-04-01']
event_2 = create_event_with_details(credentials_2)
event_2.city = 'event-cityq'
event_2.save()
expected_result_one = ['event-name', 'Jan.', '1,', '2015', 'March', '1,', '2015', 'Details', 'Edit', 'Delete']
expected_result_two = ['event-nameq', 'Feb.', '1,', '2015', 'April', '1,', '2015', 'Details', 'Edit', 'Delete']
search_page.search_city_field('event')
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_city_field('e')
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_city_field('eve-')
search_page.submit_form()
self.assertRaisesRegexp(NoSuchElementException,
'Unable to locate element: //table//tbody',
search_page.get_search_results)
search_page.search_city_field('event-fail-test')
search_page.submit_form()
self.assertRaisesRegexp(NoSuchElementException,
'Unable to locate element: //table//tbody',
search_page.get_search_results)
search_page.search_city_field('[email protected]#$%^&*()_')
search_page.submit_form()
self.assertNotEqual(search_page.get_help_block(), None)
示例4: test_create_job_with_invalid_event_date
def test_create_job_with_invalid_event_date(self):
# register event first to create job
event = ['event-name', '2050-08-21', '2050-09-28']
create_event_with_details(event)
self.settings.go_to_events_page()
settings = self.settings
settings.live_server_url = self.live_server_url
# create job with start date outside range
job = ['event-name', 'job name', 'job description', '08/10/2050', '09/11/2050']
settings.navigate_to_job_list_view()
settings.go_to_create_job_page()
settings.fill_job_form(job)
# check job not created and proper error message displayed
self.assertNotEqual(self.driver.current_url, self.live_server_url + settings.job_list_page)
self.assertEqual(settings.get_warning_context(), 'Job dates should lie within Event dates')
# create job with end date outside range
job = ['event-name', 'job name', 'job description', '08/30/2050', '09/29/2050']
settings.navigate_to_job_list_view()
settings.go_to_create_job_page()
settings.fill_job_form(job)
# check job not created and proper error message displayed
self.assertNotEqual(self.driver.current_url, self.live_server_url + settings.job_list_page)
self.assertEqual(settings.get_warning_context(), 'Job dates should lie within Event dates')
示例5: setUpModule
def setUpModule():
"""
- Creates objects which can be reused by multiple test classes
- Creates jobs that can be used later for shift creation
"""
global e1, e2, j1, j2, j3
event_1 = ["Software Conference", "2012-10-3", "2012-11-25"]
event_2 = ["Django Conference", "2012-10-13", "2012-11-25"]
e1 = create_event_with_details(event_1)
e2 = create_event_with_details(event_2)
job_1 = [
"Software Developer", "2012-10-22", "2012-10-25", "A software job", e1
]
job_2 = [
"Systems Administrator", "2012-10-8", "2012-10-16",
"A systems administrator job", e1
]
job_3 = [
"Project Manager", "2012-11-2", "2012-11-12", "A management job", e1
]
j1 = create_job_with_details(job_1)
j2 = create_job_with_details(job_2)
j3 = create_job_with_details(job_3)
示例6: test_intersection_of_all_fields
def test_intersection_of_all_fields(self):
"""
Test search results for different combinations of event name, start date, end date, city, state, country and job
"""
search_page = self.search_page
search_page.live_server_url = self.live_server_url
credentials_1 = ['event-name', '2015-01-01', '2015-03-01']
event_1 = create_event_with_details(credentials_1)
event_1.country = 'event-country'
event_1.state = 'event-state'
event_1.city = 'event-city'
event_1.save()
job = ['job', '2015-02-01', '2015-02-15', 'descriptionq', event_1]
job_1 = create_job_with_details(job)
credentials_2 = [
'event-nameq', '2015-02-01', '2015-04-01']
event_2 = create_event_with_details(credentials_2)
event_2.country = 'event-countryq'
event_2.state = 'event-stateq'
event_2.city = 'event-cityq'
event_2.save()
job = ['jobq', '2015-02-02', '2015-02-15', 'job-description', event_2]
job_2 = create_job_with_details(job)
expected_result_one = ['event-name', 'Jan.', '1,', '2015', 'March', '1,', '2015', 'Details', 'Edit', 'Delete']
expected_result_two = ['event-nameq', 'Feb.', '1,', '2015', 'April', '1,', '2015', 'Details', 'Edit', 'Delete']
search_page.navigate_to_event_search_page()
search_page.search_name_field('event')
search_page.search_start_date_field('2015-01-01')
search_page.search_end_date_field('2015-04-01')
search_page.search_state_field('event')
search_page.search_country_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.assertTrue(expected_result_one in result)
self.assertTrue(expected_result_two in result)
search_page.search_name_field('event')
search_page.search_country_field('wrong-country')
search_page.search_job_field(job_1.id)
search_page.submit_form()
self.assertRaisesRegexp(NoSuchElementException,
'Unable to locate element: //table//tbody',
search_page.get_search_results)
search_page.search_state_field('event')
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)
示例7: test_event_start_and_end_date_field
def test_event_start_and_end_date_field(self):
"""
Test search results for event start date and end date
"""
search_page = self.search_page
search_page.live_server_url = self.live_server_url
search_page.navigate_to_event_search_page()
credentials_1 = [
'event-name', '2015-01-01', '2015-03-01'
]
event_1 = create_event_with_details(credentials_1)
credentials_2 = [
'event-nameq', '2015-02-01', '2015-04-01'
]
event_2 = create_event_with_details(credentials_2)
expected_result_one = ['event-name', 'Jan.', '1,', '2015', 'March', '1,', '2015', 'Details', 'Edit', 'Delete']
expected_result_two = ['event-nameq', 'Feb.', '1,', '2015', 'April', '1,', '2015', 'Details', 'Edit', 'Delete']
# search for events filling only start date
search_page.search_start_date_field('12/01/2015')
search_page.submit_form()
self.assertRaisesRegexp(NoSuchElementException,
'Unable to locate element: //table//tbody',
search_page.get_search_results)
# search filling end date only
search_page.navigate_to_event_search_page()
search_page.search_end_date_field('02/15/2015')
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_two in result)
self.assertTrue(expected_result_one in result)
# search filling both start and end date
search_page.navigate_to_event_search_page()
search_page.search_start_date_field('01/01/2015')
search_page.search_end_date_field('01/15/2015')
search_page.submit_form()
search_results = search_page.get_search_results()
result = search_page.get_results_list(search_results)
self.assertEqual(len(result), 1)
self.assertTrue(expected_result_one in result)
示例8: setUpModule
def setUpModule():
"""
Creates events, jobs and shifts which can be reused by multiple test classes
"""
global e1, e2, e3, e4, e5
global j1, j2, j3, j4, j5
global s1, s2, s3, s4
event_1 = ["Open Source Event", "2012-10-22", "2012-10-23"]
event_2 = ["Python Event", "2013-11-12", "2013-11-13"]
event_3 = ["Django Event", "2015-07-02", "2015-07-03"]
event_4 = ["Systers Event", "2015-07-25", "2015-08-08"]
event_5 = ["Anita Borg Event", "2015-07-07", "2015-07-08"]
e1 = create_event_with_details(event_1)
e2 = create_event_with_details(event_2)
e3 = create_event_with_details(event_3)
e4 = create_event_with_details(event_4)
e5 = create_event_with_details(event_5)
job_1 = [
"Software Developer", "2012-10-22", "2012-10-23", "A software job", e1
]
job_2 = [
"Systems Administrator", "2013-11-12", "2013-11-13",
"A systems administrator job", e2
]
job_3 = [
"Backend Dev", "2012-10-8", "2012-10-16", "A java developer job", e4
]
job_4 = ["Instructor", "2012-10-22", "2012-10-23", "", e4]
job_5 = ["Instructor", "2012-10-22", "2012-10-23", "", e3]
j1 = create_job_with_details(job_1)
j2 = create_job_with_details(job_2)
j3 = create_job_with_details(job_3)
j4 = create_job_with_details(job_4)
j5 = create_job_with_details(job_5)
# shifts with limited, plenty and no slots
shift_1 = ["2012-10-23", "9:00", "15:00", 1, j1]
shift_2 = ["2012-10-23", "10:00", "16:00", 2, j1]
shift_3 = ["2013-11-12", "12:00", "18:00", 4, j2]
shift_4 = ["2013-10-23", "10:00", "18:00", 1, j4]
s1 = create_shift_with_details(shift_1)
s2 = create_shift_with_details(shift_2)
s3 = create_shift_with_details(shift_3)
s4 = create_shift_with_details(shift_4)
示例9: test_edit_job_with_invalid_shift_date
def test_edit_job_with_invalid_shift_date(self):
# register event first to create job
event = ['event-name', '2017-08-21', '2017-09-28']
created_event = create_event_with_details(event)
# create job
job = ['job', '2017-08-21', '2017-08-21', '',created_event]
created_job = create_job_with_details(job)
# create shift
shift = ['2017-08-21', '09:00', '12:00', '10', created_job]
created_shift = create_shift_with_details(shift)
settings = self.settings
settings.live_server_url = self.live_server_url
settings.navigate_to_job_list_view()
invalid_job_one = ['event-name','changed job name','job description',
'2017-09-01', '2017-09-11']
# edit job with date range such that the shift start date no longer
# falls in the range
settings.go_to_edit_job_page()
settings.fill_job_form(invalid_job_one)
# check job not edited and proper error message displayed
self.assertNotEqual(self.driver.current_url,
self.live_server_url +settings.job_list_page)
self.assertEqual(settings.get_template_error_message(),
'You cannot edit this job as 1 associated shift no longer lies within the new date range')
# database check to ensure that job not edited
self.assertEqual(len(Job.objects.all()), 1)
self.assertNotEqual(len(Job.objects.filter(name=created_job.name)), 0)
示例10: test_edit_job
def test_edit_job(self):
# register event first to create job
event = ['event-name', '2017-08-21', '2017-09-28']
created_event = create_event_with_details(event)
# create job
job = ['job', '2017-08-21', '2017-08-21', '',created_event]
created_job = create_job_with_details(job)
settings = self.settings
settings.live_server_url = self.live_server_url
edit_job = ['event-name','changed job name','job description',
'2017-08-25', '2017-08-25']
settings.navigate_to_job_list_view()
settings.go_to_edit_job_page()
settings.fill_job_form(edit_job)
# check job edited
self.assertEqual(self.driver.current_url,
self.live_server_url + settings.job_list_page)
self.assertEqual(settings.get_job_name(), 'changed job name')
# database check to ensure that job edited correctly
self.assertEqual(len(Job.objects.all()), 1)
self.assertNotEqual(len(Job.objects.filter(name=edit_job[1])), 0)
示例11: test_delete_event_with_associated_job
def test_delete_event_with_associated_job(self):
event = ['event-name', '2017-08-21', '2017-09-28']
created_event = create_event_with_details(event)
# create job
job = ['job', '2017-08-21', '2017-08-21', '',created_event]
created_job = create_job_with_details(job)
settings = self.settings
settings.live_server_url = self.live_server_url
# check event created
settings.navigate_to_event_list_view()
self.assertEqual(settings.get_event_name(), created_event.name)
# delete event
self.delete_event_from_list()
self.assertNotEqual(settings.get_danger_message(), None)
self.assertEqual(settings.get_template_error_message(),
'You cannot delete an event that a job is currently associated with.')
# check event NOT deleted
settings.navigate_to_event_list_view()
self.assertEqual(settings.get_event_name(), 'event-name')
# database check to ensure that event is not deleted
self.assertEqual(len(Event.objects.all()), 1)
self.assertNotEqual(len(Event.objects.filter(name = created_event.name)), 0)
示例12: test_edit_event_with_invalid_job_date
def test_edit_event_with_invalid_job_date(self):
event = ['event-name', '2017-08-21', '2017-09-28']
created_event = create_event_with_details(event)
# create job
job = ['job', '2017-08-21', '2017-08-21', '',created_event]
created_job = create_job_with_details(job)
settings = self.settings
settings.live_server_url = self.live_server_url
settings.navigate_to_event_list_view()
self.assertEqual(settings.get_event_name(), created_event.name)
settings.go_to_edit_event_page()
# Edit event such that job is no longer in the new date range
new_event = ['new-event-name', '2017-08-30', '2017-09-21']
settings.fill_event_form(new_event)
# check event not edited and error message displayed
self.assertNotEqual(self.driver.current_url,
self.live_server_url + settings.event_list_page)
self.assertEqual(
settings.element_by_xpath(self.elements.TEMPLATE_ERROR_MESSAGE).text,
'You cannot edit this event as the following associated job no longer lies within the new date range :')
# database check to ensure that event not edited
self.assertEqual(len(Event.objects.all()), 1)
self.assertEqual(len(Event.objects.filter(name=new_event[0])), 0)
示例13: test_field_value_retention_for_event
def test_field_value_retention_for_event(self):
settings = self.settings
settings.live_server_url = self.live_server_url
settings.navigate_to_event_list_view()
settings.go_to_create_event_page()
invalid_event = ['[email protected]', '07/21/2016', '09/28/2017']
settings.fill_event_form(invalid_event)
# verify that event was not created and that field values are not
# erased
self.assertEqual(self.driver.current_url, self.live_server_url +
settings.create_event_page)
self.check_event_form_values(invalid_event)
# database check to ensure that event not created
self.assertEqual(len(Event.objects.all()), 0)
# now create an event and edit it
# verify that event was not edited and that field values are not
# erased
event = ['event-name', '2017-08-21', '2017-09-28']
created_event = create_event_with_details(event)
settings.navigate_to_event_list_view()
settings.go_to_edit_event_page()
settings.fill_event_form(invalid_event)
self.assertNotEqual(self.driver.current_url, self.live_server_url +
settings.create_event_page)
# self.check_event_form_values(invalid_event)
# database check to ensure that event not edited
self.assertEqual(len(Event.objects.all()), 1)
self.assertEqual(len(Event.objects.filter(name=invalid_event[0])), 0)
示例14: test_edit_shift_with_invalid_date
def test_edit_shift_with_invalid_date(self):
# register event first to create job
event = ['event-name', '2017-08-21', '2017-09-28']
created_event = create_event_with_details(event)
# create job
job = ['job', '2017-08-21', '2017-08-30', '',created_event]
created_job = create_job_with_details(job)
# create shift
shift = ['2017-08-21', '09:00', '12:00', '10', created_job]
created_shift = create_shift_with_details(shift)
settings = self.settings
settings.live_server_url = self.live_server_url
settings.navigate_to_shift_list_view()
settings.go_to_edit_shift_page()
# edit shift with date not between job dates
invalid_shift = ['02/05/2017', '04:00', '13:00', '2']
settings.fill_shift_form(invalid_shift)
# verify that shift was not edited and error message displayed
self.assertEqual(settings.get_warning_context(),
'Shift date should lie within Job dates')
# database check to ensure that shift was not edited
self.assertEqual(len(Shift.objects.all()), 1)
self.assertNotEqual(len(Shift.objects.filter(date=created_shift.date)), 0)
示例15: test_create_shift
def test_create_shift(self):
# register event first to create job
event = ['event-name', '2017-08-21', '2017-09-28']
created_event = create_event_with_details(event)
# create job
job = ['job', '2017-08-21', '2017-08-30', '',created_event]
created_job = create_job_with_details(job)
settings = self.settings
settings.live_server_url = self.live_server_url
# create shift
settings.navigate_to_shift_list_view()
settings.go_to_create_shift_page()
shift = ['08/30/2017', '09:00', '12:00', '10']
settings.fill_shift_form(shift)
# verify that shift was created
self.assertNotEqual(settings.get_results(), None)
with self.assertRaises(NoSuchElementException):
settings.get_help_block()
# database check to ensure that shift created with proper job
self.assertEqual(len(Shift.objects.all()), 1)
self.assertNotEqual(len(Shift.objects.filter(job=created_job)), 0)