Best Python code snippet using avocado_python
test_boto3.py
Source:test_boto3.py
1import boto32from botocore.config import Config3import os4import time5import configparser6config = configparser.RawConfigParser()7config.read("config.ini")8AWS_ACCESS_KEY = config["General"]["AWS_ACCESS_KEY"]9AWS_SECRET_ACCESS = config["General"]["AWS_SECRET_ACCESS"]10BUCKET_NAME = config["General"]["BUCKET_NAME"]11config = Config(connect_timeout=3600, read_timeout=3600)12s3 = boto3.client('s3',13 aws_access_key_id=AWS_ACCESS_KEY,14 aws_secret_access_key=AWS_SECRET_ACCESS,15 config=config)16# s3.upload_file("./test_upload_image/test_upload.png",17# BUCKET_NAME, "detected_ships/10-01-2022-10-30-AM-2.png")18# time.sleep(1)19# s3.upload_file("./test_upload_image/test_upload.png",20# BUCKET_NAME, "detected_ships/10-01-2022-10-45-AM-3.png")21# time.sleep(1)22# s3.upload_file("./test_upload_image/test_upload.png",23# BUCKET_NAME, "detected_ships/10-01-2022-12-30-PM-4.png")24# time.sleep(1)25# s3.upload_file("./test_upload_image/test_upload.png",26# BUCKET_NAME, "detected_ships/10-01-2022-09-30-PM-5.png")27# time.sleep(1)28# s3.download_file(BUCKET_NAME, "detected_ships/10-01-2022-10-45-AM-2.png",29# "./test_download_image/10-01-2022-10-45-AM-2.png")30# print(os.path.exists("test_download_image/10-01-2022-10-30-AM-2.png"))31response = s3.list_objects(Bucket=BUCKET_NAME)32# for content in response.get('Contents', []):33# print(content["Key"])34image_dict = {}35for content in response.get('Contents', []):36 image_dict[content["Key"]] = content["LastModified"]37img_list_sorted = sorted(38 image_dict.items(), key=lambda item: item[1], reverse=True)...
test_models.py
Source:test_models.py
1from django.test import TestCase2from travel_times.models import TravelTimesMap3class TestTravelTimesMap(TestCase):4 def test_download_image(self):5 test_map = TravelTimesMap.objects.create(6 postcode="SW1A1AA",7 width=100,8 height=1009 )10 test_map.download_image()11 test_map.refresh_from_db()...
test_download_image.py
Source:test_download_image.py
1import unittest2from meme_bot import download_image3import os4class test_download_image(unittest.TestCase):5 def test_downloadmeme(self):6 download_image.downloadmeme()7 self.assertEqual(os.path.exists("meme.jpg"), True)8 os.remove("meme.jpg")9if __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!!