Ejemplo n.º 1
0
 def test_category_id__refers_to_other_units(self):
     unit = self.unit_cls({
         'category_id': 'some-unit'
     }, provider=self.provider)
     message = "field 'category_id', unit 'ns::some-unit' is not available"
     self.provider.unit_list = [unit]
     context = UnitValidationContext([self.provider])
     issue_list = unit.check(context=context)
     self.assertIssueFound(
         issue_list, self.unit_cls.Meta.fields.category_id,
         Problem.bad_reference, Severity.error, message)
Ejemplo n.º 2
0
 def test_requires__refers_to_other_units(self):
     unit = self.unit_cls({
         'requires': 'some_unit.attr == "value"'
     }, provider=self.provider)
     message = "field 'requires', unit 'ns::some_unit' is not available"
     self.provider.unit_list = [unit]
     context = UnitValidationContext([self.provider])
     issue_list = unit.check(context=context)
     self.assertIssueFound(
         issue_list, self.unit_cls.Meta.fields.requires,
         Problem.bad_reference, Severity.error, message)
Ejemplo n.º 3
0
 def test_template_resource__refers_to_other_units(self):
     unit = self.unit_cls({'template-resource': 'some-unit'},
                          provider=self.provider)
     message = ("field 'template-resource',"
                " unit 'ns::some-unit' is not available")
     self.provider.unit_list = [unit]
     self.provider.problem_list = []
     context = UnitValidationContext([self.provider])
     issue_list = unit.check(context=context)
     self.assertIssueFound(issue_list,
                           self.unit_cls.Meta.fields.template_resource,
                           Problem.bad_reference, Severity.error, message)
 def test_id__unique(self):
     unit = self.unit_cls({'id': 'id'}, provider=self.provider)
     other_unit = self.unit_cls({'id': 'id'}, provider=self.provider)
     self.provider.unit_list = [unit, other_unit]
     self.provider.problem_list = []
     context = UnitValidationContext([self.provider])
     message_start = ("{} 'id', field 'id', clashes with 1 other unit,"
                      " look at: ").format(unit.tr_unit())
     issue_list = unit.check(context=context)
     issue = self.assertIssueFound(issue_list, self.unit_cls.Meta.fields.id,
                                   Problem.not_unique, Severity.error)
     self.assertTrue(issue.message.startswith(message_start))
Ejemplo n.º 5
0
 def test_requires__refers_to_other_resource_jobs(self):
     other_unit = JobDefinition({
         'id': 'some_unit', 'plugin': 'shell'
     }, provider=self.provider)
     unit = self.unit_cls({
         'requires': 'some_unit.attr == "value"'
     }, provider=self.provider)
     message = "field 'requires', the referenced job is not a resource job"
     self.provider.unit_list = [unit, other_unit]
     context = UnitValidationContext([self.provider])
     issue_list = unit.check(context=context)
     self.assertIssueFound(
         issue_list, self.unit_cls.Meta.fields.requires,
         Problem.bad_reference, Severity.error, message)
Ejemplo n.º 6
0
 def test_after__refers_to_other_jobs(self):
     other_unit = UnitWithId({
         'id': 'some-unit'
     }, provider=self.provider)
     unit = self.unit_cls({
         'after': 'some-unit'
     }, provider=self.provider)
     message = "field 'after', the referenced unit is not a job"
     self.provider.unit_list = [unit, other_unit]
     context = UnitValidationContext([self.provider])
     issue_list = unit.check(context=context)
     self.assertIssueFound(
         issue_list, self.unit_cls.Meta.fields.after,
         Problem.bad_reference, Severity.error, message)