Skip to content

Commit

Permalink
[IMP] product_origin : Add test
Browse files Browse the repository at this point in the history
  • Loading branch information
legalsylvain committed Jan 11, 2024
1 parent b0557bd commit ec0f78f
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
1 change: 1 addition & 0 deletions product_origin/tests/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import test_module
33 changes: 33 additions & 0 deletions product_origin/tests/test_module.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Copyright (C) 2024 - Today: GRAP (http://www.grap.coop)
# @author: Sylvain LE GAL (https://twitter.com/legalsylvain)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

from odoo.exceptions import ValidationError
from odoo.tests.common import TransactionCase


class TestModule(TransactionCase):
@classmethod
def setUpClass(cls):
super().setUpClass()
cls.country_us = cls.env.ref("base.us")
cls.state_tarapaca = cls.env.ref("base.state_cl_01")

def test_product_product(self):
self._test_compute_and_constrains(self.env["product.product"])

def test_product_template(self):
self._test_compute_and_constrains(self.env["product.template"])

def _test_compute_and_constrains(self, model):
# Set state should set country
product = model.create({"name": "Test Name"})
self.assertEqual(product.state_id_domain, [])

product.country_id = self.country_us
self.assertEqual(
product.state_id_domain, [("country_id", "=", self.country_us.id)]
)

with self.assertRaises(ValidationError):
product.state_id = self.state_tarapaca

0 comments on commit ec0f78f

Please sign in to comment.