Skip to content

Commit 27c0995

Browse files
committed
[IMP] util/helpers: tests for import/export empty paths
Commits 5b944f7 and 1d9e20e did not consider the case of empty paths, what was fixed in a05df66. Due to its urgent nature, no tests were added with the fix's commit. That said, this commit adds tests for the case when `base_import.mapping` or `ir.export.line` present path fields which are empty.
1 parent 86d814b commit 27c0995

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

src/base/tests/test_util.py

+8-6
Original file line numberDiff line numberDiff line change
@@ -420,6 +420,7 @@ def setUp(self):
420420
(0, 0, {"name": "rate_ids/company_id/user_ids/name"}),
421421
(0, 0, {"name": "rate_ids/company_id/user_ids/partner_id/user_ids/name"}),
422422
(0, 0, {"name": "rate_ids/name"}),
423+
(0, 0, {}),
423424
],
424425
}
425426
]
@@ -444,7 +445,7 @@ def test_rename_field(self):
444445
def test_remove_field(self):
445446
util.remove_field(self.cr, "res.currency.rate", "company_id")
446447
self._invalidate()
447-
self.assertEqual(len(self.export.export_fields), 2)
448+
self.assertEqual(len(self.export.export_fields), 3)
448449
self.assertEqual(self.export.export_fields[0].name, "full_name")
449450
self.assertEqual(self.export.export_fields[1].name, "rate_ids/name")
450451

@@ -456,11 +457,11 @@ def test_rename_model(self):
456457
def test_remove_model(self):
457458
util.remove_model(self.cr, "res.currency.rate")
458459
self._invalidate()
459-
self.assertEqual(len(self.export.export_fields), 1)
460-
self.assertEqual(self.export.export_fields[0].name, "full_name")
460+
self.assertEqual(len(self.export.export_fields), 2)
461+
self.assertEqual(self.export.export_fields.mapped("name"), ["full_name", False])
461462

462463
util.remove_model(self.cr, "res.currency")
463-
self.cr.execute("SELECT * FROM ir_exports WHERE id = %s", [self.export.id])
464+
self.cr.execute("SELECT * FROM ir_exports WHERE id IN %s", [tuple(self.export.ids)])
464465
self.assertFalse(self.cr.fetchall())
465466

466467

@@ -475,6 +476,7 @@ def setUp(self):
475476
"rate_ids/company_id/user_ids/name",
476477
"rate_ids/company_id/user_ids/partner_id/user_ids/name",
477478
"rate_ids/name",
479+
False,
478480
]
479481
]
480482
)
@@ -523,10 +525,10 @@ def test_remove_model(self):
523525
remaining_mappings = self.import_mapping - removed_mappings
524526

525527
self.assertEqual(len(removed_mappings), 3)
526-
self.assertEqual(remaining_mappings[0].field_name, "full_name")
528+
self.assertEqual(remaining_mappings.mapped("field_name"), ["full_name", False])
527529

528530
util.remove_model(self.cr, "res.currency")
529-
self.cr.execute("SELECT * FROM base_import_mapping WHERE id = %s", [remaining_mappings.id])
531+
self.cr.execute("SELECT * FROM base_import_mapping WHERE id IN %s", [tuple(remaining_mappings.ids)])
530532
self.assertFalse(self.cr.fetchall())
531533

532534

0 commit comments

Comments
 (0)