Skip to content

Commit

Permalink
[ADD] coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
hbrunn committed Sep 18, 2017
1 parent 17f5e0d commit 684419e
Showing 1 changed file with 20 additions and 15 deletions.
35 changes: 20 additions & 15 deletions base_import_odoo/tests/test_base_import_odoo.py
Expand Up @@ -31,21 +31,26 @@ def _mock_read(
**(context or self.env.context)
).browse(domain_or_ids).read(fields=fields)

self.env.ref('base_import_odoo.demodb').write({'password': 'admin'})
with patch('erppeek.Client.search', side_effect=_mock_search):
with patch('erppeek.Client.read', side_effect=_mock_read):
self.env.ref('base_import_odoo.demodb')._run_import()
# here the actual test begins - check that we created new objects,
# check xmlids, check values, check if dummies are cleaned up/replaced
self.assertNotEqual(
self.env.ref(self._get_xmlid('base.user_demo')),
self.env.ref('base.user_demo'),
)
self.assertEqual(
dict(self.env.ref(self._get_xmlid('base.user_demo'))._cache),
dict(self.env.ref('base.user_demo')._cache),
)
# TODO: test much more
for dummy in range(2):
# we run this two times to enter the code path where xmlids exist
self.env.ref('base_import_odoo.demodb').write({
'password': 'admin',
})
with patch('erppeek.Client.search', side_effect=_mock_search):
with patch('erppeek.Client.read', side_effect=_mock_read):
self.env.ref('base_import_odoo.demodb')._run_import()
# here the actual test begins - check that we created new
# objects, check xmlids, check values, check if dummies are
# cleaned up/replaced
self.assertNotEqual(
self.env.ref(self._get_xmlid('base.user_demo')),
self.env.ref('base.user_demo'),
)
self.assertEqual(
dict(self.env.ref(self._get_xmlid('base.user_demo'))._cache),
dict(self.env.ref('base.user_demo')._cache),
)
# TODO: test much more

def _get_xmlid(self, remote_xmlid):
remote_obj = self.env.ref(remote_xmlid)
Expand Down

0 comments on commit 684419e

Please sign in to comment.