mirror of
https://github.com/Telecominfraproject/wlan-testing.git
synced 2025-11-02 03:48:09 +00:00
pytest: Clean up some tools vs pytest breakage in that last commit.
Seems you cannot have two __init__ methods in a class, so change code to only one one variant. Signed-off-by: Ben Greear <greearb@candelatech.com>
This commit is contained in:
@@ -48,15 +48,6 @@ class CloudSDK:
|
|||||||
self.cloud_type = "v1"
|
self.cloud_type = "v1"
|
||||||
self.refresh_bearer()
|
self.refresh_bearer()
|
||||||
|
|
||||||
def __init__(self, id, passwd, url, verbose):
|
|
||||||
self.user = id
|
|
||||||
self.password = passwd
|
|
||||||
self.base_url = url
|
|
||||||
self.assert_bad_response = False
|
|
||||||
self.verbose = verbose
|
|
||||||
self.cloud_type = "v1"
|
|
||||||
self.refresh_bearer()
|
|
||||||
|
|
||||||
def refresh_bearer(self):
|
def refresh_bearer(self):
|
||||||
self.bearer = self.get_bearer(self.base_url, self.cloud_type)
|
self.bearer = self.get_bearer(self.base_url, self.cloud_type)
|
||||||
|
|
||||||
@@ -672,7 +663,7 @@ class CloudSDK:
|
|||||||
print(equipment_info)
|
print(equipment_info)
|
||||||
|
|
||||||
###Update AP Info with Required Profile ID
|
###Update AP Info with Required Profile ID
|
||||||
url = cloudSDK_url+"/portal/equipment"
|
url = self.base_url + "/portal/equipment"
|
||||||
headers = {
|
headers = {
|
||||||
'Content-Type': 'application/json',
|
'Content-Type': 'application/json',
|
||||||
'Authorization': 'Bearer ' + self.bearer
|
'Authorization': 'Bearer ' + self.bearer
|
||||||
@@ -1429,8 +1420,7 @@ class CreateAPProfiles:
|
|||||||
msg='AP profile for ' + mode + ' tests could not be created using API')
|
msg='AP profile for ' + mode + ' tests could not be created using API')
|
||||||
self.test_cases["ap_"+self.mode] = "failed"
|
self.test_cases["ap_"+self.mode] = "failed"
|
||||||
|
|
||||||
self.ap_profile = self.cloud.set_ap_profile(eq_id, self.test_profile_id, self.command_line_args.sdk_base_url,
|
self.ap_profile = self.cloud.set_ap_profile(eq_id, self.test_profile_id)
|
||||||
self.bearer)
|
|
||||||
|
|
||||||
def cleanup_profile(self):
|
def cleanup_profile(self):
|
||||||
pass
|
pass
|
||||||
|
|||||||
@@ -28,15 +28,6 @@ class TestRail_Client:
|
|||||||
if command_line_args.testrail_user_id == "NONE":
|
if command_line_args.testrail_user_id == "NONE":
|
||||||
self.use_testrails = False
|
self.use_testrails = False
|
||||||
|
|
||||||
def __init__(self, url, id, passwd):
|
|
||||||
self.user = id
|
|
||||||
self.password = passwd
|
|
||||||
base_url = url
|
|
||||||
if not base_url.endswith('/'):
|
|
||||||
base_url += '/'
|
|
||||||
self.__url = base_url + 'index.php?/api/v2/'
|
|
||||||
self.use_testrails = True
|
|
||||||
|
|
||||||
|
|
||||||
def send_get(self, uri, filepath=None):
|
def send_get(self, uri, filepath=None):
|
||||||
"""Issue a GET request (read) against the API.
|
"""Issue a GET request (read) against the API.
|
||||||
|
|||||||
@@ -145,8 +145,8 @@ def add_base_parse_args(parser):
|
|||||||
default="password")
|
default="password")
|
||||||
parser.add_argument("--testrail-run-prefix", type=str, help="testrail run prefix",
|
parser.add_argument("--testrail-run-prefix", type=str, help="testrail run prefix",
|
||||||
default="prefix-1")
|
default="prefix-1")
|
||||||
parser.add_argument("--milestone", type=str, help="testrail milestone ID",
|
parser.add_argument("--testrail-milestone", type=str, help="testrail milestone ID",
|
||||||
default="milestone-1")
|
default="milestone-1")
|
||||||
|
|
||||||
parser.add_argument("--lanforge-ip-address", type=str, help="ip address of the lanforge gui",
|
parser.add_argument("--lanforge-ip-address", type=str, help="ip address of the lanforge gui",
|
||||||
default="127.0.0.1")
|
default="127.0.0.1")
|
||||||
@@ -288,8 +288,8 @@ def add_base_parse_args_pytest(parser):
|
|||||||
default="password")
|
default="password")
|
||||||
parser.addoption("--testrail-run-prefix", type=str, help="testrail run prefix",
|
parser.addoption("--testrail-run-prefix", type=str, help="testrail run prefix",
|
||||||
default="prefix-1")
|
default="prefix-1")
|
||||||
parser.addoption("--milestone", type=str, help="testrail milestone ID",
|
parser.addoption("--testrail-milestone", type=str, help="testrail milestone ID",
|
||||||
default="milestone-1")
|
default="milestone-1")
|
||||||
|
|
||||||
parser.addoption("--lanforge-ip-address", type=str, help="ip address of the lanforge gui",
|
parser.addoption("--lanforge-ip-address", type=str, help="ip address of the lanforge gui",
|
||||||
default="127.0.0.1")
|
default="127.0.0.1")
|
||||||
@@ -403,3 +403,4 @@ class UnitTestBase:
|
|||||||
self.cloud: CloudSDK = CloudSDK(self.command_line_args)
|
self.cloud: CloudSDK = CloudSDK(self.command_line_args)
|
||||||
self.bearer = self.cloud.get_bearer(self.cloudSDK_url, cloud_type)
|
self.bearer = self.cloud.get_bearer(self.cloudSDK_url, cloud_type)
|
||||||
self.customer_id = self.command_line_args.customer_id
|
self.customer_id = self.command_line_args.customer_id
|
||||||
|
|
||||||
|
|||||||
@@ -124,7 +124,7 @@ def setup_testrails(request, instantiate_testrail, access_points):
|
|||||||
# TODO: Should not be session wide I think, you will want to run different
|
# TODO: Should not be session wide I think, you will want to run different
|
||||||
# configurations (bridge, nat, vlan, wpa/wpa2/eap, etc
|
# configurations (bridge, nat, vlan, wpa/wpa2/eap, etc
|
||||||
@pytest.fixture(scope="session")
|
@pytest.fixture(scope="session")
|
||||||
def setup_cloudsdk(request, instantiate_cloudsdk):
|
def setup_cloudsdk(request, instantiate_cloudsdk, instantiate_testrail):
|
||||||
# snippet to do cleanup after all the tests are done
|
# snippet to do cleanup after all the tests are done
|
||||||
def fin():
|
def fin():
|
||||||
print("Cloud SDK cleanup done")
|
print("Cloud SDK cleanup done")
|
||||||
@@ -138,7 +138,6 @@ def setup_cloudsdk(request, instantiate_cloudsdk):
|
|||||||
|
|
||||||
cloud.assert_bad_response = True
|
cloud.assert_bad_response = True
|
||||||
|
|
||||||
model_id = command_line_args.model
|
|
||||||
equipment_id = instantiate_cloudsdk.equipment_id
|
equipment_id = instantiate_cloudsdk.equipment_id
|
||||||
|
|
||||||
print("equipment-id: %s" % (equipment_id))
|
print("equipment-id: %s" % (equipment_id))
|
||||||
@@ -164,7 +163,7 @@ def setup_cloudsdk(request, instantiate_cloudsdk):
|
|||||||
radius_name = "%s-%s-%s" % (command_line_args.testbed, fw_model, "Radius")
|
radius_name = "%s-%s-%s" % (command_line_args.testbed, fw_model, "Radius")
|
||||||
|
|
||||||
print("Create profiles")
|
print("Create profiles")
|
||||||
ap_object = CreateAPProfiles(command_line_args, cloud=cloud, client=client, fw_model=fw_model)
|
ap_object = CreateAPProfiles(command_line_args, cloud=cloud, client=instantiate_testrail, fw_model=fw_model)
|
||||||
|
|
||||||
# Logic to create AP Profiles (Bridge Mode)
|
# Logic to create AP Profiles (Bridge Mode)
|
||||||
|
|
||||||
@@ -230,16 +229,12 @@ def update_firmware(request, setup_testrails, instantiate_jFrog, instantiate_clo
|
|||||||
|
|
||||||
@pytest.fixture(scope="session")
|
@pytest.fixture(scope="session")
|
||||||
def instantiate_cloudsdk(request):
|
def instantiate_cloudsdk(request):
|
||||||
rv = CloudSDK(
|
command_line_args = create_command_line_args(request)
|
||||||
request.config.getini("sdk-user-id"),
|
rv = CloudSDK(command_line_args)
|
||||||
request.config.getini("sdk-user-password"),
|
|
||||||
request.config.getini("sdk-base-url"),
|
|
||||||
False # verbose TODO: Make this configurable
|
|
||||||
)
|
|
||||||
|
|
||||||
equipment_id = request.config.getoption("--equipment-id")
|
equipment_id = request.config.getoption("--equipment-id")
|
||||||
if equipment_id == "-1":
|
if equipment_id == "-1":
|
||||||
eq_id = ap_ssh_ovsh_nodec(create_command_line_args(request), 'id')
|
eq_id = ap_ssh_ovsh_nodec(command_line_args, 'id')
|
||||||
print("EQ Id: %s" % (eq_id))
|
print("EQ Id: %s" % (eq_id))
|
||||||
|
|
||||||
# Now, query equipment to find something that matches.
|
# Now, query equipment to find something that matches.
|
||||||
@@ -260,12 +255,8 @@ def instantiate_cloudsdk(request):
|
|||||||
yield rv
|
yield rv
|
||||||
|
|
||||||
@pytest.fixture(scope="session")
|
@pytest.fixture(scope="session")
|
||||||
def instantiate_testrail(request):
|
def instantiate_testrail(request):
|
||||||
yield TestRail_Client(
|
yield TestRail_Client(create_command_line_args(request))
|
||||||
request.config.getini("testrail-base-url"),
|
|
||||||
request.config.getini("testrail-user-id"),
|
|
||||||
request.config.getoption("--testrail-user-password")
|
|
||||||
)
|
|
||||||
|
|
||||||
@pytest.fixture(scope="session")
|
@pytest.fixture(scope="session")
|
||||||
def instantiate_jFrog(request):
|
def instantiate_jFrog(request):
|
||||||
|
|||||||
@@ -53,4 +53,12 @@ def create_command_line_args(request):
|
|||||||
command_line_args.ssid_5g_wpa2 = request.config.getoption("--ssid-5g-wpa2")
|
command_line_args.ssid_5g_wpa2 = request.config.getoption("--ssid-5g-wpa2")
|
||||||
command_line_args.psk_2g_wpa2 = request.config.getoption("--psk-2g-wpa2")
|
command_line_args.psk_2g_wpa2 = request.config.getoption("--psk-2g-wpa2")
|
||||||
command_line_args.psk_5g_wpa2 = request.config.getoption("--psk-5g-wpa2")
|
command_line_args.psk_5g_wpa2 = request.config.getoption("--psk-5g-wpa2")
|
||||||
|
|
||||||
|
command_line_args.testrail_base_url = request.config.getoption("--testrail-base-url")
|
||||||
|
command_line_args.testrail_project = request.config.getoption("--testrail-project")
|
||||||
|
command_line_args.testrail_user_id = request.config.getoption("--testrail-user-id")
|
||||||
|
command_line_args.testrail_user_password = request.config.getoption("--testrail-user-password")
|
||||||
|
command_line_args.testrail_run_prefix = request.config.getoption("--testrail-run-prefix")
|
||||||
|
command_line_args.testrail_milestone = request.config.getoption("--testrail-milestone")
|
||||||
|
|
||||||
return command_line_args
|
return command_line_args
|
||||||
|
|||||||
@@ -41,19 +41,19 @@ class Test24ghz(object):
|
|||||||
if setup_testrails > 0:
|
if setup_testrails > 0:
|
||||||
instantiate_testrail.update_testrail(case_id=2835, run_id=setup_testrails, status_id=1, msg="testing")
|
instantiate_testrail.update_testrail(case_id=2835, run_id=setup_testrails, status_id=1, msg="testing")
|
||||||
|
|
||||||
@pytest.mark.featureB
|
#@pytest.mark.featureB
|
||||||
def test_feature_b(self):
|
#def test_feature_b(self):
|
||||||
pass
|
# pass
|
||||||
|
|
||||||
@pytest.mark.featureC
|
#@pytest.mark.featureC
|
||||||
def test_feature_c(self):
|
#def test_feature_c(self):
|
||||||
assert 1 == 0
|
# assert 1 == 0
|
||||||
|
|
||||||
@pytest.mark.featureD
|
#@pytest.mark.featureD
|
||||||
def test_feature_d(self):
|
#def test_feature_d(self):
|
||||||
pytest.skip("speedup")
|
# pytest.skip("speedup")
|
||||||
|
|
||||||
@pytest.mark.xfail
|
#@pytest.mark.xfail
|
||||||
@pytest.mark.featureE
|
#@pytest.mark.featureE
|
||||||
def test_feature_e(self):
|
#def test_feature_e(self):
|
||||||
assert 1 == 0
|
# assert 1 == 0
|
||||||
|
|||||||
Reference in New Issue
Block a user