[IMP] Actually generate report in test

Plus other tests to make it to the codecov target
This commit is contained in:
Stefan Rijnhart
2021-02-03 20:22:01 +01:00
parent e3dee68101
commit ab6476c866
2 changed files with 41 additions and 1 deletions

View File

@@ -610,3 +610,37 @@ class TestAssetManagement(SavepointCase):
# In the last month of the fiscal year we compensate for the small
# deviations if that is necessary.
self.assertAlmostEqual(asset.depreciation_line_ids[12].amount, 166.63, places=2)
def test_15_account_asset_group(self):
""" Group's name_get behaves differently depending on code and context
"""
group_fa = self.env.ref("account_asset_management.account_asset_group_fa")
group_tfa = self.env.ref("account_asset_management.account_asset_group_tfa")
# Groups are displayed by code (if any) plus name
self.assertEqual(
self.env["account.asset.group"]._name_search("FA"),
[(group_fa.id, "FA Fixed Assets")],
)
# Groups with code are shown by code in list views
self.assertEqual(
self.env["account.asset.group"]
.with_context(params={"view_type": "list"})
._name_search("FA"),
[(group_fa.id, "FA")],
)
self.assertEqual(
self.env["account.asset.group"]._name_search("TFA"),
[(group_tfa.id, "TFA Tangible Fixed Assets")],
)
group_tfa.code = False
group_fa.code = False
self.assertEqual(group_fa.name_get(), [(group_fa.id, "Fixed Assets")])
# Groups without code are shown by truncated name in lists
self.assertEqual(
group_tfa.name_get(), [(group_tfa.id, "Tangible Fixed Assets")]
)
self.assertEqual(
group_tfa.with_context(params={"view_type": "list"}).name_get(),
[(group_tfa.id, "Tangible Fixed A...")],
)
self.assertFalse(self.env["account.asset.group"]._name_search("stessA dexiF"))

View File

@@ -30,6 +30,8 @@ class TestAssetManagementXls(SavepointCase):
cls.xls_report_name = "{}.asset_report_xls".format(module)
cls.wiz_model = cls.env["wiz.account.asset.report"]
cls.company = cls.env.ref("base.main_company")
# Ensure we have something to report on
cls.env.ref("account_asset_management." "account_asset_asset_ict0").validate()
asset_group_id = cls.wiz_model._default_asset_group_id()
fy_dates = cls.company.compute_fiscalyear_dates(fields.date.today())
@@ -42,7 +44,7 @@ class TestAssetManagementXls(SavepointCase):
cls.report_action = cls.xls_report.xls_export()
def test_01_action_xls(self):
""" Check report XLS action """
""" Check report XLS action and generate report """
self.assertDictContainsSubset(
{
"type": "ir.actions.report",
@@ -51,3 +53,7 @@ class TestAssetManagementXls(SavepointCase):
},
self.report_action,
)
model = self.env["report.%s" % self.report_action["report_name"]].with_context(
active_model=self.xls_report._name, **self.report_action["context"]
)
model.create_xlsx_report(self.xls_report.ids, data=self.report_action["data"])