|
| 1 | +# -*- coding: utf-8 -*- |
| 2 | +# Copyright 2019 Therp BV (https://therp.nl) |
| 3 | +# License AGPL-3 - See https://www.gnu.org/licenses/agpl-3.0.html |
| 4 | +from odoo.tests import common |
| 5 | + |
| 6 | + |
| 7 | +@common.post_install(True) |
| 8 | +class TestConfig(common.TransactionCase): |
| 9 | + def test_set_get_config(self): |
| 10 | + """Test configuration methods.""" |
| 11 | + config_model = self.env["base.config.settings"] |
| 12 | + config = config_model.create( |
| 13 | + { |
| 14 | + "auth_admin_passkey_send_to_admin": False, |
| 15 | + "auth_admin_passkey_send_to_user": False, |
| 16 | + } |
| 17 | + ) |
| 18 | + # Set email admin and user to False (and back again). |
| 19 | + config.set_auth_admin_passkey_send_to_admin() |
| 20 | + config.set_auth_admin_passkey_send_to_user() |
| 21 | + self.assertEqual( |
| 22 | + False, |
| 23 | + config_model.get_default_auth_admin_passkey_send_to_admin([])[ |
| 24 | + "auth_admin_passkey_send_to_admin" |
| 25 | + ], |
| 26 | + ) |
| 27 | + self.assertEqual( |
| 28 | + False, |
| 29 | + config_model.get_default_auth_admin_passkey_send_to_user([])[ |
| 30 | + "auth_admin_passkey_send_to_user" |
| 31 | + ], |
| 32 | + ) |
| 33 | + config.write( |
| 34 | + { |
| 35 | + "auth_admin_passkey_send_to_admin": True, |
| 36 | + "auth_admin_passkey_send_to_user": True, |
| 37 | + } |
| 38 | + ) |
| 39 | + config.set_auth_admin_passkey_send_to_admin() |
| 40 | + config.set_auth_admin_passkey_send_to_user() |
| 41 | + self.assertEqual( |
| 42 | + True, |
| 43 | + config_model.get_default_auth_admin_passkey_send_to_admin([])[ |
| 44 | + "auth_admin_passkey_send_to_admin" |
| 45 | + ], |
| 46 | + ) |
| 47 | + self.assertEqual( |
| 48 | + True, |
| 49 | + config_model.get_default_auth_admin_passkey_send_to_user([])[ |
| 50 | + "auth_admin_passkey_send_to_user" |
| 51 | + ], |
| 52 | + ) |
0 commit comments