Skip to content

Conversation

@odesenfans
Copy link
Collaborator

@odesenfans odesenfans commented May 9, 2022

It is now possible to test API endpoints with the test client of aiohttp.
Added an example test that checks that the /version endpoint returns
the expected version.

Refactored the declaration of endpoints in the initialization of
the app. We now have a register_routes function centralized in
a single module. All references to the global app object inside the
implementation of endpoints were replaced by accesses to request.app.
This allows to import the app object, configured properly, without
importing other files.

@odesenfans odesenfans changed the title [Tests] Make HTTP endpoints testable [Tests] Make API endpoints testable May 9, 2022
It is now possible to write API tests with the test client of aiohttp.
Added an example test that checks that the /version endpoint returns
the expected version.

Refactored the declaration of endpoints in the initialization of
the app. We now have a `register_routes` function centralized in
a single module. All references to the global app object inside the
implementation of endpoints were replaced by accesses to `request.app`.
This allows to import the app object, configured properly, without
importing other files.
)


def register_routes(app: web.Application):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1 to centralize all routes. Should we also move them to a new file src/aleph/web/routes.py to make it easier to find ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok for me.

@hoh hoh merged commit 16ce8dd into aleph-im:dev May 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants