How to use __get_activity method in ATX

Best Python code snippet using ATX

test_manage_schedule.py

Source:test_manage_schedule.py Github

copy

Full Screen

...79 time.sleep(MODAL_TRANSITION_WAIT_TIME)80 super().choose_option_from_select('id_school_period_type', period_profile)81 super().click_modal_save_button()82 time.sleep(PAGE_LOADING_WAIT_TIME)83 def __get_activity(self, portion_type):84 return Activity.objects.get(activity_portion_type=portion_type)85 def __go_to_first_period_lesson_plan(self):86 button = self.browser.find_element_by_class_name('btn-tertiary')87 button.click()88 def __select_lesson_plan_activity_edit(self, id_selector, selection_text):89 if selection_text is not None:90 super().choose_option_from_select(id_selector, selection_text)91 def __edit_lesson_plan(self, greeting, warmup, presentation, practice, production, cooldown, assessment):92 button = self.browser.find_element_by_css_selector('#edit-lesson-plan-button')93 button.click()94 time.sleep(MODAL_TRANSITION_WAIT_TIME)95 self.__select_lesson_plan_activity_edit('id_greeting', greeting)96 self.__select_lesson_plan_activity_edit('id_warmup', warmup)97 self.__select_lesson_plan_activity_edit('id_presentation', presentation)98 self.__select_lesson_plan_activity_edit('id_practice', practice)99 self.__select_lesson_plan_activity_edit('id_production', production)100 self.__select_lesson_plan_activity_edit('id_cooldown', cooldown)101 self.__select_lesson_plan_activity_edit('id_assessment', assessment)102 super().click_modal_save_button()103 time.sleep(PAGE_LOADING_WAIT_TIME)104 def __delete_first_period_class(self):105 button = self.browser.find_element_by_class_name('delete-class-button')106 button.click()107 def __edit_lesson_hour(self, lesson, hour):108 button = self.browser.find_element_by_class_name('edit-lesson-hour-button')109 button.click()110 time.sleep(MODAL_TRANSITION_WAIT_TIME)111 super().type_text_in_input('#id_lesson_number', lesson)112 super().type_text_in_input('#id_hour_number', hour)113 super().click_modal_save_button()114 time.sleep(PAGE_LOADING_WAIT_TIME)115 # Assertions116 def __assert_no_days_scheduled(self):117 content = self.browser.find_element_by_id('paw-main-content').text118 self.assertIn('There are no classes scheduled for the school on this month. Would you like to schedule a new class day?', content)119 def __assert_class_existence(self, section, teacher, lesson):120 content = self.browser.find_element_by_id('paw-main-content').text121 self.assertIn(section, content)122 self.assertIn(teacher, content)123 self.assertIn(lesson, content)124 def __assert_class_inexistence(self, section, teacher, lesson, is_similar_lesson_found=False):125 content = self.browser.find_element_by_id('paw-main-content').text126 self.assertNotIn(section, content)127 self.assertNotIn(teacher, content)128 if not is_similar_lesson_found:129 self.assertNotIn(lesson, content)130 def __assert_class_lesson_plan_existence(self, year_level, section_name, greeting, warmup, presentation, practice, production, cooldown, assessment, hour_number):131 date = datetime.now()132 school_section = SchoolSection.objects.get(133 school=School.objects.get(name='Dolphin Elementary School'),134 year_level=year_level135 )136 section = Section.objects.get(137 school_section=school_section,138 section_name=section_name139 )140 lesson_plan = LessonPlan.objects.filter(141 greeting=greeting,142 warmup=warmup,143 presentation=presentation,144 practice=practice,145 production=production,146 cooldown=cooldown,147 assessment=assessment,148 ).last()149 self.assertTrue(SectionPeriod.objects.get(150 date=date,151 section=section,152 lesson_plan=lesson_plan,153 ))154 def __assert_first_period_profile_value(self, value):155 content = self.browser.find_element_by_class_name('default-profile-marker').text156 self.assertEqual(value, content)157 def __assert_option_is_in_dropdown(self, option, dropdown_selector_id):158 is_in_dropdown = False159 css_selector_option = '#%s > option' % (dropdown_selector_id)160 option_elements = self.browser.find_elements_by_css_selector(css_selector_option)161 for element in option_elements:162 if element.text == option:163 is_in_dropdown = True164 break165 self.assertTrue(is_in_dropdown)166 return is_in_dropdown167 def __assert_all_options_are_in_dropdown(self, options, dropdown_selector_id):168 is_all_in_dropdown = True169 for option in options:170 if not self.__assert_option_is_in_dropdown(option, dropdown_selector_id):171 is_all_in_dropdown = False172 break173 self.assertTrue(is_all_in_dropdown)174 def __assert_class_addition_lesson_plan_dropdown_values(self, year_level, section, expected_values):175 self.__click_add_class_button()176 time.sleep177 if year_level is not None:178 super().choose_option_from_select('id_year_level', year_level)179 if section is not None:180 super().choose_option_from_select('id_section', section)181 self.__assert_all_options_are_in_dropdown(expected_values, 'id_lesson_plan')182 super().click_modal_cancel_button()183 def __assert_period_days(self, datetime_object, expected_day):184 expected_string = "%s %s" % (datetime_object.strftime("%B %d"), expected_day)185 content = self.browser.find_element_by_id('paw-main-content')186 self.assertIn(expected_string, content.text)187 def __assert_lesson_hour_existence(self, lesson, hour):188 self.assertTrue(SectionPeriod.objects.filter(lesson_number=lesson, hour_number=hour).exists())189 def __assert_period_class_next_day(self, year_level, section_name):190 current_date = datetime.now()191 self.__click_add_class_button()192 if year_level is not None:193 super().choose_option_from_select('id_year_level', year_level)194 if section_name is not None:195 super().choose_option_from_select('id_section', section_name)196 modal = self.browser.find_element_by_css_selector('.modal.fade.in')197 self.assertIn('Lesson 1, Hour 1, on %s'%(current_date.strftime("%B %d, %Y")), modal.text)198 # Tests199 # python3 manage.py test schedules.tests.test_manage_schedule.ScheduleManagementTestCases.test_no_school_years_available200 def test_no_school_years_available(self):201 super().go_to_schedules_page()202 super().assert_no_school_years()203 def test_no_schools_available(self):204 super().go_to_schedules_page_with_school_year()205 super().assert_dropdown_enabled('select[name="school-year"]', True)206 super().assert_dropdown_enabled('select[name="school"]', False)207 super().assert_dropdown_enabled('select[name="month"]', True)208 def test_no_class_available(self):209 super().go_to_schedules_page_complete()210 self.__click_view_schedule_button()211 self.__assert_no_days_scheduled()212 def test_add_class_correctly(self):213 super().go_to_schedules_page_with_complete_package()214 self.__click_view_schedule_button()215 self.__add_first_period_class('3', '1', 'Let\'s Try 1, Lesson 1, Hour 1')216 self.__assert_class_existence('3-1', 'Mr. Nogami', 'Lesson 1, Hour 1 (Let\'s Try 1)')217 def test_add_class_no_lesson_plans(self):218 super().go_to_schedules_page_with_scheduled_day()219 self.__click_view_schedule_button()220 self.__add_first_period_class('3', '1', None)221 self.__assert_class_existence('3-1', 'N/A', None)222 def test_add_class_generic_lesson_plans(self):223 super().go_to_schedules_page_with_generic_lesson_plan()224 self.__click_view_schedule_button()225 self.__add_first_period_class('1', '1', 'Animals, Hour 1')226 self.__assert_class_existence('1-1', 'N/A', 'Lesson 1, Hour 1 (Animals)')227 def test_add_class_no_teacher_name(self):228 super().go_to_schedules_page_with_complete_package()229 self.__click_view_schedule_button()230 self.__add_first_period_class('3', '2', 'Let\'s Try 1, Lesson 1, Hour 1')231 self.__assert_class_existence('3-2', 'N/A', 'Lesson 1, Hour 1 (Let\'s Try 1)')232 def test_edit_period_profile(self):233 new_period_profile = 'Monday Schedule'234 super().go_to_schedules_page_with_complete_package()235 self.__click_view_schedule_button()236 self.__change_period_profile(new_period_profile)237 self.__assert_first_period_profile_value(new_period_profile)238 def test_edit_period_profile_with_class(self):239 weekday = datetime.now().weekday() # 0 is Monday, 6 is Saturday240 period_type = NAME_WEDNESDAY_SCHEDULE241 if weekday == 0 or weekday == 2:242 period_type = NAME_NORMAL_SCHEDULE243 super().go_to_schedules_page_with_class()244 self.__click_view_schedule_button()245 self.__change_period_profile(period_type)246 self.__assert_class_inexistence('3-1', 'Mr. Nogami', 'Lesson 1, Hour 1 (Let\'s Try 1)')247 def test_edit_return_period_profile_with_class(self):248 weekday = datetime.now().weekday() # 0 is Monday, 6 is Saturday249 250 old_period_type = NAME_NORMAL_SCHEDULE251 new_period_type = NAME_WEDNESDAY_SCHEDULE252 if weekday == 0:253 old_period_type = NAME_MONDAY_SCHEDULE254 new_period_type = NAME_NORMAL_SCHEDULE255 elif weekday == 2:256 old_period_type = NAME_WEDNESDAY_SCHEDULE257 new_period_type = NAME_NORMAL_SCHEDULE258 super().go_to_schedules_page_with_class()259 super().click_button('view-schedule-button')260 time.sleep(PAGE_LOADING_LONG_WAIT_TIME) # The Edit Period Profile button fails to click if it's not a long wait time261 self.__change_period_profile(new_period_type)262 self.__assert_class_inexistence('3-1', 'Mr. Nogami', 'Lesson 1, Hour 1 (Let\'s Try 1)')263 self.__change_period_profile(old_period_type)264 self.__assert_class_existence('3-1', 'Mr. Nogami', 'Lesson 1, Hour 1 (Let\'s Try 1)')265 # Have 5-1 and 4-1 on a specific day. Add 5-2: "Same as 5-1" should be there, but not "Same as "4-1"266 def test_same_lesson_plan_dropdown(self):267 expected_values_5_2 = ['None', 'Same as 5-1, Lesson 1, Hour 1 (Let\'s Try 1)']268 expected_values_4_2 = ['None', 'Same as 4-1, Lesson 1, Hour 1 (Let\'s Try 1)']269 super().go_to_schedules_page_with_complete_package()270 self.__add_elementary_school_class(year_level=5, section=1, period_number=1)271 self.__add_elementary_school_class(year_level=4, section=1, period_number=2)272 self.__click_view_schedule_button()273 self.__assert_class_addition_lesson_plan_dropdown_values(year_level='5', section='2', expected_values=expected_values_5_2)274 self.__assert_class_addition_lesson_plan_dropdown_values(year_level='4', section='2', expected_values=expected_values_4_2)275 def test_same_lesson_plan(self):276 super().go_to_schedules_page_with_complete_package()277 self.__add_elementary_school_class(year_level=5, section=1, period_number=2)278 self.__click_view_schedule_button()279 self.__add_first_period_class('5', '2', 'Same as 5-1, Lesson 1, Hour 1 (Let\'s Try 1)')280 self.__assert_class_lesson_plan_existence(281 year_level=5,282 section_name='2',283 greeting=self.__get_activity(GREETING),284 warmup=self.__get_activity(WARMUP),285 presentation=self.__get_activity(PRESENTATION),286 practice=self.__get_activity(PRACTICE),287 production=self.__get_activity(PRODUCTION),288 cooldown=self.__get_activity(COOLDOWN),289 assessment=self.__get_activity(ASSESSMENT),290 hour_number=1,291 )292 def test_same_lesson_plan_change_child_lsp(self):293 greeting = 'Hello Song'294 warmup = 'Rainbow Song'295 presentation_5_2 = 'None'296 presentation_5_1 = 'Vocabulary Drilling'297 practice = 'Keyword Game'298 production = 'Interview Game'299 cooldown = 'Signature Count'300 assessment = 'Vocabulary Volunteer'301 super().go_to_schedules_page_with_complete_package()302 self.__add_elementary_school_class(year_level=5, section=1, period_number=2)303 self.__click_view_schedule_button()304 self.__add_first_period_class('5', '2', 'Same as 5-1, Lesson 1, Hour 1 (Let\'s Try 1)')305 self.__go_to_first_period_lesson_plan()306 self.__edit_lesson_plan(307 greeting=None, 308 warmup=None, 309 presentation=presentation_5_2, 310 practice=None, 311 production=None, 312 cooldown=None, 313 assessment=None)314 self.__assert_class_lesson_plan_existence(315 year_level=5,316 section_name='2',317 greeting=self.__get_activity(GREETING),318 warmup=self.__get_activity(WARMUP),319 presentation=None,320 practice=self.__get_activity(PRACTICE),321 production=self.__get_activity(PRODUCTION),322 cooldown=self.__get_activity(COOLDOWN),323 assessment=self.__get_activity(ASSESSMENT),324 hour_number=1,325 )326 self.__assert_class_lesson_plan_existence(327 year_level=5,328 section_name='1',329 greeting=self.__get_activity(GREETING),330 warmup=self.__get_activity(WARMUP),331 presentation=self.__get_activity(PRESENTATION),332 practice=self.__get_activity(PRACTICE),333 production=self.__get_activity(PRODUCTION),334 cooldown=self.__get_activity(COOLDOWN),335 assessment=self.__get_activity(ASSESSMENT),336 hour_number=1,337 )338 def test_same_lesson_plan_change_parent_lsp(self):339 greeting = 'Hello Song'340 warmup = 'Rainbow Song'341 presentation_5_1 = 'None'342 presentation_5_2 = 'Vocabulary Drilling'343 practice = 'Keyword Game'344 production = 'Interview Game'345 cooldown = 'Signature Count'346 assessment = 'Vocabulary Volunteer'347 super().go_to_schedules_page_with_complete_package()348 self.__add_elementary_school_class(year_level=5, section=1, period_number=1)349 self.__click_view_schedule_button()350 self.__add_first_period_class('5', '2', 'Same as 5-1, Lesson 1, Hour 1 (Let\'s Try 1)')351 self.__go_to_first_period_lesson_plan()352 self.__edit_lesson_plan(353 greeting=None, 354 warmup=None, 355 presentation=presentation_5_1,356 practice=None, 357 production=None, 358 cooldown=None, 359 assessment=None)360 self.__assert_class_lesson_plan_existence(361 year_level=5,362 section_name='1',363 greeting=self.__get_activity(GREETING),364 warmup=self.__get_activity(WARMUP),365 presentation=None,366 practice=self.__get_activity(PRACTICE),367 production=self.__get_activity(PRODUCTION),368 cooldown=self.__get_activity(COOLDOWN),369 assessment=self.__get_activity(ASSESSMENT),370 hour_number=1,371 )372 self.__assert_class_lesson_plan_existence(373 year_level=5,374 section_name='2',375 greeting=self.__get_activity(GREETING),376 warmup=self.__get_activity(WARMUP),377 presentation=self.__get_activity(PRESENTATION),378 practice=self.__get_activity(PRACTICE),379 production=self.__get_activity(PRODUCTION),380 cooldown=self.__get_activity(COOLDOWN),381 assessment=self.__get_activity(ASSESSMENT),382 hour_number=1,383 )384 def test_delete_class(self):385 super().go_to_schedules_page_with_complete_package()386 self.__add_elementary_school_class(year_level=3, section=1, period_number=1)387 self.__click_view_schedule_button()388 self.__add_first_period_class('3', '2', 'Same as 3-1, Lesson 1, Hour 1 (Let\'s Try 1)')389 self.__assert_class_existence('3-1', 'Mr. Nogami', 'Lesson 1, Hour 1 (Let\'s Try 1)')390 self.__assert_class_existence('3-2', 'N/A', 'Lesson 1, Hour 1 (Let\'s Try 1)')391 self.__delete_first_period_class()392 self.__assert_class_inexistence('3-1', 'Mr. Nogami', 'Lesson 1, Hour 1 (Let\'s Try 1)', is_similar_lesson_found=True)393 self.__assert_class_existence('3-2', 'N/A', 'Lesson 1, Hour 1 (Let\'s Try 1)')394 def test_view_schedule(self):395 super().go_to_schedules_page_with_complete_package()...

Full Screen

Full Screen

sample_manager.py

Source:sample_manager.py Github

copy

Full Screen

1#!/usr/bin/env python3.72from pkg_resources import resource_filename3class SampleManager:4 @staticmethod5 def __get_activity(file_path):6 file_path = resource_filename(__name__, file_path)7 with open(file_path, 'r') as f:8 return f.read()9 @staticmethod10 def get_access_file_activity():11 return SampleManager.__get_activity("file_access.xml")12 @staticmethod13 def get_added_file_activity():14 return SampleManager.__get_activity("file_added.xml")15 @staticmethod16 def get_changed_file_activity():17 return SampleManager.__get_activity("file_changed.xml")18 @staticmethod19 def get_deleted_file_activity():20 return SampleManager.__get_activity("file_deleted.xml")21 @staticmethod22 def get_moved_file_activity():23 return SampleManager.__get_activity("file_moved.xml")24 @staticmethod25 def get_renamed_file_activity():26 return SampleManager.__get_activity("file_renamed.xml")27 @staticmethod28 def get_restored_file_activity():...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run ATX automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful