Skip to content

Commit b8ef636

Browse files
Rename MySession to ApiSession; Fix file paths in api tests.
1 parent e292969 commit b8ef636

File tree

4 files changed

+11
-10
lines changed

4 files changed

+11
-10
lines changed

fixtures_session.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1+
# pylint: disable=missing-function-docstring
12
import pytest
23

3-
from src.main.session import MySession, HttpbinApiSessionLevelOne, HttpbinApiSessionLevelTwo
4+
from src.main.session import ApiSession, HttpbinApiSessionLevelOne, HttpbinApiSessionLevelTwo
45

56

67
@pytest.fixture(scope='session', autouse=True)
7-
def api_session() -> MySession:
8-
with MySession() as session:
8+
def api_session() -> ApiSession:
9+
with ApiSession() as session:
910
yield session
1011

1112

src/main/file.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
def read_json(filename):
88
"""Read json and attach to allure as file."""
9-
with open(os.path.join(os.getcwd(), 'src', 'test', 'resources', filename)) as file:
9+
with open(os.path.join(os.getcwd(), 'resources', filename)) as file:
1010
schema = json.loads(file.read())
1111
allure.attach(body=json.dumps(schema, indent=2, ensure_ascii=False).encode('utf8'),
1212
name='Json schema', attachment_type=allure.attachment_type.JSON)

src/main/session.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
from src.main.allure_helpers import allure_request_logger
88

99

10-
class MySession(Session):
10+
class ApiSession(Session):
1111

1212
@allure_request_logger
1313
def request(self, method, url, **kwargs) -> Response:

src/test/test_api.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ def test_patch(self):
2828
with open(os.path.join(os.path.dirname(__file__), 'resources', 'patch.json')) as file:
2929
schema = json.loads(file.read())
3030

31-
body = requests.get('https://httpbin.org/patch').json()
31+
body = requests.patch('https://httpbin.org/patch').json()
3232

3333
validictory.validate(body, schema, fail_fast=False)
3434

@@ -63,7 +63,7 @@ def test_patch(self):
6363
name='Json schema', attachment_type=allure.attachment_type.JSON)
6464

6565
allure.attach(url, 'Requested API', allure.attachment_type.URI_LIST)
66-
body = requests.get(url).json()
66+
body = requests.patch(url).json()
6767
allure.attach(body=json.dumps(body, indent=2, ensure_ascii=False).encode('utf8'),
6868
name="Response", attachment_type=allure.attachment_type.JSON)
6969

@@ -131,22 +131,22 @@ def request(self, method, url):
131131
name="Response", attachment_type=allure.attachment_type.JSON)
132132
return body
133133

134-
def httpbin(self, method, url):
134+
def http_bin(self, method, url):
135135
return self.request(method, f'https://httpbin.org{url}')
136136

137137
@allure.title('GET "https://httpbin.org/get"')
138138
def test_get(self):
139139
schema = file.read_json('get.json')
140140

141-
body = self.httpbin('get', '/get')
141+
body = self.http_bin('get', '/get')
142142

143143
validictory.validate(body, schema, fail_fast=False)
144144

145145
@allure.title('PATCH "https://httpbin.org/patch"')
146146
def test_patch(self):
147147
schema = file.read_json('patch.json')
148148

149-
body = self.httpbin('patch', '/patch').json()
149+
body = self.http_bin('patch', '/patch')
150150

151151
validictory.validate(body, schema, fail_fast=False)
152152

0 commit comments

Comments
 (0)