-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconftest.py
62 lines (51 loc) · 1.82 KB
/
conftest.py
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
import requests
import pytest
import json
from requests.auth import HTTPBasicAuth
from .config import base_url
from .API_Classes.EmployeeClass import EmployeeAPI
@pytest.fixture(scope="session")
def bearer_token():
auth = HTTPBasicAuth('user1', 'password1')
response = requests.post(base_url+"/tokens",auth=auth)
bearer_token = response.json()["access_token"]
return bearer_token
@pytest.fixture(scope="session",autouse=True)
def api_client(bearer_token):
headers = {"Authorization": f"Bearer {bearer_token}"}
return EmployeeAPI(base_url, headers)
@pytest.fixture(scope="session")
def LastEmployee():
with open('JSON/lastEmployeeID.json','r') as file:
data = json.load(file)
return data['EmployeeID']
@pytest.fixture(scope="session")
def bearer_token_negative():
auth = HTTPBasicAuth('random1', 'random1')
response = requests.post(base_url+"/tokens",auth=auth)
bearer_token = response.json()["access_token"]
return bearer_token
@pytest.fixture(scope="session",autouse=True)
def api_client_negative(bearer_token_negative):
headers = {"Authorization": f"Bearer {bearer_token_negative}"}
return EmployeeAPI(base_url, headers)
# @pytest.fixture(scope="session")
# def openFile():
# with open('JSON/newDemoEmployee1.json','r') as file:
# data = json.load(file)
# return data
# @pytest.fixture(scope="session")
# def upadteEmpDetails():
# with open('JSON/updateEmployeeDetails.json','r') as file:
# data = json.load(file)
# return data
# @pytest.fixture(scope="session")
# def onBoardData():
# with open('JSON/onBoardingDate.json','r') as file:
# data = json.load(file)
# return data
# @pytest.fixture(scope="session")
# def offBoardData():
# with open('JSON/offBoardingDate.json','r') as file:
# data = json.load(file)
# return data