Skip to content

Commit 030803c

Browse files
authored
Function test: Improved conftest.py, completed User, added BaseResource (#2072)
* Function test: Improved conftest.py, completed User, added BaseResource Details: * Redesigned the JSON schema for the YAML test files: - Added support for defining setup resources at the test file level and at the testcase level by adding a new property 'setup'. That required the list of testcases to be moved under a top-level property 'testcases'. The setup objects are stored in a dictionary and can be looked up by URI. - Moved the definition of a HMC session from a top-level hmc_session property in each testcase to become definable at the test file level and at the testcase level, within the new 'setup' property. - Defined a schema definition 'value' that represents a Python value for method parameters, method return values, or property values. That fixed the issue that previously, zhmcclient resource and manager objects could only be represented as single objects but not as items in a list or dict. Also, zhmcclient resource and manager objects are now referenced via URI lookup in the dictionary resulting from the setup resources. - Changed the way the target object of the test is specified, to also use the same approach as for 'value', except that it must be either a resource or manager object. - Changed the way method parameter values and method return values are specified in the testcase YAML, to use the 'value' definition. * Adjusted the test code in conftest.py to the new test file structure. * In conftest.py, introduced a class TestcaseData in order to isolate the data properties pytest does not care about from other properties pytest does care about. Before that, it happened that a test property happened to use the name of a property known by pytest. * In conftest.py, fixed the issue that requests_mock records only the last HTTP request/response pair, by maintaning our own list of requests. Apparently, that limitation in requests_mock is intentional to keep it simple. The request_mock pytest fixture solves that issue, but we cannot use that fixture because we do not have pytest test functions. * In conftest.py, fixed the issue that the zhmcclient result was compared with == which lead to comparison failures for different but equal objects, and for zhmcclient.BaseResource objects due to their timestamp property, and for immutabledict objects returned by some properties. This was fixed by adding an assert_result() method that performs these comparisons more thoughtfully. * Adjusted the existing test_user.yaml test file to the new schema, and added testcases for the remaining methods and properties of zhmcclient.User, except for inherited ones. * Added a new test file test_resource.yaml and defined testcases for any methods and properties inherited into resource classes. Signed-off-by: Andreas Maier <maiera@de.ibm.com> * Squash: Fixed uri-reference format, enabled format checker Signed-off-by: Andreas Maier <maiera@de.ibm.com> --------- Signed-off-by: Andreas Maier <maiera@de.ibm.com>
1 parent 12d3668 commit 030803c

6 files changed

Lines changed: 1882 additions & 482 deletions

File tree

dev-requirements.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ more-itertools>=4.0.0
3333
pytz>=2019.1,!=2024.2,!=2025.1,!=2025.2
3434
# Python's built-in zoneinfo module needs the tzdata package on Windows.
3535
tzdata>=2023.4; sys_platform == 'win32'
36+
# # rfc3986-validator is needed for jsonschema validation of format=uri-reference
37+
# rfc3986-validator>=0.1.1
3638

3739
# packaging is used by pytest, pip-check-reqs, sphinx
3840
packaging>=24.2

minimum-constraints-develop.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ pytz==2019.1
3333
requests-mock==1.6.0
3434
requests-toolbelt==0.8.0
3535
tzdata==2023.4; sys_platform == 'win32'
36+
# rfc3986-validator==0.1.1
3637

3738
# Unit test (indirect dependencies):
3839
# decorator: covered in direct deps for installation

0 commit comments

Comments
 (0)