Skip to content

Commit

Permalink
Merge pull request #11 from naodeng/main
Browse files Browse the repository at this point in the history
add demo for filter test
  • Loading branch information
naodeng authored Nov 20, 2023
2 parents befe084 + 920fc15 commit 867208e
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 1 deletion.
5 changes: 4 additions & 1 deletion pytest.ini
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,7 @@
# allure
addopts = --alluredir ./allure-results
# pytest-html
# addopts = -vs -rf --html-report=./report --title='PYTEST REPORT'
# addopts = -vs -rf --html-report=./report --title='PYTEST REPORT'
markers =
Regression: marks tests as Regression
Smoke: marks tests as Smoke
2 changes: 2 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ allure-python-commons==2.13.2
attrs==23.1.0
certifi==2023.7.22
charset-normalizer==3.3.2
execnet==2.0.2
idna==3.4
iniconfig==2.0.0
Jinja2==3.1.2
Expand All @@ -13,5 +14,6 @@ pluggy==1.3.0
pytest==7.4.3
pytest-custom-exit-code==0.3.0
pytest-metadata==3.0.0
pytest-xdist==3.4.0
requests==2.31.0
urllib3==2.0.7
31 changes: 31 additions & 0 deletions test_case/test_demo_filter.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import pytest
import requests
import json


class TestPytestMultiEnvDemo:

@pytest.mark.Regression # mark the test case as regression
def test_get_demo_filter(self, env_config, env_request_data, env_response_data):
host = env_config["host"]
get_api = env_config["getAPI"]
get_api_response_data = env_response_data["getAPI"]
# send request
response = requests.get(host+get_api)
# assert
assert response.status_code == 200
assert response.json() == get_api_response_data

@pytest.mark.Smoke # mark the test case as smoke
def test_post_demo_filter(self, 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"]
print("make the request")
post_api_response_data = env_response_data["postAPI"]
# Your test code here
response = requests.post(host + post_api, json=post_api_request_data)
print("verify the response status code")
assert response.status_code == 201
print("verify the response data")
assert response.json() == post_api_response_data

0 comments on commit 867208e

Please sign in to comment.