mirror of
				https://github.com/Telecominfraproject/wlan-testing.git
				synced 2025-10-30 18:38:06 +00:00 
			
		
		
		
	initial pytest core redone
This commit is contained in:
		
							
								
								
									
										2
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							| @@ -150,3 +150,5 @@ pytest/* | |||||||
| !pytest/helpers | !pytest/helpers | ||||||
| !pytest/pytest.ini | !pytest/pytest.ini | ||||||
| pytest/nightly*log | pytest/nightly*log | ||||||
|  |  | ||||||
|  | test_everything.xml | ||||||
							
								
								
									
										29
									
								
								libs/cloudsdk/2.4ghz/test_generic.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										29
									
								
								libs/cloudsdk/2.4ghz/test_generic.py
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,29 @@ | |||||||
|  | import pytest | ||||||
|  |  | ||||||
|  | @pytest.mark.usefixtures('setup_cloudsdk') | ||||||
|  | @pytest.mark.usefixtures('update_firmware') | ||||||
|  | @pytest.mark.UHF # example of a class mark | ||||||
|  | class Test24ghz(object): | ||||||
|  |     @pytest.mark.wpa2 | ||||||
|  |     def test_single_client_wpa2(self, setup_cloudsdk, update_firmware): | ||||||
|  |         print(setup_cloudsdk) | ||||||
|  |         assert 1 == 0 | ||||||
|  |  | ||||||
|  |     @pytest.mark.open | ||||||
|  |     def test_single_client_open(self, setup_cloudsdk, update_firmware): | ||||||
|  |         print(setup_cloudsdk) | ||||||
|  |         assert 1 == 0 | ||||||
|  |  | ||||||
|  | @pytest.mark.usefixtures('setup_cloudsdk') | ||||||
|  | @pytest.mark.usefixtures('update_firmware') | ||||||
|  | @pytest.mark.SHF # example of a class mark | ||||||
|  | class Test50ghz(object): | ||||||
|  |     @pytest.mark.wpa2 | ||||||
|  |     def test_single_client_wpa2(self, setup_cloudsdk, update_firmware): | ||||||
|  |         print(setup_cloudsdk) | ||||||
|  |         assert 1 == 0 | ||||||
|  |  | ||||||
|  |     @pytest.mark.open | ||||||
|  |     def test_single_client_open(self, setup_cloudsdk, update_firmware): | ||||||
|  |         print(setup_cloudsdk) | ||||||
|  |         assert 1 == 0 | ||||||
| @@ -82,3 +82,9 @@ Currently the plan is to use pytest integrated with [allure](https://docs.qameta | |||||||
| 1. Do not use old style string formatting: `"Hello %s" % var`; use `f"Hello {var}` instead | 1. Do not use old style string formatting: `"Hello %s" % var`; use `f"Hello {var}` instead | ||||||
| 2. use `"""` in Docstrings | 2. use `"""` in Docstrings | ||||||
| 3. todo | 3. todo | ||||||
|  |  | ||||||
|  | ### Useful links | ||||||
|  |  | ||||||
|  | https://docs.pytest.org/en/latest/example/markers.html   | ||||||
|  | https://docs.pytest.org/en/latest/usage.html   | ||||||
|  | http://pythontesting.net/framework/pytest/pytest-introduction/ | ||||||
							
								
								
									
										17
									
								
								libs/cloudsdk/configuration_data.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										17
									
								
								libs/cloudsdk/configuration_data.py
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,17 @@ | |||||||
|  | """ | ||||||
|  |     A set of constants describing AP profiles | ||||||
|  | """ | ||||||
|  |  | ||||||
|  | PROFILE_DATA = { | ||||||
|  |     "test_single_client_wpa2": { | ||||||
|  |         "profile_name": "test-ssid-wpa2", | ||||||
|  |         "ssid_name": "test_wpa2_test", | ||||||
|  |         "mode": "BRIDGE", | ||||||
|  |         "security_key": "testing12345" | ||||||
|  |     }, | ||||||
|  |     "test_single_client_open": { | ||||||
|  |         "profile_name": "test-ssid-open", | ||||||
|  |         "ssid_name": "test_open", | ||||||
|  |         "mode": "BRIDGE" | ||||||
|  |     } | ||||||
|  | } | ||||||
							
								
								
									
										78
									
								
								libs/cloudsdk/conftest.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										78
									
								
								libs/cloudsdk/conftest.py
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,78 @@ | |||||||
|  | # import files in the current directory | ||||||
|  | import sys | ||||||
|  | import os | ||||||
|  | sys.path.append( | ||||||
|  |     os.path.dirname( | ||||||
|  |         os.path.realpath( __file__ ) | ||||||
|  |     ) | ||||||
|  | ) | ||||||
|  |  | ||||||
|  | import pytest | ||||||
|  | from configuration_data import PROFILE_DATA | ||||||
|  |  | ||||||
|  | def pytest_addoption(parser): | ||||||
|  |     parser.addini("jfrog-base-url", "jfrog base url") | ||||||
|  |     parser.addini("jfrog-user-id", "jfrog username") | ||||||
|  |     parser.addini("jfrog-user-password", "jfrog password") | ||||||
|  |     parser.addini("sdk-base-url", "cloud sdk base url") | ||||||
|  |     parser.addini("sdk-user-id", "cloud sdk username") | ||||||
|  |     parser.addini("sdk-user-password", "cloud sdk user password") | ||||||
|  |     parser.addini("sdk-customer-id", "cloud sdk customer id for the access points") | ||||||
|  |     parser.addini("testrail-base-url", "testrail base url") | ||||||
|  |     parser.addini("testrail-project", "testrail project name to use to generate test reports") | ||||||
|  |     parser.addini("testrail-user-id", "testrail username") | ||||||
|  |     parser.addini("testrail-user-password", "testrail user password") | ||||||
|  |     parser.addini("lanforge-ip-address", "LANforge ip address to connect to") | ||||||
|  |     parser.addini("lanforge-port-number", "LANforge port number to connect to") | ||||||
|  |     parser.addini("lanforge-radio", "LANforge radio to use") | ||||||
|  |     parser.addini("lanforge-ethernet-port", "LANforge ethernet adapter to use") | ||||||
|  |  | ||||||
|  |     # change behaviour | ||||||
|  |     parser.addoption( | ||||||
|  |         "--skip-update-firmware", | ||||||
|  |         action="store_true", | ||||||
|  |         default=False, | ||||||
|  |         help="skip updating firmware on the AP (useful for local testing)" | ||||||
|  |     ) | ||||||
|  |     # this has to be the last argument | ||||||
|  |     # example: --access-points ECW5410 EA8300-EU | ||||||
|  |     parser.addoption( | ||||||
|  |         "--access-points", | ||||||
|  |         nargs="+", | ||||||
|  |         default=[ "ECW5410" ], | ||||||
|  |         help="list of access points to test" | ||||||
|  |     ) | ||||||
|  |  | ||||||
|  | def pytest_generate_tests(metafunc): | ||||||
|  |     metafunc.parametrize("access_points", metafunc.config.getoption('--access-points'), scope="session") | ||||||
|  |  | ||||||
|  | # run something after all tests are done regardless of the outcome | ||||||
|  | def pytest_unconfigure(config): | ||||||
|  |     print("Tests cleanup done") | ||||||
|  |  | ||||||
|  | @pytest.fixture(scope="function") | ||||||
|  | def setup_cloudsdk(request, instantiate_cloudsdk): | ||||||
|  |     def fin(): | ||||||
|  |         print(f"Cloud SDK cleanup for {request.node.originalname}") | ||||||
|  |     request.addfinalizer(fin) | ||||||
|  |     yield PROFILE_DATA[request.node.originalname] | ||||||
|  |  | ||||||
|  | @pytest.fixture(scope="session") | ||||||
|  | def update_firmware(request, instantiate_jFrog, instantiate_cloudsdk, retrieve_latest_image, access_points): | ||||||
|  |     if request.config.getoption("--skip-update-firmware"): | ||||||
|  |         return | ||||||
|  |     yield "update_firmware" | ||||||
|  |  | ||||||
|  | @pytest.fixture(scope="session") | ||||||
|  | def retrieve_latest_image(request, access_points): | ||||||
|  |     if request.config.getoption("--skip-update-firmware"): | ||||||
|  |         return | ||||||
|  |     yield "retrieve_latest_image" | ||||||
|  |  | ||||||
|  | @pytest.fixture(scope="session") | ||||||
|  | def instantiate_cloudsdk(request): | ||||||
|  |     yield "instantiate_cloudsdk" | ||||||
|  |  | ||||||
|  | @pytest.fixture(scope="session") | ||||||
|  | def instantiate_jFrog(request): | ||||||
|  |     yield "instantiate_jFrog" | ||||||
							
								
								
									
										29
									
								
								libs/cloudsdk/pytest.ini
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										29
									
								
								libs/cloudsdk/pytest.ini
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,29 @@ | |||||||
|  | [pytest] | ||||||
|  | addopts= --junitxml=test_everything.xml | ||||||
|  | # jFrog parameters | ||||||
|  | jfrog-base-url=tip.jFrog.io/artifactory/tip-wlan-ap-firmware | ||||||
|  | jfrog-user-id=tip-read | ||||||
|  | jfrog-user-password=tip-read | ||||||
|  | # Cloud SDK parameters | ||||||
|  | sdk-base-url=wlan-portal-svc.cicd.lab.wlan.tip.build | ||||||
|  | sdk-user-id=support@example.com | ||||||
|  | sdk-user-password=support | ||||||
|  | # Testrails parameters | ||||||
|  | testrail-base-url=telecominfraproject.testrail.com | ||||||
|  | testrail-project=opsfleet-wlan | ||||||
|  | testrail-user-id=gleb@opsfleet.com | ||||||
|  | testrail-user-password=use_command_line_to_pass_this | ||||||
|  | # LANforge | ||||||
|  | lanforge-ip-address=localhost | ||||||
|  | lanforge-port-number=8080 | ||||||
|  | lanforge-radio=wiphy4 | ||||||
|  | lanforge-ethernet-port=eth2 | ||||||
|  |  | ||||||
|  | # Cloud SDK settings | ||||||
|  | sdk-customer-id=2 | ||||||
|  |  | ||||||
|  | markers = | ||||||
|  |     UHF: marks tests as using 2.4 ghz frequency | ||||||
|  |     SHF: marks tests as using 5.0 ghz frequency | ||||||
|  |     open: marks tests as using no security | ||||||
|  |     wpa2: marks tests as using wpa2 security | ||||||
| @@ -1,5 +1,5 @@ | |||||||
| """ | """ | ||||||
|     A set of constants to use throughtout the tests |     A set of constants describing cloud controllers properties | ||||||
| """ | """ | ||||||
|  |  | ||||||
| SDK_BASE_URLS = { | SDK_BASE_URLS = { | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Gleb Boushev
					Gleb Boushev