Best Python code snippet using avocado_python
urls.py
Source:urls.py  
1# Copyright (c) 2015 Ansible, Inc.2# All Rights Reserved.3from __future__ import absolute_import, unicode_literals4from django.conf import settings5from django.conf.urls import include, url6from awx.api.generics import (7    LoggedLoginView,8    LoggedLogoutView,9)10from awx.api.views import (11    ApiRootView,12    ApiV2RootView,13    ApiV2PingView,14    ApiV2ConfigView,15    ApiV2SubscriptionView,16    ApiV2AttachView,17    AuthView,18    UserMeList,19    DashboardView,20    DashboardJobsGraphView,21    UnifiedJobTemplateList,22    UnifiedJobList,23    HostAnsibleFactsDetail,24    JobCredentialsList,25    JobTemplateCredentialsList,26    SchedulePreview,27    ScheduleZoneInfo,28    OAuth2ApplicationList,29    OAuth2TokenList,30    ApplicationOAuth2TokenList,31    OAuth2ApplicationDetail,32)33from awx.api.views.metrics import (34    MetricsView,35)36from .organization import urls as organization_urls37from .user import urls as user_urls38from .project import urls as project_urls39from .project_update import urls as project_update_urls40from .inventory import urls as inventory_urls41from .team import urls as team_urls42from .host import urls as host_urls43from .group import urls as group_urls44from .inventory_source import urls as inventory_source_urls45from .inventory_update import urls as inventory_update_urls46from .inventory_script import urls as inventory_script_urls47from .credential_type import urls as credential_type_urls48from .credential import urls as credential_urls49from .credential_input_source import urls as credential_input_source_urls50from .role import urls as role_urls51from .job_template import urls as job_template_urls52from .job import urls as job_urls53from .job_host_summary import urls as job_host_summary_urls54from .job_event import urls as job_event_urls55from .ad_hoc_command import urls as ad_hoc_command_urls56from .ad_hoc_command_event import urls as ad_hoc_command_event_urls57from .system_job_template import urls as system_job_template_urls58from .system_job import urls as system_job_urls59from .workflow_job_template import urls as workflow_job_template_urls60from .workflow_job import urls as workflow_job_urls61from .notification_template import urls as notification_template_urls62from .notification import urls as notification_urls63from .label import urls as label_urls64from .workflow_job_template_node import urls as workflow_job_template_node_urls65from .workflow_job_node import urls as workflow_job_node_urls66from .schedule import urls as schedule_urls67from .activity_stream import urls as activity_stream_urls68from .instance import urls as instance_urls69from .instance_group import urls as instance_group_urls70from .oauth2 import urls as oauth2_urls71from .oauth2_root import urls as oauth2_root_urls72from .workflow_approval_template import urls as workflow_approval_template_urls73from .workflow_approval import urls as workflow_approval_urls74v2_urls = [75    url(r'^$', ApiV2RootView.as_view(), name='api_v2_root_view'),76    url(r'^credential_types/', include(credential_type_urls)),77    url(r'^credential_input_sources/', include(credential_input_source_urls)),78    url(r'^hosts/(?P<pk>[0-9]+)/ansible_facts/$', HostAnsibleFactsDetail.as_view(), name='host_ansible_facts_detail'),79    url(r'^jobs/(?P<pk>[0-9]+)/credentials/$', JobCredentialsList.as_view(), name='job_credentials_list'),80    url(r'^job_templates/(?P<pk>[0-9]+)/credentials/$', JobTemplateCredentialsList.as_view(), name='job_template_credentials_list'),81    url(r'^schedules/preview/$', SchedulePreview.as_view(), name='schedule_rrule'),82    url(r'^schedules/zoneinfo/$', ScheduleZoneInfo.as_view(), name='schedule_zoneinfo'),83    url(r'^applications/$', OAuth2ApplicationList.as_view(), name='o_auth2_application_list'),84    url(r'^applications/(?P<pk>[0-9]+)/$', OAuth2ApplicationDetail.as_view(), name='o_auth2_application_detail'),85    url(r'^applications/(?P<pk>[0-9]+)/tokens/$', ApplicationOAuth2TokenList.as_view(), name='application_o_auth2_token_list'),86    url(r'^tokens/$', OAuth2TokenList.as_view(), name='o_auth2_token_list'),87    url(r'^', include(oauth2_urls)),88    url(r'^metrics/$', MetricsView.as_view(), name='metrics_view'),89    url(r'^ping/$', ApiV2PingView.as_view(), name='api_v2_ping_view'),90    url(r'^config/$', ApiV2ConfigView.as_view(), name='api_v2_config_view'),91    url(r'^config/subscriptions/$', ApiV2SubscriptionView.as_view(), name='api_v2_subscription_view'),92    url(r'^config/attach/$', ApiV2AttachView.as_view(), name='api_v2_attach_view'),93    url(r'^auth/$', AuthView.as_view()),94    url(r'^me/$', UserMeList.as_view(), name='user_me_list'),95    url(r'^dashboard/$', DashboardView.as_view(), name='dashboard_view'),96    url(r'^dashboard/graphs/jobs/$', DashboardJobsGraphView.as_view(), name='dashboard_jobs_graph_view'),97    url(r'^settings/', include('awx.conf.urls')),98    url(r'^instances/', include(instance_urls)),99    url(r'^instance_groups/', include(instance_group_urls)),100    url(r'^schedules/', include(schedule_urls)),101    url(r'^organizations/', include(organization_urls)),102    url(r'^users/', include(user_urls)),103    url(r'^projects/', include(project_urls)),104    url(r'^project_updates/', include(project_update_urls)),105    url(r'^teams/', include(team_urls)),106    url(r'^inventories/', include(inventory_urls)),107    url(r'^hosts/', include(host_urls)),108    url(r'^groups/', include(group_urls)),109    url(r'^inventory_sources/', include(inventory_source_urls)),110    url(r'^inventory_updates/', include(inventory_update_urls)),111    url(r'^inventory_scripts/', include(inventory_script_urls)),112    url(r'^credentials/', include(credential_urls)),113    url(r'^roles/', include(role_urls)),114    url(r'^job_templates/', include(job_template_urls)),115    url(r'^jobs/', include(job_urls)),116    url(r'^job_host_summaries/', include(job_host_summary_urls)),117    url(r'^job_events/', include(job_event_urls)),118    url(r'^ad_hoc_commands/', include(ad_hoc_command_urls)),119    url(r'^ad_hoc_command_events/', include(ad_hoc_command_event_urls)),120    url(r'^system_job_templates/', include(system_job_template_urls)),121    url(r'^system_jobs/', include(system_job_urls)),122    url(r'^notification_templates/', include(notification_template_urls)),123    url(r'^notifications/', include(notification_urls)),124    url(r'^workflow_job_templates/', include(workflow_job_template_urls)),125    url(r'^workflow_jobs/', include(workflow_job_urls)),126    url(r'^labels/', include(label_urls)),127    url(r'^workflow_job_template_nodes/', include(workflow_job_template_node_urls)),128    url(r'^workflow_job_nodes/', include(workflow_job_node_urls)),129    url(r'^unified_job_templates/$', UnifiedJobTemplateList.as_view(), name='unified_job_template_list'),130    url(r'^unified_jobs/$', UnifiedJobList.as_view(), name='unified_job_list'),131    url(r'^activity_stream/', include(activity_stream_urls)),132    url(r'^workflow_approval_templates/', include(workflow_approval_template_urls)),133    url(r'^workflow_approvals/', include(workflow_approval_urls)),134]135app_name = 'api'136urlpatterns = [137    url(r'^$', ApiRootView.as_view(), name='api_root_view'),138    url(r'^(?P<version>(v2))/', include(v2_urls)),139    url(r'^login/$', LoggedLoginView.as_view(140        template_name='rest_framework/login.html',141        extra_context={'inside_login_context': True}142    ), name='login'),143    url(r'^logout/$', LoggedLogoutView.as_view(144        next_page='/api/', redirect_field_name='next'145    ), name='logout'),146    url(r'^o/', include(oauth2_root_urls)),147]148if settings.SETTINGS_MODULE == 'awx.settings.development':149    from awx.api.swagger import SwaggerSchemaView150    urlpatterns += [151        url(r'^swagger/$', SwaggerSchemaView.as_view(), name='swagger_view'),...paginated_url_spec.js
Source:paginated_url_spec.js  
1var should = require('should'),2    sinon = require('sinon'),3    getPaginatedUrl = require('../../../../frontend/meta/paginated_url'),4    urlUtils = require('../../../utils/urlUtils');5describe('getPaginatedUrl', function () {6    var data, getTestUrls;7    beforeEach(function () {8        data = {};9    });10    getTestUrls = function getTestUrls() {11        return {12            next: getPaginatedUrl('next', data, true),13            prev: getPaginatedUrl('prev', data, true),14            page1: getPaginatedUrl(1, data),15            page5: getPaginatedUrl(5, data),16            page10: getPaginatedUrl(10, data)17        };18    };19    it('should be a function', function () {20        should.exist(getPaginatedUrl);21    });22    describe('index', function () {23        it('should calculate correct urls for the first page of an index collection', function () {24            // Setup tests25            data.relativeUrl = '/';26            data.pagination = {prev: null, next: 2};27            // Execute test28            var urls = getTestUrls();29            // Check results30            urls.should.have.property('next', 'http://127.0.0.1:2369/page/2/');31            urls.should.have.property('prev', null);32            urls.should.have.property('page1', '/');33            urls.should.have.property('page5', '/page/5/');34            urls.should.have.property('page10', '/page/10/');35        });36        it('should calculate correct urls for the second page of an index collection', function () {37            // Setup tests38            data.relativeUrl = '/page/2/';39            data.pagination = {prev: 1, next: 3};40            // Execute test41            var urls = getTestUrls();42            // Check results43            urls.should.have.property('next', 'http://127.0.0.1:2369/page/3/');44            urls.should.have.property('prev', 'http://127.0.0.1:2369/');45            urls.should.have.property('page1', '/');46            urls.should.have.property('page5', '/page/5/');47            urls.should.have.property('page10', '/page/10/');48        });49        it('should calculate correct urls for the last page of an index collection', function () {50            // Setup tests51            data.relativeUrl = '/page/10/';52            data.pagination = {prev: 9, next: null};53            // Execute test54            var urls = getTestUrls();55            // Check results56            urls.should.have.property('next', null);57            urls.should.have.property('prev', 'http://127.0.0.1:2369/page/9/');58            urls.should.have.property('page1', '/');59            urls.should.have.property('page5', '/page/5/');60            urls.should.have.property('page10', '/page/10/');61        });62    });63    describe('other', function () {64        it('should calculate correct urls for the first page of another collection', function () {65            // Setup tests66            data.relativeUrl = '/featured/';67            data.pagination = {prev: null, next: 2};68            // Execute test69            var urls = getTestUrls();70            // Check results71            urls.should.have.property('next', 'http://127.0.0.1:2369/featured/page/2/');72            urls.should.have.property('prev', null);73            urls.should.have.property('page1', '/featured/');74            urls.should.have.property('page5', '/featured/page/5/');75            urls.should.have.property('page10', '/featured/page/10/');76        });77        it('should calculate correct urls for the second page of another collection', function () {78            // Setup tests79            data.relativeUrl = '/featured/page/2/';80            data.pagination = {prev: 1, next: 3};81            // Execute test82            var urls = getTestUrls();83            // Check results84            urls.should.have.property('next', 'http://127.0.0.1:2369/featured/page/3/');85            urls.should.have.property('prev', 'http://127.0.0.1:2369/featured/');86            urls.should.have.property('page1', '/featured/');87            urls.should.have.property('page5', '/featured/page/5/');88            urls.should.have.property('page10', '/featured/page/10/');89        });90        it('should calculate correct urls for the last page of another collection', function () {91            // Setup tests92            data.relativeUrl = '/featured/page/10/';93            data.pagination = {prev: 9, next: null};94            // Execute test95            var urls = getTestUrls();96            // Check results97            urls.should.have.property('next', null);98            urls.should.have.property('prev', 'http://127.0.0.1:2369/featured/page/9/');99            urls.should.have.property('page1', '/featured/');100            urls.should.have.property('page5', '/featured/page/5/');101            urls.should.have.property('page10', '/featured/page/10/');102        });103    });104    describe('with /blog subdirectory', function () {105        let sandbox;106        before(function () {107            sandbox = sinon.createSandbox();108            urlUtils.stubUrlUtils({url: 'http://localhost:82832/blog'}, sandbox);109        });110        after(function () {111            sandbox.restore();112        });113        it('should calculate correct urls for index', function () {114            // Setup tests115            data.relativeUrl = '/page/2/';116            data.pagination = {prev: 1, next: 3};117            // Execute test118            var urls = getTestUrls();119            // Check results120            urls.should.have.property('next', 'http://localhost:82832/blog/page/3/');121            urls.should.have.property('prev', 'http://localhost:82832/blog/');122            urls.should.have.property('page1', '/blog/');123            urls.should.have.property('page5', '/blog/page/5/');124            urls.should.have.property('page10', '/blog/page/10/');125        });126        it('should calculate correct urls for another collection', function () {127            // Setup tests128            data.relativeUrl = '/featured/page/2/';129            data.pagination = {prev: 1, next: 3};130            // Execute test131            var urls = getTestUrls();132            // Check results133            urls.should.have.property('next', 'http://localhost:82832/blog/featured/page/3/');134            urls.should.have.property('prev', 'http://localhost:82832/blog/featured/');135            urls.should.have.property('page1', '/blog/featured/');136            urls.should.have.property('page5', '/blog/featured/page/5/');137            urls.should.have.property('page10', '/blog/featured/page/10/');138        });139    });...webforms-urls.js
Source:webforms-urls.js  
1/*2 *3 * Copyright 2009-2015 Jayway Products AB4 *5 * Licensed under the Apache License, Version 2.0 (the "License");6 * you may not use this file except in compliance with the License.7 * You may obtain a copy of the License at8 *9 *     http://www.apache.org/licenses/LICENSE-2.010 *11 * Unless required by applicable law or agreed to in writing, software12 * distributed under the License is distributed on an "AS IS" BASIS,13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.14 * See the License for the specific language governing permissions and15 * limitations under the License.16 */17var UrlModule = (function() {18	var inner = {};19	var urls = {20		proxy : "/proxy/",21		surface : "/surface/",22		eid : "/eidproxy/"23	};24	inner.init = function(contextRoot, accesspoint) {25		urls.proxy = contextRoot + urls.proxy;26		urls.surface = contextRoot + urls.surface;27		urls.eid = contextRoot + urls.eid;28        urls.eidapi = urls.eid + "api/";29		urls.accesspoint = 'accesspoints/' + accesspoint + "/";30		urls.endusers = urls.accesspoint  + 'endusers/';31		32	};33	inner.verifyAccessPoint = function() {34		return urls.proxy + urls.accesspoint + '.json';35	};36	inner.selectEndUser = function() {37		return urls.surface + urls.endusers + 'selectenduser.json';38	};39	inner.getUser = function() {40		return urls.surface + urls.endusers + 'userreference.json';41	};42	inner.setUserUrl = function(user) {43		urls.user = urls.endusers + user + '/';44		urls.proxyuser = urls.endusers + user + '/drafts/';45	};46	inner.createCaseUrl = function(caze) {47		if (!urls.proxyuser && !urls.user)48			throw "URL to user not defined";49		urls.caze = urls.user + caze + '/';50		urls.draft = null;51		urls.proxycaze = urls.proxyuser + caze + '/';52		urls.proxydraft = null;53	};54	inner.createFormDraftUrl = function(form) {55		if (!urls.caze && !urls.proxycaze)56			throw "URL to case not defined";57		urls.draft = urls.caze + 'formdrafts/' + form + '/';58		urls.proxydraft = urls.proxycaze + 'formdrafts/' + form + '/';59	};60	inner.getCaseForm = function() {61		return urls.proxy + urls.proxyuser + 'findcasewithform.json';62	};63	inner.getFormDraft = function() {64		return urls.proxy + urls.proxydraft + 'index.json';65	};66	inner.getMailSelectionMessage = function() {67		return urls.proxy + urls.proxydraft + 'summary/mailselectionmessage.json';68	};69	inner.createCaseWithForm = function() {70		return urls.proxy + urls.proxyuser + 'createcasewithform.json';71	};72	inner.updateField = function() {73		return urls.proxy + urls.proxydraft + 'updatefield.json';74	};75	inner.enableMailNotification = function() {76		return urls.proxy + urls.proxydraft + 'summary/enablemailmessage.json';77	};78	inner.disableMailNotification = function() {79		return urls.proxy + urls.proxydraft + 'summary/disablemailmessage.json';80	};81	inner.setConfirmationEmail = function() {82		return urls.proxy + urls.proxydraft + 'summary/changeemailstobenotified.json';83	};84	inner.submitAndSend = function() {85		return urls.proxy + urls.proxydraft + 'summary/submitandsend.json';86	};87	inner.discard = function() {88		return urls.proxy + urls.proxydraft + 'discard.json';89	};90	inner.settings = function() {91		return urls.proxy + urls.proxydraft + 'settings.json';92	};93	94	inner.getFormSignatures = function() {95		return urls.proxy + urls.proxydraft + 'summary/signatures.json';96	};97    inner.getSigningServiceApi = function() {98        return urls.eidapi + 'services/.json';99    };100    //TODO: Create url from API response instead?101    inner.getGrpEIdProviders = function() {102        return urls.eidapi + 'services/grp/providers.json';103    };104    //TODO: Create url from API response instead?105    inner.grpSign = function() {106        return urls.eidapi + 'services/grp/sign.json';107    };108    //TODO: Create url from API response instead?109    inner.grpCollect = function(){110        return urls.eidapi + 'services/grp/collect.json';111    };112    //TODO: Create url from API response instead?113    inner.getAuthifySigningInfo = function() {114        return urls.eidapi + "services/authify/signing.json";115    };116    inner.saveSignature = function() {117        return urls.surface + urls.draft + 'savesignature.json';118    };119	inner.getCaseName = function() {120		return urls.proxy + urls.proxycaze + 'index.json';121	};122	inner.getCaseUrl = function() {123		return urls.proxy + urls.proxycaze;124	};125	inner.attach = function() {126		return urls.surface + urls.draft + 'createattachment';127	};128	inner.deleteAttachment = function(attachmentId) {129		return urls.proxy + urls.proxydraft + 'attachments/' + attachmentId + '/delete';130	};131	inner.refreshField = function() {132		return urls.proxy + urls.proxydraft + 'fieldvalue.json';133	};134	inner.getPrintUrl = function(formId) {135		return inner.getCaseUrl() + 'submittedforms/' + formId + '/generateformaspdf';136	};137	inner.setSecondSignatureName = function() {138		return urls.proxy + urls.proxydraft + 'updatename.json';139	};140	inner.setSecondSignaturePhoneNumber = function() {141		return urls.proxy + urls.proxydraft + 'updatephonenumber.json';142	};143	inner.setSecondSignatureSocialSecurityNumber = function() {144		return urls.proxy + urls.proxydraft + 'updatesocialsecuritynumber.json';145	};146	inner.setSecondSignatureEmail = function() {147		return urls.proxy + urls.proxydraft + 'updateemail.json';148	};149	inner.setSecondSignatureSingleSignature = function() {150		return urls.proxy + urls.proxydraft + 'updatesinglesignature.json';151	};152	return inner;...webforms-task-urls.js
Source:webforms-task-urls.js  
1/*2 *3 * Copyright 2009-2015 Jayway Products AB4 *5 * Licensed under the Apache License, Version 2.0 (the "License");6 * you may not use this file except in compliance with the License.7 * You may obtain a copy of the License at8 *9 *     http://www.apache.org/licenses/LICENSE-2.010 *11 * Unless required by applicable law or agreed to in writing, software12 * distributed under the License is distributed on an "AS IS" BASIS,13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.14 * See the License for the specific language governing permissions and15 * limitations under the License.16 */17var TaskUrlModule = (function() {18	var inner = {};19	var urls = {20		proxy : "/proxy/",21		surface : "/surface/",22		eid : "/eidproxy/"23	};24	inner.init = function(contextRoot, task) {25		urls.proxy = contextRoot + urls.proxy;26		urls.surface = contextRoot + urls.surface;27		urls.eid = contextRoot + urls.eid;28        urls.eidapi = urls.eid + "api/";29		urls.task = 'tasks/' + task + '/';30	};31	inner.verifyTask = function() {32		return urls.proxy + urls.task + '.json';33	};34	inner.selectEndUser = function() {35		return urls.surface + urls.task + 'selectenduser.json';36	};37	inner.getUser = function() {38		return urls.surface + urls.task + 'userreference.json';39	};40	inner.setUserUrl = function(user) {41		urls.user = urls.task + user + '/';42		urls.proxyuser = urls.task + user + '/drafts/';43	};44	inner.getTaskFormDraftUrl = function(form) {45		if (!urls.task)46			throw "URL to task not defined";47		urls.draft = urls.task + 'formdraft/';48		urls.proxydraft = urls.task + 'formdraft/';49		return urls.proxy + urls.draft + 'index.json';50	};51	inner.getTaskSubmittedFormSummary = function() {52		return urls.proxy + urls.task + 'submittedform/summary/index.json';53	};54	inner.getTaskForm = function() {55		return urls.proxy + urls.proxyuser + 'findcasewithform.json';56	};57	inner.getFormDraft = function() {58		return urls.proxy + urls.proxydraft + 'index.json';59	};60	inner.getMailSelectionMessage = function() {61		return urls.proxy + urls.proxydraft + 'summary/mailselectionmessage.json';62	};63	inner.createCaseWithForm = function() {64		return urls.proxy + urls.proxyuser + 'createcasewithform.json';65	};66	inner.updateField = function() {67		return urls.proxy + urls.proxydraft + 'updatefield.json';68	};69	inner.enableMailNotification = function() {70		return urls.proxy + urls.proxydraft + 'summary/enablemailmessage.json';71	};72	inner.disableMailNotification = function() {73		return urls.proxy + urls.proxydraft + 'summary/disablemailmessage.json';74	};75	inner.setConfirmationEmail = function() {76		return urls.proxy + urls.proxydraft + 'summary/changeemailstobenotified.json';77	};78	inner.submitAndSend = function() {79		return urls.proxy + urls.proxydraft + 'summary/submitandsend.json';80	};81	inner.discard = function() {82		return urls.proxy + urls.proxydraft + 'discard.json';83	};84	inner.settings = function() {85		return urls.proxy + urls.proxydraft + 'settings.json';86	};87	inner.getFormSignatures = function() {88		return urls.proxy + urls.proxydraft + 'summary/signatures.json';89	};90    inner.getSigningServiceApi = function() {91        return urls.eidapi + 'services/.json';92    };93    //TODO: Create url from API response instead?94    inner.getGrpEIdProviders = function() {95        return urls.eidapi + 'services/grp/providers.json';96    };97    //TODO: Create url from API response instead?98    inner.grpSign = function() {99        return urls.eidapi + 'services/grp/sign.json';100    };101    //TODO: Create url from API response instead?102    inner.grpCollect = function(){103        return urls.eidapi + 'services/grp/collect.json';104    };105    //TODO: Create url from API response instead?106    inner.getAuthifySigningInfo = function() {107        return urls.eidapi + "services/authify/signing.json";108    };109    inner.saveSignature = function() {110        return urls.surface + urls.draft + 'savesignature.json';111    };112	inner.getCaseName = function() {113		return urls.proxy + urls.task + 'caseid.json';114	};115	inner.getCaseUrl = function() {116		return urls.proxy + urls.proxycaze;117	};118	inner.attach = function() {119		return urls.surface + urls.draft + 'createattachment';120	};121	inner.deleteAttachment = function(attachmentId) {122		return urls.proxy + urls.proxydraft + 'attachments/' + attachmentId + '/delete';123	};124	inner.refreshField = function() {125		return urls.proxy + urls.proxydraft + 'fieldvalue.json';126	};127	inner.getPrintUrl = function(formId) {128		return urls.proxy + urls.draft + 'submittedforms/' + formId + '/generateformaspdf';129	};130	return inner;...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!!
