Best Python code snippet using robotframework-appiumlibrary_python
lesson7_step11.py
Source:lesson7_step11.py
1"""Ðодвиг 10 (на повÑоÑение). ÐбÑÑвиÑе клаÑÑ AppStore - инÑеÑнеÑ-магазин пÑиложений Ð´Ð»Ñ ÑÑÑÑойÑÑв под iOS. Ð ÑÑом клаÑÑе2Ð´Ð¾Ð»Ð¶Ð½Ñ Ð±ÑÑÑ ÑÐµÐ°Ð»Ð¸Ð·Ð¾Ð²Ð°Ð½Ñ ÑледÑÑÑие меÑодÑ:3add_application(self, app) - добавление нового пÑÐ¸Ð»Ð¾Ð¶ÐµÐ½Ð¸Ñ app в магазин;4remove_application(self, app) - Ñдаление пÑÐ¸Ð»Ð¾Ð¶ÐµÐ½Ð¸Ñ app из магазина;5block_application(self, app) - блокиÑовка пÑÐ¸Ð»Ð¾Ð¶ÐµÐ½Ð¸Ñ app (ÑÑÑÐ°Ð½Ð°Ð²Ð»Ð¸Ð²Ð°ÐµÑ Ð»Ð¾ÐºÐ°Ð»Ñное ÑвойÑÑво blocked обÑекÑа app в6знаÑение True);7total_apps(self) - возвÑаÑÐ°ÐµÑ Ð¾Ð±Ñее ÑиÑло пÑиложений в магазине.8ÐлаÑÑ AppStore пÑедполагаеÑÑÑ Ð¸ÑполÑзоваÑÑ ÑледÑÑÑим обÑазом (ÑÑи ÑÑÑоÑки в пÑогÑамме не пиÑаÑÑ):9store = AppStore()10app_youtube = Application("Youtube")11store.add_application(app_youtube)12store.remove_application(app_youtube)13ÐдеÑÑ Application - клаÑÑ, опиÑÑваÑÑий добавлÑемое пÑиложение Ñ ÑказаннÑм именем. ÐаждÑй обÑÐµÐºÑ ÐºÐ»Ð°ÑÑа Application14должен ÑодеÑжаÑÑ Ð»Ð¾ÐºÐ°Ð»ÑнÑе ÑвойÑÑва:15name - наименование пÑÐ¸Ð»Ð¾Ð¶ÐµÐ½Ð¸Ñ (ÑÑÑока);16blocked - бÑлево знаÑение (True - пÑиложение заблокиÑовано; False - не заблокиÑовано, изнаÑалÑно False).17Ðак Ñ
ÑаниÑÑ ÑпиÑок пÑиложений в обÑекÑаÑ
клаÑÑа AppStore ÑеÑиÑе Ñами."""18class AppStore:19 def __init__(self):20 self.apps = {}21 def add_application(self, app):22 self.apps[id(app)] = app23 def remove_application(self, app):24 self.apps.pop(id(app))25 def block_application(self, app):26 obj = self.apps.get(id(app), False)27 if not obj:28 return False29 obj.blocked = True30 return True31 def total_apps(self):32 return len(self.apps)33class Application:34 def __init__(self, name):35 self.name = name36 self.blocked = False37"""class AppStore:38 def __init__(self):39 self.apps = []40 def add_application(self, app):41 self.apps.append(app)42 def remove_application(self, app):43 self.apps.remove(app)44 @staticmethod45 def block_application(app):46 app.blocked = True47 def total_apps(self):...
urls.py
Source:urls.py
1from django.conf.urls import url, include2from django.contrib.auth.decorators import user_passes_test3from profiles.forms import MyAuthenticationForm4from profiles.views import ApplicationListView, ApplicationListAll5from . import views6from django.contrib.auth import views as auth_views7from ajax_select import urls as ajax_select_urls8urlpatterns = [9 url(r'register/$', views.register_user, name="register"),10 url(r'update/$', views.update_profile, name="update"),11 url(r'set_institute/$', views.set_institute, name="set_institute"),12 url(r'^login/$', auth_views.login, {'authentication_form': MyAuthenticationForm}, name='login', ),13 url(r'^logout/$', auth_views.logout, {'next_page': '/'}, name='logout'),14 url(r'^ajax_select/', include(ajax_select_urls)),15 url(r'^change_password/$', views.change_password, name='password_change'),16 url(r'^courses/$', views.saved_courses, name='saved_courses'),17 url(r'^save_courses/$', views.save_courses, name='save_courses'),18 url(r'^save_home_course/$', views.save_home_course, name='save_home_course'),19 url(r'^remove_course/$', views.remove_course, name='remove_course'),20 url(r'^remove_course_match/$', views.remove_course_match, name='remove_course_match'),21 url(r'^remove_all_courses/$', views.remove_all_courses, name='remove_all_courses'),22 url(r'^remove_home_course/$', views.remove_home_course, name='remove_home_course'),23 url(r'^send_approval/$', views.send_applation, name="send_approval"),24 url(r'^save_course_match/$', views.save_course_match, name="save_course_match"),25 url(r'^save_course_match_id/$', views.save_course_match_id, name="save_course_match_id"),26 url(r'^soknader/$', ApplicationListView.as_view(), name='soknader'),27 url(r'^remove_application/$', views.remove_application, name='remove_application'),28 url(r'^soknader/all/$', views.ApplicationListAll.as_view(), name='article-list'),29 url(r'^application/editstatus/$', views.edit_status_application, name='remove_application'),30 url(r'^application/edit/(?P<id>\d+)/$', views.edit_application, name='edit_application'),31 url(r'^abroadCourse/add/$', views.add_abroad_course_to_profile, name='add_abroad_course_to_profile'),...
cleanup.py
Source:cleanup.py
...11 try:12 check_call(args, shell=True)13 except:14 pass15def remove_application(a):16 """Remove applications from juju env17 """18 args = "~/juju remove-application %s" % a19 print args20 try:21 check_call(args, shell=True)22 except:23 pass24def main():25 """Helper script to clean up Juju environment.26 Example:27 $ python cleanup.py 12 13 1428 will remove machine id 12-14, and remove applications29 hardcoded: rack, server, storage, raid, pdu....30 """31 parser = ArgumentParser(description="Clean up Juju environment")32 parser.add_argument("--machines",33 "-m",34 nargs="+",35 type=int,36 help="machines to remove")37 parser.add_argument("--bundle",38 "-b",39 default="default.yaml",40 help="bundle YAML file")41 args = parser.parse_args()42 start_at = args.machines[0]43 if not args.bundle:44 print 'Missing bundle file'45 return46 bundle = yaml.load(open(args.bundle, 'r').read())47 apps = bundle['services'].keys()48 for a in apps:49 remove_application(a)50 sleep(2)51 for m in [start_at + i for i in range(len(bundle['machines']))]:52 remove_machine(m)53 sleep(3)54 for a in apps:55 remove_application(a)56 sleep(2)57 print "Environment is clean."58if __name__ == "__main__":...
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.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!