-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathenv.py
More file actions
46 lines (36 loc) · 989 Bytes
/
Copy pathenv.py
File metadata and controls
46 lines (36 loc) · 989 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
"""
Environment -related: class and methods.
E.g. the site URL
"""
import pytest
import requests
# import json
class Env:
""" Environment class
- what kind of site to we test: URL, name
"""
def __init__(self, name: str, host_url: str):
self.name = name
self.host_url = host_url
self.session = None
def get(self, url: str):
""" Performs GET request to the given url
@param url - the URL requested
"""
return requests.get(url)
def get_endpoint(self, endpoint: str):
"""
endpoint is part of URL to be applied with host
return requests.Response
"""
return requests.get(f'{self.host_url}{endpoint}') # "data": json.loads(res.text)
def env_():
""" To be used in fixture as well as outside"""
return Env("w3", "https://www.w3.org/")
@pytest.fixture()
def env():
"""
Fixture providing environment into tests
returns Evn
"""
return env_()