test_search.py 1.1 KB

12345678910111213141516171819202122232425262728
  1. # coding: utf-8
  2. # © 2016 David BEAL @ Akretion <david.beal@akretion.com>
  3. # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
  4. from openerp.tests.common import TransactionCase
  5. class TestSearchByAttribute(TransactionCase):
  6. def test_attribute_str(self):
  7. self.assertEqual(self.ipod16.attribute_str, '16 gb')
  8. def test_change_attribute_value(self):
  9. self.attrib16.write({'name': '16 GBsuffix'})
  10. self.assertEqual(self.ipod16.attribute_str, '16 gbsuffix')
  11. def test_no_record_returned_by_search(self):
  12. res = self.product_m.search([('attribute_str', 'ilike', '16 32')])
  13. self.assertEqual(len(res), 0)
  14. def test_one_record_returned_by_search(self):
  15. res = self.product_m.search([('attribute_str', 'ilike', '16 blac')])
  16. self.assertEqual(len(res), 1)
  17. def setUp(self):
  18. super(TestSearchByAttribute, self).setUp()
  19. self.product_m = self.env['product.product']
  20. self.ipod16 = self.env.ref('product.product_product_11')
  21. self.attrib16 = self.env.ref('product.product_attribute_value_1')