-
Notifications
You must be signed in to change notification settings - Fork 106
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[10.0][IMP] Use the technical user to recompute and export (buttons o…
…n shopinvader backend view) [ADD] Add unit tests
- Loading branch information
Showing
4 changed files
with
80 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Copyright 2019 ACSONE SA/NV (<http://acsone.eu>) | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). | ||
from . import test_shopinvader_backend |
54 changes: 54 additions & 0 deletions
54
shopinvader_search_engine/tests/test_shopinvader_backend.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
# -*- coding: utf-8 -*- | ||
# Copyright 2019 ACSONE SA/NV (<http://acsone.eu>) | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). | ||
from uuid import uuid4 | ||
|
||
from odoo.addons.shopinvader.tests.common import CommonCase | ||
|
||
|
||
class TestShopinvaderBackend(CommonCase): | ||
""" | ||
Tests for shopinvader.backend | ||
""" | ||
|
||
def _create_technical_user(self): | ||
""" | ||
:return: | ||
""" | ||
return self.env["res.users"].create( | ||
{"name": "Super awesome technical user", "login": str(uuid4())} | ||
) | ||
|
||
def test_use_technical_user_if_set(self): | ||
""" | ||
Check if the _use_technical_user_if_set change the current user (sudo) | ||
correctly. | ||
:return: | ||
""" | ||
# For this case, disable the user_tech_id. So it should take current | ||
# user. | ||
user = self.env.user | ||
self.env.user.company_id.write({"user_tech_id": False}) | ||
self.assertEqual( | ||
user, self.backend._use_technical_user_if_set().env.user | ||
) | ||
# Now create a technical user and assign it on the company | ||
user = self._create_technical_user() | ||
self.env.user.company_id.write({"user_tech_id": user.id}) | ||
self.assertEqual( | ||
user, self.backend._use_technical_user_if_set().env.user | ||
) | ||
# Try with another technical user | ||
user = self._create_technical_user() | ||
self.env.user.company_id.write({"user_tech_id": user.id}) | ||
self.assertEqual( | ||
user, self.backend._use_technical_user_if_set().env.user | ||
) | ||
# Finally remove the technical user | ||
self.env.user.company_id.write({"user_tech_id": False}) | ||
user = self.env.user | ||
self.assertEqual( | ||
user, self.backend._use_technical_user_if_set().env.user | ||
) | ||
return |