-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathtest_activate_sync.py
More file actions
65 lines (58 loc) · 2.37 KB
/
test_activate_sync.py
File metadata and controls
65 lines (58 loc) · 2.37 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# Copyright 2023 Akretion
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
from odoo.tests.common import TransactionCase
class TestActivateSync(TransactionCase):
def setUp(self):
super().setUp()
self.warehouse = self.env.ref("stock.warehouse0")
def test_active_deactivate_wms_sync(self):
self.warehouse.active_wms_sync = True
for field in (
"wms_export_product_cron_id",
"wms_export_picking_in_cron_id",
"wms_export_picking_out_cron_id",
):
self.assertTrue(getattr(self.warehouse, field))
self.warehouse.active_wms_sync = False
for field in (
"wms_export_product_cron_id",
"wms_export_picking_in_cron_id",
"wms_export_picking_out_cron_id",
):
self.assertFalse(getattr(self.warehouse, field).active)
def test_wms_product_sync_created(self):
self.warehouse.active_wms_sync = True
self.warehouse.refresh_wms_products()
self.assertEqual(
len(self.env["product.product"].search([])),
len(self.env["wms.product.sync"].search([])),
)
def test_wms_product_sync_created_filter(self):
self.warehouse.active_wms_sync = True
self.warehouse.wms_export_product_filter_id.domain = '[("id" ,"=", {})]'.format(
self.env.ref("product.product_product_1").id
)
self.warehouse.refresh_wms_products()
self.assertEqual(
1,
len(self.env["wms.product.sync"].search([])),
)
def test_wms_product_sync_updates(self):
self.warehouse.active_wms_sync = True
match_unlink, match_keep, nomatch_match = self.env["product.product"].search(
[], limit=3
)
self.warehouse.wms_export_product_filter_id.domain = (
'[("id", "in", {})]'.format((match_unlink + match_keep).ids)
)
self.warehouse.refresh_wms_products()
self.assertEqual(
self.warehouse.wms_product_sync_ids.product_id, (match_unlink + match_keep)
)
self.warehouse.wms_export_product_filter_id.domain = (
'[("id", "in", {})]'.format((match_keep + nomatch_match).ids)
)
self.warehouse.refresh_wms_products()
self.assertEqual(
self.warehouse.wms_product_sync_ids.product_id, match_keep + nomatch_match
)