Commit 7674129
committed
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>1 parent d9af6b6 commit 7674129
File tree
4 files changed
+1316
-481
lines changed- tests/function
- schemas
4 files changed
+1316
-481
lines changed
0 commit comments