rockstor / rockstor-core

Linux/BTRFS based Network Attached Storage(NAS)
http://rockstor.com/docs/contribute_section.html
GNU General Public License v3.0
552 stars 137 forks source link

Py3.6 test_user.py fail re string interpretation #2582

Closed phillxnet closed 1 year ago

phillxnet commented 1 year ago

Post #2567 in testing branch we have the following test failure regarding expected string type:

buildvm:/opt/rockstor/src/rockstor/storageadmin # poetry run django-admin test -v 2 -p test_user.py
...
test_email_validation (rockstor.storageadmin.tests.test_user.UserTests) ... FAIL
...

======================================================================
FAIL: test_email_validation (rockstor.storageadmin.tests.test_user.UserTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/opt/rockstor/src/rockstor/storageadmin/tests/test_user.py", line 274, in test_email_validation
    response.data[0], "{'email': [u'Enter a valid email address.']}"
AssertionError: "{'email': ['Enter a valid email address.']}" != "{'email': [u'Enter a valid email address.']}"
- {'email': ['Enter a valid email address.']}
+ {'email': [u'Enter a valid email address.']}
?            +

----------------------------------------------------------------------
Ran 8 tests in 1.270s

FAILED (failures=1)
phillxnet commented 1 year ago

The Web-UI surfacing of the tested code related to this issue's test failure:

Attempt to Create a user with a nonsense email address, i.e. "email-not-valid.com"

Houston, we've had a problem.
{'email': ['Enter a valid email address.']}

            Traceback (most recent call last):
  File "/opt/rockstor/src/rockstor/rest_framework_custom/generic_view.py", line 41, in _handle_exception
    yield
  File "/opt/rockstor/src/rockstor/storageadmin/views/user.py", line 221, in post
    suser.full_clean()
  File "/opt/rockstor/.venv/lib/python3.6/site-packages/django/db/models/base.py", line 1250, in full_clean
    raise ValidationError(errors)
django.core.exceptions.ValidationError: {'email': ['Enter a valid email address.']}

This looks to be a more proper presentation than to have our unicode designator.

Ergo we move to modifying the test to remove the explicit unicode'' indicator. Given strings default to this now anyway.

phillxnet commented 1 year ago

Closing as: Fixed by #2584