summaryrefslogtreecommitdiff
path: root/addons/stock/tests/test_stock_location_search.py
diff options
context:
space:
mode:
authorstephanchrst <stephanchrst@gmail.com>2022-05-10 21:51:50 +0700
committerstephanchrst <stephanchrst@gmail.com>2022-05-10 21:51:50 +0700
commit3751379f1e9a4c215fb6eb898b4ccc67659b9ace (patch)
treea44932296ef4a9b71d5f010906253d8c53727726 /addons/stock/tests/test_stock_location_search.py
parent0a15094050bfde69a06d6eff798e9a8ddf2b8c21 (diff)
initial commit 2
Diffstat (limited to 'addons/stock/tests/test_stock_location_search.py')
-rw-r--r--addons/stock/tests/test_stock_location_search.py36
1 files changed, 36 insertions, 0 deletions
diff --git a/addons/stock/tests/test_stock_location_search.py b/addons/stock/tests/test_stock_location_search.py
new file mode 100644
index 00000000..a7e27f54
--- /dev/null
+++ b/addons/stock/tests/test_stock_location_search.py
@@ -0,0 +1,36 @@
+# -*- coding: utf-8 -*-
+
+from odoo.tests import common
+
+
+class TestStockLocationSearch(common.TransactionCase):
+ def setUp(self):
+ super(TestStockLocationSearch, self).setUp()
+ self.location = self.env['stock.location']
+ self.stock_location = self.env.ref('stock.stock_location_stock')
+ self.sublocation = self.env['stock.location'].create({
+ 'name': 'Shelf 2',
+ 'barcode': 1201985,
+ 'location_id': self.stock_location.id
+ })
+ self.location_barcode_id = self.sublocation.id
+ self.barcode = self.sublocation.barcode
+ self.name = self.sublocation.name
+
+ def test_10_location_search_by_barcode(self):
+ """Search stock location by barcode"""
+ location_names = self.location.name_search(name=self.barcode)
+ self.assertEqual(len(location_names), 1)
+ location_id_found = location_names[0][0]
+ self.assertEqual(self.location_barcode_id, location_id_found)
+
+ def test_20_location_search_by_name(self):
+ """Search stock location by name"""
+ location_names = self.location.name_search(name=self.name)
+ location_ids_found = [location_name[0] for location_name in location_names]
+ self.assertTrue(self.location_barcode_id in location_ids_found)
+
+ def test_30_location_search_wo_results(self):
+ """Search stock location without results"""
+ location_names = self.location.name_search(name='nonexistent')
+ self.assertFalse(location_names)