Skip to content

Commit

Permalink
Merge pull request #4 from naodeng/main
Browse files Browse the repository at this point in the history
update demo
  • Loading branch information
naodeng authored Nov 15, 2023
2 parents fb62ede + 262c3c5 commit a2d2941
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 33 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -160,4 +160,5 @@ cython_debug/
#.idea/

allure-report/
.idea/
.idea/
report
2 changes: 1 addition & 1 deletion pytest.ini
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[pytest]
# allure
# addopts = -vs -rf --html-report=./report --title='PYTEST REPORT' --self-contained-html
# addopts = --alluredir ./allure-report
# pytest-html
addopts = -vs -rf --html-report=./report --title='PYTEST REPORT' --self-contained-html
1 change: 0 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,3 @@ pytest-metadata==3.0.0
requests==2.31.0
urllib3==2.0.7
pytest-custom-exit-code==0.3.0

33 changes: 3 additions & 30 deletions test_case/test_demo_allure.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
import allure
import requests


<<<<<<< HEAD:test_case/test_demo.py
class TestPytestDemo:
=======
@allure.title("Test example get endpoint")
@allure.description("Test the example get API endpoint")
def test_get_example_endpoint(env_config, env_request_data, env_response_data):
def test_get_example_endpoint_allure(env_config, env_request_data, env_response_data):
host = env_config["host"]
get_api = env_config["getAPI"]
get_api_request_data = env_request_data["getAPI"]
Expand All @@ -18,35 +16,11 @@ def test_get_example_endpoint(env_config, env_request_data, env_response_data):
assert response.status_code == 200
print("verify the response data")
assert response.json() == get_api_response_data
>>>>>>> bb894ee (update demo):test_case/test_demo_allure.py

def test_get_demo(self):
base_url = "https://jsonplaceholder.typicode.com"
# 发起请求
response = requests.get(f"{base_url}/posts/1")
# 断言
assert response.status_code == 200
assert response.json()['userId'] == 1
assert response.json()['id'] == 1

<<<<<<< HEAD:test_case/test_demo.py
def test_post_demo(self):
base_url = "https://jsonplaceholder.typicode.com"
requests_data = {
"title": "foo",
"body": "bar",
"userId": 1
}
# 发起请求
response = requests.post(f"{base_url}/posts", requests_data)
# 断言
assert response.status_code == 201
assert response.json()['userId'] == '1'
assert response.json()['id'] == 101
=======
@allure.title("Test example POST endpoint")
@allure.description("Test the example POST API endpoint")
def test_post_example_endpoint(env_config, env_request_data, env_response_data):
def test_post_example_endpoint_allure(env_config, env_request_data, env_response_data):
host = env_config["host"]
post_api = env_config["postAPI"]
post_api_request_data = env_request_data["postAPI"]
Expand All @@ -58,4 +32,3 @@ def test_post_example_endpoint(env_config, env_request_data, env_response_data):
assert response.status_code == 201
print("verify the response data")
assert response.json() == post_api_response_data
>>>>>>> bb894ee (update demo):test_case/test_demo_allure.py

0 comments on commit a2d2941

Please sign in to comment.