-
Notifications
You must be signed in to change notification settings - Fork 170
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
improve Python unit testing and refactor _validators.py (#2120)
* refactor: apply Guard clauses in _validators.py to simplify code * fix _validators.py trailing whitespace * improve python test tructure, include execution of unit tests in make test-python * crate make directive to run python unit tests, add unit tests for azext_aro._validators.validate_cidr * add tests for test_validate_client_id and include test cases description * add unit tests for validate_client_secret from azext_aro._validators * add explicit fields to named tuple in test cases in test_validators.py * add two test scenarios for validate_cluster_resource_group * simplify mocks * add test case for test_validate_cluster_resource_group * improve test descriptions * add test_validate_disk_encryption_set test to test validate_disk_encryption_set * add test cases to test_validate_disk_encryption_set() * refactor test_validator.py to use classes instead of namedtuples. Use mocks instead of specific defined classes * refactor (simplify code): remove explicit assignemnt to None when it is the default value * create test_validate_domain() with 1st test case * add test case, domain with '_' * explicit import of unittest.TestCase * fix test message in test_validate_domain * finish test_validate_domain() * finish test_validate_sdn() and test_validate_pull_secret() * create test_validate_subnet() with first test case * finish test_validate_subnet() and minor refactor in _validators.py * create test_validate_subnets() and add first test case * finish validate_vnet_resource_group_name() * finish test_validate_worker_count() of test_validators.py and simple refactor in _validators.py * finish test_validate_worker_vm_disk_size_gb() * refactor _validators.py * add test_validate_refresh_cluster_credentials() and minor refactor of test_validators() * refactor _test_validators.py to use pytest, create script and invoke it from Makefile * simplify test_validate_cidr() using pytest.mark.parametrize * simplify some tests using pytest.mark.parametrize * finish applying pytest.mark.parametrize * clean up Makefile test-python * add blank line to hack/unit-test-python.sh * fix typo in test case * fix mega-linter error, blank space * fix test case to fail due to invalid range * fix typo in beeing to be being * remove redundant test case * reformat code for better readability * add missing license to __init__.py files
- Loading branch information
Aldo Fuster Turpin
authored
Jun 9, 2022
1 parent
bc4b648
commit cc111ee
Showing
8 changed files
with
944 additions
and
81 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#!/bin/bash | ||
|
||
# This script executes Python unit tests. It first tries to activate the virtual environment, | ||
# but if it does not exist it will be created and then activated. | ||
# When executing "pytest" command, it ignores integration test folder as | ||
# this script is intended to just execute unit tests. | ||
|
||
. pyenv/bin/activate || python3 -m venv pyenv && . pyenv/bin/activate | ||
pip install pytest | ||
cd python | ||
pytest --ignore=az/aro/azext_aro/tests/latest/integration |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# Copyright (c) Microsoft Corporation. | ||
# Licensed under the Apache License 2.0. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# Copyright (c) Microsoft Corporation. | ||
# Licensed under the Apache License 2.0. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.