openwisp/openwisp-notifications

[tests] Fix project dependent test cases (openwisp_notifications.tests.test_admin)

Aryamanz29 opened this issue ยท 0 comments

While adding openwisp_notifications.tests.test_admin in openwisp/ansible-openwisp2#349, The following test cases failed ๐Ÿ‘‡

    - openwisp_notifications.tests.test_admin
    delta: '0:01:27.280542'
    end: '2022-02-23 11:08:22.952757'
    msg: non-zero return code
    rc: 1
    start: '2022-02-23 11:06:55.672215'
    stderr: |-
      Using existing test database for alias 'default'...
      ./opt/openwisp2/env/lib/python3.9/site-packages/django/db/models/fields/__init__.py:1409: RuntimeWarning: DateTimeField Ca.validity_start received a naive datetime (2022-02-22 00:00:00) while time zone support is active.
        warnings.warn("DateTimeField %s received a naive datetime (%s)"
      .../opt/openwisp2/env/lib/python3.9/site-packages/django/db/models/fields/__init__.py:1409: RuntimeWarning: DateTimeField Cert.validity_start received a naive datetime (2022-02-22 00:00:00) while time zone support is active.
        warnings.warn("DateTimeField %s received a naive datetime (%s)"
      .............................................................................................F.........F.....................................
      ======================================================================
      FAIL: test_jquery_import (openwisp_notifications.tests.test_admin.TestAdmin)
      ----------------------------------------------------------------------
      Traceback (most recent call last):
        File "/opt/openwisp2/env/lib/python3.9/site-packages/openwisp_notifications/tests/test_admin.py", line 145, in test_jquery_import
          self.assertInHTML(
        File "/opt/openwisp2/env/lib/python3.9/site-packages/django/test/testcases.py", line 829, in assertInHTML
          self.assertEqual(
      AssertionError: 0 != 1 : Found 0 instances of '<script src="/static/admin/js/jquery.init.js">' in response (expected 1)
    
      ======================================================================
      FAIL: test_object_notification_setting_configured (openwisp_notifications.tests.test_admin.TestAdmin)
      ----------------------------------------------------------------------
      Traceback (most recent call last):
        File "/opt/openwisp2/env/lib/python3.9/site-packages/django/test/utils.py", line 437, in inner
          return func(*args, **kwargs)
        File "/opt/openwisp2/env/lib/python3.9/site-packages/openwisp_notifications/tests/test_admin.py", line 269, in test_object_notification_setting_configured
          self.assertContains(
        File "/opt/openwisp2/env/lib/python3.9/site-packages/django/test/testcases.py", line 460, in assertContains
          self.assertEqual(
      AssertionError: 0 != 1 : Found 0 instances of 'src="/static/openwisp-notifications/js/object-notifications.js"' in response (expected 1)
    
      ----------------------------------------------------------------------
      Ran 145 tests in 61.893s
    
      FAILED (failures=2)
      Preserving test database for alias 'default'...
    stderr_lines: <omitted>
    stdout: |-
      Found 145 test(s).
      System check identified no issues (0 silenced).
    stdout_lines: <omitted>

We will need to update test_jquery_import and test_object_notification_setting_configured, See complete build report https://github.com/openwisp/ansible-openwisp2/runs/5302190411?check_suite_focus=true#step:7:1215