Repository navigation
Conversation
This is a draft to test unittest implementations for the server. Implement unittests using `werkzeug.test.Client` to test the `/shells` endpoint, as example. Each endpoint and method is tested for success and possible failures. The object store is reset prior to every test case. Tests are repeated for `application/json` and `application/xml` Content-Types. Therfore test are written against an abstract `FromatClient` that covers the details of (de-)serialization behind a simple API for requesting and parsing. Therefore the base class defining the test cases (`_ShellsEndpointTest`) is disabled for testing. Two subclasses are derived from this class, one for each format, that define the correct `FormatClient` and execute the tests.
…umbnail endpoint.
…ation thumbnail endpoint." This reverts commit 496190f, which held the content of eclipse-basyx#618. This was added for testing purpose only. Merge `develop` into this branch, after the PR was closed to obtain the same result.
For now the `/submodel-elements` paths are excluded
Added test class `TestPagination` to `test_base.py` that ensures pagination by following `cursor` value correctly assembles all items. Additionally, all endpoints, that should support pagination are checked if they do so.
To separate testing of the pagination logic from working endpoints, the shared function for creatin paginated responses is now tested directly. The base tests on paginated endpoints remain.
In the first version of the tests for the Discovery API, when data needed to be added to the DiscoveryStore, this was done through the `POST /lookup/shells/<aasId>` endpoint. To decouple endpoint tests from each other, the data insertion is now done directly via the DiscoveryStore.
JAB1305
reviewed
Sep 25, 2026
hpoeche
marked this pull request as ready for review
September 27, 2026 17:20
Contributor
Author
|
Before we merge, we must check if #642 is already resolved and adapt our changes if so. |
s-heppner
requested changes
Oct 5, 2026
s-heppner
left a comment
Member
There was a problem hiding this comment.
Can someone please also fix the merge conflicts?
Comment on lines
+232
to
+235
| def assert_error(self, response: TestResponse, status_code: int) -> None: | ||
| self.assertEqual(status_code, response.status_code, msg=response.get_data(as_text=True)) | ||
| self.assertIn("success", response.get_data(as_text=True), msg=response.get_data(as_text=True)) | ||
|
|
Member
There was a problem hiding this comment.
What if there's a string like "This action was unsuccessful." somewhere in the response body? I don't doubt that this isn't the case rigt now, but this check seems weak and might falsely state success when there was none.
Contributor
There was a problem hiding this comment.
Thank you for checking. assert_error() now parses the actual success field instead of doing a substring check on the text.
| # to that file to override the defaults defined here. | ||
|
|
||
| [server] | ||
| url = http://localhost:8080/api/v3.1 |
Member
There was a problem hiding this comment.
Isn't this a problem to hardcode this, value, when it should use the single point of truth from versions.toml?
This was referenced Oct 6, 2026
Drop the per-descriptor `DESCRIPTOR_TYPE_TO_STRING` lookup and nested helper function; serialize both descriptor lists once and inject the literal modelType string in two plain loops instead, matching the pattern already used in `services/support.py`.
Resolved conflicts in CONTRIBUTING.md
Splits the definition of the server `url` value into `host` and `base_path` in the `test_config.default.ini`. The values are concatenated in `test_helpers.py` to define the `url` value. If `base_path` is set to `DEFAULT`, its value is read from `versions.toml`. This is the default value for `base_path` so the tests do not fail on API version bumps.
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Changes
This PR adds unit and integration test to the previously untested server package. In detail the following test setup is used
Unit Testing
Unit tests are primarily written against the served API, employing
werkzeug.test.Clientto test thewerkzeugbased API interfaces.All three server interfaces (
repository,discovery,registry) are tested this way.Format specific testing
All implemented endpoints are tested with all supported
Content-Types and for all possible responses.Responses are not deserialized using the SDK adapter, because round-trip serialization-deserialization is already tested in the SDK. However, the correctness of responses are still verified by parsing them using standard libraries (
jsonandlxml.etree) and checking for specific expected data.To reduce repetition of test for both Content-Types
application/jsonandapplication/xml,test/interfaces/format_utils.pydefines a format-agnostic wrapperFormatClientofwerkzeug.test.Clientthat has subclassesJsonFormatClientandXmlFormatClienthandling serialization of request bodies as well as parsing and checking as described above.The test cases are written against this format-agnostic
FormatClient. Function decoratorswith_json_client/with_xml_clientare used to create separate test cases with the correct client at runtime.Coverage
In general, endpoints are tested for successful response and all error codes, defined in the specification. More specifically:
GETendpoints are tested forPOSTendpoints are tested for*ObjectStorePUTendpoints are tested for*ObjectStoreis altered correctlyDELETEendpoints are tested for*ObjectStoreAdditional Tests
While the test above test if the endpoints behavior is compliant to the specification, some additional tests directly test the code in
base.py:base.py, therefore we extensively test it separate for correct logic (pages build a partition of complete set) and parameter handling.JsonResponseandXmlResponseis tested separatelyHTTPApiDecoder), is already tested in the test cases above.Entrypoint Testing
The entrypoints
run_registry.pyandrun_discovery.py(fromserver/app/services) that start up the respective server profile, configure the storage and the API base path via environment variables. We test that setting these variables results in the correct storage setup inside the tests inserver/test/services. We need to useimportlibto run the code because the entrypoints are written as scripts, that run their code at import time. Therefore no coverage data can be collected.Integration Testing
To ensure correct setup of uWSGI, nginx and supervisor inside the docker container, we run basic integration tests.
Therefore,
server/test/docker_integration/has one test module per profile (repository, registry, discovery) that runs against a real, already-running server, checking/descriptionand a full create/retrieve/delete roundtrip per profile.By default these tests skip if no server is reachable (like
test_couchdb.pyin the SDK). SettingREQUIRE_SERVER_INTEGRATION_TESTSmakes them fail instead of skip. We use this setting in theserver-dockerCI job, which now builds and tests all three profiles.