samedi 7 avril 2018

Confirmation email in django selenium tests

I'm trying to write simple login test for my django application using selenium for python but I'm getting error that credentials are not valid. For registration I'm using allauth package which provides email confirmation mechanism. As I understand credentials are not valid because newly created users didn't respond to confirmation email. Is there a way to turn it off for testing purpose? I was trying to set ACCOUNT_EMAIL_REQUIRED setting to False but it caused assertion (It is a result of runserver command):

Unhandled exception in thread started by <function check_errors. <locals>.wrapper at 0x7fccbb8cb400>
Traceback (most recent call last):
  File "/pathToPython/python3.5/site-packages/django/utils/autoreload.py", line 225, in wrapper
  fn(*args, **kwargs)
  File "/pathToPython/python3.5/site-packages/django/core/management/commands/runserver.py", line 112, in inner_run
  autoreload.raise_last_exception()
  File "/pathToPython/python3.5/site-packages/django/utils/autoreload.py", line 248, in raise_last_exception
  raise _exception[1]
  File "/pathToPython/python3.5/site-packages/django/core/management/__init__.py", line 327, in execute
  autoreload.check_errors(django.setup)()
  File "/pathToPython/python3.5/site-packages/django/utils/autoreload.py", line 225, in wrapper
  fn(*args, **kwargs)
  File "/pathToPython/python3.5/site-packages/django/__init__.py", line 24, in setup
  apps.populate(settings.INSTALLED_APPS)
  File "/pathToPython/python3.5/site-packages/django/apps/registry.py", line 112, in populate
  app_config.import_models()
  File "/pathToPython/python3.5/site-packages/django/apps/config.py", line 198, in import_models
  self.models_module = import_module(models_module_name)
  File "/pathToPython/python3.5/importlib/__init__.py", line 126, in import_module
  return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 986, in _gcd_import
  File "<frozen importlib._bootstrap>", line 969, in _find_and_load
  File "<frozen importlib._bootstrap>", line 958, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 673, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 665, in exec_module
  File "<frozen importlib._bootstrap>", line 222, in _call_with_frames_removed
  File "/pathToPython/python3.5/site-packages/allauth/account/models.py", line 12, in <module>
  from . import app_settings, signals
  File "/pathToPython/python3.5/site-packages/allauth/account/app_settings.py", line 328, in <module>
  app_settings = AppSettings('ACCOUNT_')
  File "/pathToPython/python3.5/site-packages/allauth/account/app_settings.py", line 22, in __init__
  self.AuthenticationMethod.EMAIL) or self.EMAIL_REQUIRED
AssertionError

For testing purpose I'm using filebased.EmailBackend so I'm thinking about using some functionality within test which will register user and then find this log imitating confirmation email and visit website specified in it but maybe someone knows better solution?

Aucun commentaire:

Enregistrer un commentaire