-
-
Notifications
You must be signed in to change notification settings - Fork 88
[tests:fix] Switched to ChannelsLiveServerTestCase #466 #465
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[tests:fix] Switched to ChannelsLiveServerTestCase #466 #465
Conversation
ee2d9f8 to
3d223e8
Compare
nemesifier
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks on the right track to me.
Question: how can we be sure it's working as expected and there's no JS errors?
Wouldn't it make sense to add at least one test for this?
CI is not passing on Django 5.2, why is that?
tests/openwisp2/settings.py
Outdated
| 'ENGINE': 'django.db.backends.sqlite3', | ||
| 'NAME': 'openwisp_utils.db', | ||
| 'TEST': { | ||
| 'NAME': 'openwisp_utils_test.db', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this needed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this needed?
Without this, it was causing this error
raise ImproperlyConfigured(
django.core.exceptions.ImproperlyConfigured: ChannelLiveServerTestCase can not be used with in memory databases
As the ASGI server requires a physical database
|
|
||
|
|
||
| class TestMenu(SeleniumTestMixin, StaticLiveServerTestCase): | ||
| class TestMenu(SeleniumTestMixin, ChannelsLiveServerTestCase): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's tag all these tests (as we're doing in other modules for the selenium tests) so we can exclude them from the parallel run.
.github/workflows/ci.yml
Outdated
| if: ${{ !cancelled() && steps.deps.conclusion == 'success' }} | ||
| run: | | ||
| coverage run runtests.py --parallel | ||
| coverage run runtests.py |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Once we have tagged the tests, we can modify the runtests.py script to handle which tests must not be run in parallel.
Since this can get complex in each module, I insisted with @pandafy that we hide this complexity from contributors in the runtests.py script, which thanks to a few lines of comments is also useful to us maintainers to remember why it's done that way.
See the runtests.py script in the controller module:
https://github.com/openwisp/openwisp-controller/blob/master/runtests.py#L46-L47
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need to handle this.
There is an open issue in django channels for ChannelsLiveServerTestCase is broken in django 5.2 |
a6a7f2b to
6a8a34a
Compare
setup.py
Outdated
| "channels[daphne]~=4.2.0", | ||
| "channels[daphne]@" | ||
| "git+https://github.com/openwisp/channels.git@" | ||
| "issues/2148-ChannelsLiveServerTestCase-Django52-compatible#egg=channels[daphne]", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can update this now as the PR has been merged.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated!
.github/workflows/ci.yml
Outdated
| if: ${{ !cancelled() && steps.deps.conclusion == 'success' }} | ||
| run: | | ||
| coverage run runtests.py --parallel | ||
| coverage run runtests.py |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need to handle this.
.github/workflows/ci.yml
Outdated
| pip install ${{ matrix.django-version }} | ||
| sudo npm install -g prettier | ||
| pip uninstall channels channels-redis daphne -y | ||
| pip install -e ".[channels]" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't be needed anymore.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated!
Replaced StaticLiveServerTestCase with ChannelsLiveServerTestCase to resolve JS errors caused by failed websocket connections. Fixes openwisp#466
6a8a34a to
18861b1
Compare
Updates:
|
nemesifier
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! @pandafy what do you think?
pandafy
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! I have one question, the rest looks good!
tests/openwisp2/asgi.py
Outdated
|
|
||
| from django.core.asgi import get_asgi_application | ||
|
|
||
| os.environ.setdefault("DJANGO_SETTINGS_MODULE", "openwisp2.settings") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we need this here? I don't see it in openwisp-controller and openwisp-notifications.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't remember exactly why, but removing it does nothing. So removed it.
Updates
|
Replaced StaticLiveServerTestCase with ChannelsLiveServerTestCase to resolve JS errors caused by failed websocket connections.
Fixes #466
Checklist
Reference to Existing Issue
Closes #466.
Description of Changes
Issues