Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[IMP] util/helpers: tests for import/export empty paths #108

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions src/base/tests/test_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -420,6 +420,7 @@ def setUp(self):
(0, 0, {"name": "rate_ids/company_id/user_ids/name"}),
(0, 0, {"name": "rate_ids/company_id/user_ids/partner_id/user_ids/name"}),
(0, 0, {"name": "rate_ids/name"}),
(0, 0, {}),
],
}
]
Expand All @@ -444,7 +445,7 @@ def test_rename_field(self):
def test_remove_field(self):
util.remove_field(self.cr, "res.currency.rate", "company_id")
self._invalidate()
self.assertEqual(len(self.export.export_fields), 2)
self.assertEqual(len(self.export.export_fields), 3)
self.assertEqual(self.export.export_fields[0].name, "full_name")
self.assertEqual(self.export.export_fields[1].name, "rate_ids/name")

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

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


Expand All @@ -475,6 +476,7 @@ def setUp(self):
"rate_ids/company_id/user_ids/name",
"rate_ids/company_id/user_ids/partner_id/user_ids/name",
"rate_ids/name",
False,
]
]
)
Expand Down Expand Up @@ -523,10 +525,10 @@ def test_remove_model(self):
remaining_mappings = self.import_mapping - removed_mappings

self.assertEqual(len(removed_mappings), 3)
self.assertEqual(remaining_mappings[0].field_name, "full_name")
self.assertEqual(remaining_mappings.mapped("field_name"), ["full_name", False])

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


Expand Down