diff --git a/checkbox-ng/plainbox/impl/unit/test_template.py b/checkbox-ng/plainbox/impl/unit/test_template.py index 180ddb270..4473794a1 100644 --- a/checkbox-ng/plainbox/impl/unit/test_template.py +++ b/checkbox-ng/plainbox/impl/unit/test_template.py @@ -223,6 +223,30 @@ def test_template_id__precedence_jinja2(self): "id": "job_id_{{ param }}", }).template_id, "template_id") + def test_template_summary(self): + self.assertEqual(TemplateUnit({ + "template-summary": "summary", + }).template_summary, "summary") + + def test_template_description(self): + self.assertEqual(TemplateUnit({ + "template-description": "description", + }).template_description, "description") + + def test_tr_template_summary(self): + """Ensure template_summary is populated with the translated field.""" + self.assertEqual(TemplateUnit({ + "_template-summary": "summary", + }).template_summary, "summary") + + def test_tr_template_description(self): + """ + Ensure template_description is populated with the translated field. + """ + self.assertEqual(TemplateUnit({ + "_template-description": "description", + }).template_description, "description") + def test_template_resource__empty(self): self.assertEqual(TemplateUnit({}).template_resource, None) @@ -496,6 +520,50 @@ def test_template_unit__untranslatable(self): issue_list, self.unit_cls.Meta.fields.template_unit, Problem.unexpected_i18n, Severity.warning) + def test_template_summary__translatable(self): + issue_list = self.unit_cls({ + 'template-summary': 'template_summary' + }, provider=self.provider).check() + self.assertIssueFound(issue_list, + self.unit_cls.Meta.fields.template_summary, + Problem.expected_i18n, + Severity.warning) + + def test_template_summary__present(self): + issue_list = self.unit_cls({ + }, provider=self.provider).check() + self.assertIssueFound(issue_list, + self.unit_cls.Meta.fields.template_summary, + Problem.missing, + Severity.advice) + + def test_template_summary__one_line(self): + issue_list = self.unit_cls({ + 'template-summary': 'line1\nline2' + }, provider=self.provider).check() + self.assertIssueFound(issue_list, + self.unit_cls.Meta.fields.template_summary, + Problem.wrong, + Severity.warning) + + def test_template_summary__short_line(self): + issue_list = self.unit_cls({ + 'template-summary': 'x' * 81 + }, provider=self.provider).check() + self.assertIssueFound(issue_list, + self.unit_cls.Meta.fields.template_summary, + Problem.wrong, + Severity.warning) + + def test_template_description__translatable(self): + issue_list = self.unit_cls({ + 'template-description': 'template_description' + }, provider=self.provider).check() + self.assertIssueFound(issue_list, + self.unit_cls.Meta.fields.template_description, + Problem.expected_i18n, + Severity.warning) + def test_template_resource__untranslatable(self): issue_list = self.unit_cls({ '_template-resource': 'template_resource'