def _invalid_specification(self, specification):
     """Asserts that 'specification' is invalid and returns a list of
     validation problems
     """
     with self.assertRaises(InvalidSpecificationError) as invalid:
         validated_specification(specification)
     return invalid.exception.problems
 def _invalid_specification(self, specification):
     """Asserts that 'specification' is invalid and returns a list of
     validation problems
     """
     with self.assertRaises(InvalidSpecificationError) as invalid:
         validated_specification(specification)
     return invalid.exception.problems
    def test_user_template_one_validation_error(self):
        with self.assertRaises(InvalidSpecificationError) as cm:
            validated_specification({'Name': 'T1'})

        self.assertEqual('1 problem:\nFields: One or more fields must be defined.',
                         str(cm.exception))
        self.assertEqual(['Fields: One or more fields must be defined.'],
                         cm.exception.problems)
    def test_user_template_one_validation_error(self):
        with self.assertRaises(InvalidSpecificationError) as cm:
            validated_specification({'Name': 'T1'})

        self.assertEqual('1 problem:\nFields: One or more fields must be defined.',
                         str(cm.exception))
        self.assertEqual(['Fields: One or more fields must be defined.'],
                         cm.exception.problems)
    def test_user_template_two_validation_errors(self):
        with self.assertRaises(InvalidSpecificationError) as cm:
            validated_specification({})

        expected = ('2 problems:\nFields: One or more fields must be defined.\n'
                    'Name: This field is required.')
        self.assertEqual(expected, str(cm.exception))
        expected = ['Fields: One or more fields must be defined.',
                    'Name: This field is required.']
        self.assertEqual(expected, cm.exception.problems)
    def test_user_template_two_validation_errors(self):
        with self.assertRaises(InvalidSpecificationError) as cm:
            validated_specification({})

        expected = ('2 problems:\nFields: One or more fields must be defined.\n'
                    'Name: This field is required.')
        self.assertEqual(expected, str(cm.exception))
        expected = ['Fields: One or more fields must be defined.',
                    'Name: This field is required.']
        self.assertEqual(expected, cm.exception.problems)