Best Python code snippet using autotest_python
Jober.py
Source:Jober.py
...26 password = getpass.unix_getpass()27 self.server = jenkins.Jenkins(url, username, password)28 logger.debug('Connect to Jenkins successfully.')29 pass30 def create_new_job(self, job_name, job_config_xml):31 """32 Create new job when the Job name not exist.33 :param job_name:34 :type job_name:35 :param job_config_xml:36 :type job_config_xml:37 :return:38 :rtype:39 """40 try:41 self.server.create_job(job_name, job_config_xml)42 except jenkins.JenkinsException as e:43 # logger.error(e.message)44 print(e.message)45 pass46 def create_job(self, job_name, job_config_xml):47 """48 Create new job anyway.49 :param job_name:50 :type job_name:51 :param job_config_xml:52 :type job_config_xml:53 :return:54 :rtype:55 """56 try:57 self.delete_job(job_name)58 except jenkins.JenkinsException:59 self.create_new_job(job_name, job_config_xml)60 return61 self.create_new_job(job_name, job_config_xml)62 pass63 def delete_job(self, job_name):64 self.server.delete_job(job_name)65 pass66 def update_job(self):67 pass68 def enable_job(self,job_name):69 self.server.enable_job(job_name)...
test_jobs_repo.py
Source:test_jobs_repo.py
...9 location = "USA"10 description = "Fake description"11 owner = create_random_owner(db=db_session)12 job_schema = JobCreate(title=title, company=company, company_url=company_url, location=location, description=description)13 job = create_new_job(job=job_schema, db=db_session, owner_id=owner.id)14 retrieved_job = retrieve_job(id=job.id, db=db_session)15 assert retrieved_job.id == job.id16 assert retrieved_job.title == "test title"17def test_retrieve_all_jobs(db_session: Session):18 title = "test title"19 company = "test company"20 company_url = "test.example.com"21 location = "USA"22 description = "Fake description"23 owner = create_random_owner(db=db_session)24 job_schema = JobCreate(title=title, company=company, company_url=company_url, location=location, description=description)25 create_new_job(job=job_schema, db=db_session, owner_id=owner.id)26 create_new_job(job=job_schema, db=db_session, owner_id=owner.id)27 create_new_job(job=job_schema, db=db_session, owner_id=owner.id)28 retrieved_jobs = list_jobs(db=db_session)...
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!!