How to use control_get method in autotest

Best Python code snippet using autotest_python

views.py

Source: views.py Github

copy

Full Screen

...31@AppRoute(routes=routes, url='/​create-course/​')32class CreateCourse(PostGetView):33 template_name = 'create_course.html'34 category_id = -135 def control_get(self, params):36 id = params['id']37 category = MapperRegistry.get_current_mapper('category').find_by_id(id)38 params['category_name'] = category.name39 return params40 def control_post(self, data: dict):41 if data['name']:42 name = data['name']43 else:44 name = f'some course'45 name = site.decode_value(name)46 splitter = '~'47 if splitter in name:48 print('WRONG NAME')49 return50 type_ = data['type_']51 self.category_id = self.local_data['id']52 if self.category_id != -1:53 category = MapperRegistry.get_current_mapper('category').\54 find_by_id(int(self.category_id))55 course = site.create_course(type_, name, category.id)56 course.observers.append(email_notifier)57 course.observers.append(sms_notifier)58 category.courses.append(course)59 course.mark_new()60 UnitOfWork.get_current().commit()61@AppRoute(routes=routes, url='/​courses-list/​')62class CoursesList(PostGetView):63 template_name = 'course_list.html'64 def control_get(self, params):65 category_id = params['id']66 category = MapperRegistry.get_current_mapper('category').find_by_id(category_id)67 params['category_name'] = category.name68 mapper = MapperRegistry.get_current_mapper('course')69 params['objects_list'] = mapper.find_by_category_id(category_id)70 return params71class NotFound404:72 def __call__(self, request):73 return '404 WHAT', render('404.html')74@AppRoute(routes=routes, url='/​create-category/​')75class CreateCategory(PostGetView):76 template_name = 'create_category.html'77 def control_get(self, params):78 # заглушка. Пока нет реализации подкатегорий79 params = {'category_id': '0'}80 return params81 def control_post(self, data: dict):82 if data['name']:83 name = data['name']84 else:85 name = 'some category'86 name = site.decode_value(name)87 print('----------', self.local_data)88 category_id = int(self.local_data['category_id'])89 if category_id != 0:90 category = MapperRegistry.get_current_mapper('category').find_by_id(category_id)91 else:92 category = None93 new_category = site.create_category(name, category)94 site.categories.append(new_category)95 new_category.mark_new()96 UnitOfWork.get_current().commit()97@AppRoute(routes=routes, url='/​category-list/​')98class CategoryList(PostGetView):99 template_name = 'category_list.html'100 def control_get(self, params):101 mapper = MapperRegistry.get_current_mapper('category')102 params['objects_list'] = mapper.all()103 for item in params['objects_list']:104 courses = MapperRegistry.get_current_mapper('course').find_by_category_id(item.id)105 for course in courses:106 item.courses.append(course)107 return params108@AppRoute(routes=routes, url='/​student-list/​')109class StudentListView(ListView):110 template_name = 'student_list.html'111 def get_queryset(self):112 mapper = MapperRegistry.get_current_mapper('student')113 return mapper.all()114@AppRoute(routes=routes, url='/​create-student/​')...

Full Screen

Full Screen

agent_pool.py

Source: agent_pool.py Github

copy

Full Screen

...83 print('检测模块出错!!!')848586class Controller(object):87 def control_get(self):88 # 获取功能:爬取代理网站,将代理存储到redis89 getter = Getter()90 while True:91 try:92 getter.run()93 except:94 print(traceback.format_exc())95 time.sleep(30)9697 def control_test(self):98 # 检测功能,检测redis中的代理是否可用99 tester = Tester(test_url='http:/​/​www.baidu.com')100 while True:101 try: ...

Full Screen

Full Screen

main.py

Source: main.py Github

copy

Full Screen

...8class Controller(object):9 """10 获取功能:爬取代理网站,将代理存储到redis11 """12 def control_get(self):13 getter = Getter()14 while True:15 getter.run()16 time.sleep(20)17 """18 检测功能,检测redis中的代理是否可用19 """20 def control_test(self):21 tester = Tester()22 while True:23 tester.run()24 time.sleep(20)25 def run(self):26 print('代理池开始运行了......')...

Full Screen

Full Screen

Blogs

Check out the latest blogs from LambdaTest on this topic:

Scala Testing: A Comprehensive Guide

Before we discuss Scala testing, let us understand the fundamentals of Scala and how this programming language is a preferred choice for your development requirements.The popularity and usage of Scala are rapidly rising, evident by the ever-increasing open positions for Scala developers.

What Agile Testing (Actually) Is

So, now that the first installment of this two fold article has been published (hence you might have an idea of what Agile Testing is not in my opinion), I’ve started feeling the pressure to explain what Agile Testing actually means to me.

How To Choose The Right Mobile App Testing Tools

Did you know that according to Statista, the number of smartphone users will reach 18.22 billion by 2025? Let’s face it, digital transformation is skyrocketing and will continue to do so. This swamps the mobile app development market with various options and gives rise to the need for the best mobile app testing tools

A Complete Guide To CSS Houdini

As a developer, checking the cross browser compatibility of your CSS properties is of utmost importance when building your website. I have often found myself excited to use a CSS feature only to discover that it’s still not supported on all browsers. Even if it is supported, the feature might be experimental and not work consistently across all browsers. Ask any front-end developer about using a CSS feature whose support is still in the experimental phase in most prominent web browsers. ????

Appium Testing Tutorial For Mobile Applications

The count of mobile users is on a steep rise. According to the research, by 2025, it is expected to reach 7.49 billion users worldwide. 70% of all US digital media time comes from mobile apps, and to your surprise, the average smartphone owner uses ten apps per day and 30 apps each month.

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 autotest 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