Skip to content

[change:tests] Switch 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

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

dee077
Copy link

@dee077 dee077 commented Apr 28, 2025

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

  • Changed StaticLiveServerTestCase to ChannelsLiveServerTestCase.
  • Updated to Django 5.2.0 in ci.
  • Removed --parallel for running test in ci.

Issues

  • ChannelsLiveServerTestCase does not support Django 5.2 yet.
  • For running test --parallel does not work.

@dee077 dee077 changed the title [change:tests] Switch to ChannelsLiveServerTestCase #904 [change:tests] Switch to ChannelsLiveServerTestCase #466 Apr 29, 2025
Replaced StaticLiveServerTestCase with ChannelsLiveServerTestCase to resolve JS errors caused by failed websocket connections.

Fixes openwisp#466
@dee077 dee077 force-pushed the issues/904-change-to-ChannelsLiveServerTestCase branch from ee2d9f8 to 3d223e8 Compare April 29, 2025 05:26
Copy link
Member

@nemesifier nemesifier left a 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?

'ENGINE': 'django.db.backends.sqlite3',
'NAME': 'openwisp_utils.db',
'TEST': {
'NAME': 'openwisp_utils_test.db',
Copy link
Member

Choose a reason for hiding this comment

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

Why is this needed?

Copy link
Author

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):
Copy link
Member

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.

@@ -86,7 +86,7 @@ jobs:
- name: Tests
if: ${{ !cancelled() && steps.deps.conclusion == 'success' }}
run: |
coverage run runtests.py --parallel
coverage run runtests.py
Copy link
Member

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

@dee077
Copy link
Author

dee077 commented May 9, 2025

CI is not passing on Django 5.2, why is that?

There is an open issue in django channels for ChannelsLiveServerTestCase is broken in django 5.2
django/channels#2148

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement testing Issue related to testing or CI
Projects
Status: To do (general)
Development

Successfully merging this pull request may close these issues.

[change] Switch to ChannelsLiveServerTestCase for all Selenium tests
2 participants