Best Python code snippet using autotest_python
rpc_interface_unittest.py
Source: rpc_interface_unittest.py
...241 set([1, 2]))242 task = tasks[0]243 self.assertEquals(task['task'], models.SpecialTask.Task.VERIFY)244 self.assertEquals(task['requested_by'], 'autotest_system')245 def test_parameterized_job(self):246 settings.settings.override_value(247 'AUTOTEST_WEB', 'parameterized_jobs', 'True')248 string_type = model_attributes.ParameterTypes.STRING249 test = models.Test.objects.create(250 name='test', test_type=model_attributes.TestTypes.SERVER)251 test_parameter = test.testparameter_set.create(name='key')252 profiler = models.Profiler.objects.create(name='profiler')253 kernels = ({'version': 'version', 'cmdline': 'cmdline'},)254 profilers = ('profiler',)255 profiler_parameters = {'profiler': {'key': ('value', string_type)}}256 job_parameters = {'key': ('value', string_type)}257 job_id = rpc_interface.create_parameterized_job(258 name='job', priority=models.Job.Priority.MEDIUM, test='test',259 parameters=job_parameters, kernel=kernels, label='label1',...
test_jenkins.py
Source: test_jenkins.py
1#!/bin/env python2#3# Copyright (C) 2014 eNovance SAS <licensing@enovance.com>4#5# Licensed under the Apache License, Version 2.0 (the "License"); you may6# not use this file except in compliance with the License. You may obtain7# 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, WITHOUT13# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the14# License for the specific language governing permissions and limitations15# under the License.16import random17import requests18import time19import config20from utils import Base21from utils import JenkinsUtils22from utils import get_cookie23def rand_suffix():24 return ''.join(random.sample('123456789abcdef', 3))25TEST_PARAMETERIZED_JOB = """<?xml version='1.0' encoding='UTF-8'?>26<project>27 <keepDependencies>false</keepDependencies>28 <properties/>29 <scm class='jenkins.scm.NullSCM'/>30 <canRoam>true</canRoam>31 <disabled>false</disabled>32 <blockBuildWhenUpstreamBuilding>false</blockBuildWhenUpstreamBuilding>33 <properties>34 <hudson.model.ParametersDefinitionProperty>35 <parameterDefinitions>36 <hudson.model.StringParameterDefinition>37 <name>timeout</name>38 <description>how long do we sleep</description>39 <defaultValue/>40 </hudson.model.StringParameterDefinition>41 </parameterDefinitions>42 </hudson.model.ParametersDefinitionProperty>43 </properties>44 <triggers class='vector'/>45 <concurrentBuild>false</concurrentBuild>46 <builders>47 <hudson.tasks.Shell>48 <command>echo "Hi, I am a lazy test."49set -x50sleep "$timeout"51set +x52echo "Done !"53 </command>54 </hudson.tasks.Shell>55 </builders>56 <publishers/>57 <buildWrappers/>58</project>"""59class TestJenkinsBasic(Base):60 """ Functional tests to validate config repo bootstrap61 """62 def setUp(self):63 super(TestJenkinsBasic, self).setUp()64 self.ju = JenkinsUtils()65 def test_config_jobs_exist(self):66 """ Test if jenkins config-update and config-check are created67 """68 url = '%s/job/config-check/' % self.ju.jenkins_url69 resp = self.ju.get(url)70 self.assertEquals(resp.status_code, 200)71 url = '%s/job/config-update/' % self.ju.jenkins_url72 resp = self.ju.get(url)73 self.assertEquals(resp.status_code, 200)74class TestJobsAPI(Base):75 @classmethod76 def setUpClass(cls):77 cookie = get_cookie(config.ADMIN_USER, config.ADMIN_PASSWORD)78 cls.cookie = {"auth_pubtkt": cookie}79 cls.ju = JenkinsUtils()80 cls.test_job = "test-sleep-" + rand_suffix()81 cls.ju.create_job(cls.test_job,82 TEST_PARAMETERIZED_JOB)83 cls.ju.run_job(cls.test_job, {'timeout': '1'})84 cls.ju.wait_till_job_completes(cls.test_job, 1, 'lastBuild')85 cls.base_url = config.GATEWAY_URL + "/manage/jobs/"86 def test_get_one(self):87 """Get info about one job"""88 job = requests.get(self.base_url + "%s/id/1/" % self.test_job,89 cookies=self.cookie).json()90 self.assertTrue("jenkins" in job.keys(),91 job)92 self.assertEqual(self.test_job,93 job["jenkins"][0]["job_name"])94 def test_get_parameters(self):95 """fetch the parameters used to run one job"""96 u = self.base_url + "%s/id/1/parameters" % self.test_job97 job = requests.get(u, cookies=self.cookie).json()98 self.assertTrue("jenkins" in job.keys(),99 job)100 self.assertEqual(self.test_job,101 job["jenkins"]["job_name"])102 self.assertEqual(1,103 int(job["jenkins"]["parameters"][0]['value']),104 job)105 self.assertEqual('timeout',106 job["jenkins"]["parameters"][0]['name'],107 job)108 def test_get_logs(self):109 """fetch the logs of a job and check their contents"""110 job = requests.get(self.base_url + "%s/id/1/logs" % self.test_job,111 cookies=self.cookie).json()112 self.assertTrue("jenkins" in job.keys(),113 job)114 self.assertEqual(self.test_job,115 job["jenkins"]["job_name"])116 logs_url = job["jenkins"]["logs_url"]117 r = requests.get(logs_url, cookies=self.cookie).text118 self.assertTrue("Hi, I am a lazy test." in r,119 r)120 def test_run(self):121 """Test running a parameterized job manually"""122 last_build = self.ju.get_last_build_number(self.test_job,123 'lastBuild')124 r = requests.post(self.base_url + self.test_job,125 cookies=self.cookie,126 json={'timeout': '3'}).json()127 time.sleep(1)128 self.assertEqual(int(last_build) + 1,129 int(r["jenkins"]["job_id"]),130 r)131 def test_stop(self):132 """test stopping a running job"""133 last_build = self.ju.get_last_build_number(self.test_job,134 'lastBuild')135 build = int(last_build) + 1136 self.ju.run_job(self.test_job, {'timeout': '60'})137 time.sleep(10)138 r = requests.delete(self.base_url + "%s/id/%s" % (self.test_job,139 build),140 cookies=self.cookie)141 self.assertTrue(int(r.status_code < 300),...
Check out the latest blogs from LambdaTest on this topic:
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.
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.
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
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. ????
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.
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!!