Skip to content

Conversation

@sven-rosenzweig
Copy link
Contributor

@sven-rosenzweig sven-rosenzweig commented Sep 4, 2024

Introduce GitHub Actions for rate limit middleware

This PR adds GitHub Actions to the rate limit middleware, inspired by the Neutron network driver's GitHub Actions setup. It ensures that Pep8 checks and unit tests are automatically executed when a PR is created on the master branch.

As part of enabling these actions, test execution issues were resolved, and all existing Pep8 violations were fixed.

Remove py35, py36 and add py38 to tox environments.

Add enviroment for running pep8 and funcional tests.
Two main issues caused the test execution to fail.

Issue 1:
The tests were failing due to a relative import not being found,
resulting in the following error: ImportError: attempted relative import with no known parent package.

Switching to absolute imports, as generally recommended, did not resolve
the issue due to a circular reference.
The problem arises because a Python file named rate_limit.py exists within the rate_limit module.
When trying to import within the module using from rate_limit, it attempts to import itself,
leading to the following error: ImportError: cannot import name 'backend' from partially initialized module 'rate_limit' (most likely due to a circular import).

Issue 2:
Middleware tests require a running Redis database to determine
if requests should be rate limited via a Lua script.
This commit mocks the result of the Lua script,
eliminating the need for an active Redis instance during test execution.
Fix flake8 findings and ignore D107 'Missing docstring in __init__'.
Github action runs tests and pep8 on each pull request to master.

Updated flake8-docstring to latest version as this caused
the action execution to fail.
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