Best Python code snippet using yandex-tank
test_update.py
Source:test_update.py
1import pytest2from fastapi.testclient import TestClient3from app.main import app4client = TestClient(app)5#sprinkler6@pytest.mark.order(3)7def test_update_sprinkler(test_update):8 response = test_update.post("/sprinkler", json={9 "id": 1,10 "description": "test_sprinkler_01_updated",11 "active": True12 }13 )14 assert response.status_code == 20015@pytest.mark.order(3)16def test_update_sprinkler_inexist_id(test_update):17 response = test_update.post("/sprinkler", json={18 "id": 0,19 "description": "test_sprinkler_01_updated",20 "active": True21 }22 )23 assert response.status_code == 40424 assert response.json()["message"] == "Don't find ID specified"25@pytest.mark.order(3)26def test_update_sprinkler_wrong_value(test_update):27 response = test_update.post("/sprinkler", json={28 "id": 1,29 "description": "test_sprinkler_01_updated",30 "active": 331 }32 )33 assert response.status_code == 42234#plant35@pytest.mark.order(3)36def test_update_plant(test_update):37 response = test_update.post("/plant", json={38 "id": 1,39 "description": "test_plant_01_updated",40 "sprinkler_id": 1,41 "active": True42 }43 )44 assert response.status_code == 20045@pytest.mark.order(3)46def test_update_plant_inexist_id(test_update):47 response = test_update.post("/plant", json={48 "id": 0,49 "description": "test_plant_01_updated",50 "sprinkler_id": 1,51 "active": True52 }53 )54 assert response.status_code == 40455 assert response.json()["message"] == "Don't find ID specified"56@pytest.mark.order(3)57def test_update_plant_inexist_sprinkler_id(test_update):58 response = test_update.post("/plant", json={59 "id": 1,60 "description": "test_plant_01_updated_wrong_sprinkler_id",61 "sprinkler_id": 0,62 "active": True63 }64 )65 assert response.status_code == 40066@pytest.mark.order(3)67def test_update_plant_wrong_value(test_update):68 response = test_update.post("/plant", json={69 "id": 1,70 "description": "test_plant_01_updated_wrong_value",71 "sprinkler_id": 1,72 "active": 373 }74 )75 assert response.status_code == 42276#water day77@pytest.mark.order(3)78def test_update_waterday(test_update):79 response = test_update.post("/waterday", json={80 "id": 1,81 "week_day": 0,82 "time_day": "12:30",83 "water_time": 50,84 "plant_id": 1,85 "active": True86 }87 )88 assert response.status_code == 20089@pytest.mark.order(3)90def test_update_waterday_indexist_id(test_update):91 response = test_update.post("/waterday", json={92 "id": 0,93 "week_day": 0,94 "time_day": "12:30",95 "water_time": 50,96 "plant_id": 1,97 "active": True98 }99 )100 assert response.status_code == 404101 assert response.json()["message"] == "Don't find ID specified"102@pytest.mark.order(3)103def test_update_waterday_wrong_week_day(test_update):104 response = test_update.post("/waterday", json={105 "id": 1,106 "week_day": 7,107 "time_day": "12:30",108 "water_time": 50,109 "plant_id": 1,110 "active": True111 }112 )113 assert response.status_code == 400114 assert response.json()["message"] == "Weekday must be between 0-6 (0: Monday/6: Sunday)"115 assert response.json()["exception"] == "Weekday 7 is invalid"116@pytest.mark.order(3)117def test_update_waterday_wrong_time_day(test_update):118 response = test_update.post("/waterday", json={119 "id": 1,120 "week_day": 0,121 "time_day": "1c:30",122 "water_time": 50,123 "plant_id": 1,124 "active": True125 }126 )127 assert response.status_code == 400128 assert response.json()["message"] == "Time Day must be in format HH:MM - 24 format"129 assert response.json()["exception"] == "time data '1c:30' does not match format '%H:%M'"130@pytest.mark.order(3)131def test_update_waterday_wrong_value_timeday(test_update):132 response = test_update.post("/waterday", json={133 "id": 1,134 "week_day": 0,135 "time_day": "12:30",136 "water_time": 'a',137 "plant_id": 1,138 "active": True139 }140 )141 assert response.status_code == 422142 143@pytest.mark.order(3)144def test_update_waterday_inextis_plant_id(test_update):145 response = test_update.post("/waterday", json={146 "id": 1,147 "week_day": 0,148 "time_day": "12:30",149 "water_time": 50,150 "plant_id": 0,151 "active": True152 }153 )154 assert response.status_code == 400155 assert response.json()["message"] == "Don't find plant_id specified"...
test_movie.py
Source:test_movie.py
...17 resp_json = resp.json18 assert resp.status_code == 20019 assert resp_json["name"] == "avengers1"20 assert resp_json["genre"] == "gnr1"21def test_update( client):22 resp = client.put("/movie/avengers1", json={'name': 'test_update', 'genre': 'test_update'})23 assert resp.status_code == 20424 resp = client.get("/movie/test_update")25 resp_json = resp.json26 assert resp.status_code == 20027 assert resp_json["name"] == "test_update"28 assert resp_json["genre"] == "test_update"29def test_update_name( client):30 resp = client.put("/movie/avengers1", json={'name': 'test_update'})31 assert resp.status_code == 20432 resp = client.get("/movie/test_update")33 resp_json = resp.json34 assert resp.status_code == 20035 assert resp_json["name"] == "test_update"...
run_hardware_tests.py
Source:run_hardware_tests.py
1import hardware_tests as hw2print('hw.test_bmp.test_temperature()')3hw.test_bmp.test_temperature()4print('hw.test_bmp.test_pressure()')5hw.test_bmp.test_pressure()6print('hw.test_lcd.test_cursor_pos()')7hw.test_lcd.test_cursor_pos()8print('hw.test_lcd.test_columns()')9hw.test_lcd.test_columns()10print('hw.test_lcd.test_cursor_mode()')11hw.test_lcd.test_cursor_mode()12print('hw.test_lcd.test_clear()')13hw.test_lcd.test_clear()14print('hw.test_lcd.test_write_string()')15hw.test_lcd.test_write_string()16print('hw.test_lsm.test_accel_x()')17hw.test_lsm.test_accel_x()18print('hw.test_lsm.test_accel_y()')19hw.test_lsm.test_accel_y()20print('hw.test_lsm.test_accel_z()')21hw.test_lsm.test_accel_z()22print('hw.test_lsm.test_mag_x()')23hw.test_lsm.test_mag_x()24print('hw.test_lsm.test_mag_y()')25hw.test_lsm.test_mag_y()26print('hw.test_lsm.test_mag_z()')27hw.test_lsm.test_mag_z()28print('hw.test_sht.test_temperature()')29hw.test_sht.test_temperature()30print('hw.test_sht.test_humidity()')31hw.test_sht.test_humidity()32print('hw.test_tsl.test_visible()')33hw.test_tsl.test_visible()34print('hw.test_tsl.test_infrared()')35hw.test_tsl.test_infrared()36print('hw.test_update.test_run()')37hw.test_update.test_run()38print('hw.test_update.test_get_current_release()')39hw.test_update.test_get_current_release()40print('hw.test_update.test_get_releases()')41hw.test_update.test_get_releases()42print('hw.test_update.test_get_passive_partition()')43hw.test_update.test_get_passive_partition()44print('hw.test_update.test_get_total_size()')45hw.test_update.test_get_total_size()46print('hw.test_update.test_download_checksums()')47hw.test_update.test_download_checksums()48print('hw.test_update.test_download_rootfs()')49hw.test_update.test_download_rootfs()50print('hw.test_update.test_download_boot()')51hw.test_update.test_download_boot()52print('hw.test_update.test_get_checksum_rootfs()')53hw.test_update.test_get_checksum_rootfs()54print('hw.test_update.test_get_checksum_boot()')55hw.test_update.test_get_checksum_boot()56print('hw.test_update.test_flash_boot_select()')57hw.test_update.test_flash_boot_select()58print('hw.test_update.test_install()')59hw.test_update.test_install()60print('hw.test_update.test_create_checksums_json()')61hw.test_update.test_create_checksums_json()62print('hw.test_wifi.test_decode_name()')63hw.test_wifi.test_decode_name()64print('hw.test_wifi.test_get_ip()')65hw.test_wifi.test_get_ip()66print('hw.test_wifi.test_scan()')67hw.test_wifi.test_scan()68print('hw.test_wifi.test_add()')69hw.test_wifi.test_add()70print('hw.test_wifi.test_known()')71hw.test_wifi.test_known()72print('hw.test_wifi.test_remove()')73hw.test_wifi.test_remove()74print('hw.test_wifi.test_reset()')...
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!!