This addon introduced an integration conflict when tested in a database that had `mail_tracking_mass_mailing` installed, producing this failure:
Traceback (most recent call last):
File "/opt/odoo/auto/addons/auth_signup_verify_email/controllers/main.py", line 44, in passwordless_signup
sudo_users.reset_password(values.get("login"))
File "/usr/lib/python2.7/contextlib.py", line 24, in __exit__
self.gen.next()
File "/opt/odoo/custom/src/odoo/odoo/sql_db.py", line 419, in savepoint
self.execute('RELEASE SAVEPOINT "%s"' % name)
File "/opt/odoo/custom/src/odoo/odoo/sql_db.py", line 154, in wrapper
return f(self, *args, **kwargs)
File "/opt/odoo/custom/src/odoo/odoo/sql_db.py", line 231, in execute
res = self._obj.execute(query, params)
InternalError: no such savepoint
Which in turn produced the following in the next test:
InternalError: current transaction is aborted, commands ignored until end of transaction block
The problem comes from the fact that one cannot rollback to a nested savepoint if the parent savepoint was released. It became a problem because that's the strategy that both this addon and upstream's `TestCursor` follow.
To avoid that, tests now mock the `send_mail` method. This results also in having a predictable outcome from the test `test_good_email`, so it is more meaningful now.
Besides, previously we were using the `validate_email` package, which is currently a dead project that can silently fail under certain environments, as seen in https://github.com/syrusakbary/validate_email/pull/80.
There's the `email_validator` package, freely available, supported, and it provides a human-readable error message whenever some format from the email fails.
As such, here I'm switching the dependency, while still adding a backwards compatibility layer for preexisting installations.
In Odoo v9, every request calls `res.users.check()`, which stores one authentication attempt per request, which is false.
Besides, it easily leads to hitting ip-api.com rate limits, so now that API is only asked when seeing in form view (simply by setting the computed field as not stored).
Also, form view was hidden, so it's now visible.
If you test this addon after installing `partner_event`, you get this error in all tests:
ERROR: test_validate_pass_reset_error (odoo.addons.password_security.tests.test_res_users.TestResUsers)
` It should throw PassError on reset inside min threshold
Traceback (most recent call last):
` File "/opt/odoo/auto/addons/password_security/tests/test_res_users.py", line 143, in test_validate_pass_reset_error
` rec_id = self._new_record()
` File "/opt/odoo/auto/addons/password_security/tests/test_res_users.py", line 46, in _new_record
` partner_id = self.env['res.partner'].create(self.partner_vals)
` File "/opt/odoo/auto/addons/mail_tracking_mailgun/models/res_partner.py", line 154, in create
` return super(ResPartner, self).create(vals)
` File "/opt/odoo/auto/addons/partner_firstname/models/res_partner.py", line 54, in create
` return super(ResPartner, self.with_context(context)).create(vals)
` File "/opt/odoo/custom/src/odoo/odoo/addons/base/res/res_partner.py", line 532, in create
` partner = super(Partner, self).create(vals)
` File "/opt/odoo/auto/addons/mail/models/mail_thread.py", line 228, in create
` thread = super(MailThread, self).create(values)
` File "/opt/odoo/custom/src/odoo/odoo/models.py", line 3847, in create
` record = self.browse(self._create(old_vals))
` File "/opt/odoo/custom/src/odoo/odoo/models.py", line 4006, in _create
` self.recompute()
` File "/opt/odoo/custom/src/odoo/odoo/models.py", line 5336, in recompute
` vals = rec._convert_to_write({n: rec[n] for n in ns})
` File "/opt/odoo/custom/src/odoo/odoo/models.py", line 5336, in <dictcomp>
` vals = rec._convert_to_write({n: rec[n] for n in ns})
` File "/opt/odoo/custom/src/odoo/odoo/models.py", line 5232, in __getitem__
` return self._fields[key].__get__(self, type(self))
` File "/opt/odoo/custom/src/odoo/odoo/fields.py", line 918, in __get__
` value = record._cache[self]
` File "/opt/odoo/custom/src/odoo/odoo/models.py", line 5584, in __getitem__
` return value.get() if isinstance(value, SpecialValue) else value
` File "/opt/odoo/custom/src/odoo/odoo/fields.py", line 48, in get
` raise self.exception
` AccessError: (u'Sorry, you are not allowed to access this document. Only users with the following access level are currently allowed to do that:\n- Events/User\n\n(Document model: event.registration)', None)
Since creating users or partners in tests has a very high probability to collide with other addons, this test is being moved to post mode.
Also, to avoid the above permissions issue, the partner is actually created through the admin user, which actually has permissions to read everything. Then, it is `.sudo()`ed later, to perform the module tests correctly. The tests do not get affected because what is being tested was not [intended to be] the partner creation itself, but the password policy enforcement.