Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit c4a7f2a

Browse files
committedJul 8, 2024·
[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 c4a7f2a

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed
 

‎src/base/tests/test_util.py

+10-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

@@ -478,6 +479,9 @@ def setUp(self):
478479
]
479480
]
480481
)
482+
self.import_mapping = self.import_mapping + self.env["base_import.mapping"].create(
483+
{"res_model": "res.currency", "column_name": "Column name"}
484+
)
481485

482486
util.flush(self.import_mapping)
483487

@@ -523,10 +527,10 @@ def test_remove_model(self):
523527
remaining_mappings = self.import_mapping - removed_mappings
524528

525529
self.assertEqual(len(removed_mappings), 3)
526-
self.assertEqual(remaining_mappings[0].field_name, "full_name")
530+
self.assertEqual(remaining_mappings.mapped("field_name"), ["full_name", False])
527531

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

532536

0 commit comments

Comments
 (0)
Please sign in to comment.