Best Python code snippet using Kiwi_python
problem2.py
Source:problem2.py
1import pytest2import requests3def test_edit_bug():4 """ 5 Verify that a bug can be edited and the data persists6 """7 url = "https://bugs.info:4000/api/v1/bug"8 existing_bug = {9 "bug_id": 1234,10 "title": "The service is hanging",11 "description": "service hangs after casting a string",12 "status": "OPEN",13 }14 edit_bug_data = {15 "bug_id": 1234,16 "title": "The service starts and stops",17 "description": "Service keeps restarting and logging everyone off",18 }19 expected = {20 "bug_id": 1234,21 "title": "The service starts and stops",22 "description": "Service keeps restarting and logging everyone off",23 "status": "OPEN",24 }25 r = requests.post(url, edit_bug_data)26 # verify 200 request status code27 assert r.status_code == 20028 29 # lookup the bug and verify data persists30 bug_id = update_bug_data["bug_id"]31 assert r.get(url, bug_id) == expected32def test_edit_bug():33 """ 34 Verify that editing an invalid bug id results in a "Not Found" response35 """36 url = "https://bugs.info:4000/api/v1/bug"37 bug = {38 "bug_id": -20039 }40 bug_id = bug["bug_id"]41 r = requests.post(url, bug_id)42 assert "NOT FOUND" in r.raise_for_status()43def test_invalid_payload():44 """45 Verify that the server handles invalid payloads46 """...
test_mutation.py
Source:test_mutation.py
...16 assert bug.project == project17 assert bug.priority == Priority.URGENT18 assert bug.state == State.NEW19 assert bug.created_by == user20def test_edit_bug(user, bug):21 action = Action.build(bug=bug, user=user)22 action.set_title('new title')23 assert bug.actions.count() == 1, "Action should not be created yet"24 action.commit()25 assert bug.actions.count() == 226 bug.refresh_from_db()27 assert bug.title == 'new title'28def test_operations(user, bug):29 action = Action.build(bug=bug, user=user)30 assert list(action.operations) == []31 op1 = action.add_comment('bar')32 assert list(action.operations) == [op1]33 op2 = action.set_title('foo')34 assert list(action.operations) == [op1, op2]...
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!!