-
Notifications
You must be signed in to change notification settings - Fork 75
Expand file tree
/
Copy pathconftest.py
More file actions
64 lines (53 loc) · 2.01 KB
/
conftest.py
File metadata and controls
64 lines (53 loc) · 2.01 KB
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
63
64
"""PyTest fixtures for testing the project."""
from __future__ import annotations
import os
import pytest
from ibmsecurity.appliance.isamappliance import ISAMAppliance
from ibmsecurity.user.applianceuser import ApplianceUser
import ibmsecurity.isam.appliance
@pytest.fixture(scope="session")
def iviaServer():
"""Initiate an ISAMAppliance."""
# s = IviaLogin()
_username = os.getenv('IVIA_ADMIN')
_pw = os.getenv('IVIA_PW')
_host = os.getenv('IVIA_HOST')
_port = os.getenv('IVIA_PORT') or 443
_https_proxy = os.getenv('IVIA_HTTPS_PROXY') or None
_http_proxy = os.getenv('IVIA_HTTP_PROXY') or None
# Create a user credential for ISAM appliance
u = ApplianceUser(username=_username, password=_pw)
# Create an ISAM appliance with above credential
isam_server = ISAMAppliance(hostname=_host, user=u, lmi_port=_port, http_proxy=_http_proxy, https_proxy=_https_proxy)
yield isam_server
returnValue = ibmsecurity.isam.appliance.commit(isamAppliance=isam_server, publish=True)
print('\nCommit result and publish')
print( returnValue )
print('\n')
return returnValue
# ibmsecurity
def pytest_runtest_setup(item):
print("setting up function:", item.name)
yield
# @pytest.fixture(autouse=True)
# def pytest_configure(config: Config) -> None:
# """Register custom markers."""
# print('configure')
#@pytest.fixture(scope="session", autouse=True)
#def ivia_commit(iviaServer):
# """Commit the changes"""
# print('TEST')
# # caplog.set_level(logging.INFO)
# returnValue = ibmsecurity.isam.appliance.commit(isamAppliance=iviaServer)
# # logging.log(logging.DEBUG, returnValue)
# print(returnValue)
#@pytest.hookimpl(hookwrapper=True)
#def pytest_sessionfinish(session, iviaServer):
# """Commit the changes"""
# # caplog.set_level(logging.INFO)
#
# returnValue = ibmsecurity.isam.appliance.commit(isamAppliance=iviaServer)
# yield returnValue
# # logging.log(logging.DEBUG, returnValue)
# print(returnValue)
# print("\nTest session finished!")