def test_escrita_campo_num_decimal(self):
        # aceitar somente tipo Decimal
        with self.assertRaises(errors.TipoError):
            self.seg_p.valor_titulo = 10.0
        with self.assertRaises(errors.TipoError):
            self.seg_p.valor_titulo = ''

        # Testa se as casas decimais estao sendo verificadas
        with self.assertRaises(errors.NumDecimaisError):
            self.seg_p.valor_titulo = Decimal('100.2')
        with self.assertRaises(errors.NumDecimaisError):
            self.seg_p.valor_titulo = Decimal('1001')
        with self.assertRaises(errors.NumDecimaisError):
            self.seg_p.valor_titulo = Decimal('1.000')

        # verifica se o numero de digitos esta sendo verificado
        with self.assertRaises(errors.NumDigitosExcedidoError):
            self.seg_p.valor_titulo = Decimal('10000000008100.21')

        # armazemamento correto de um decimal
        self.seg_p.valor_titulo = Decimal('2.13')
        self.assertEqual(self.seg_p.valor_titulo, Decimal('2.13'))
def test_validate_change_skill_difficulty_invalid_value(self):
        expected_suggestion_dict = self.suggestion_dict
        suggestion = suggestion_registry.SuggestionAddQuestion(
            expected_suggestion_dict['suggestion_id'],
            expected_suggestion_dict['target_id'],
            expected_suggestion_dict['target_version_at_submission'],
            expected_suggestion_dict['status'], self.author_id,
            self.reviewer_id, expected_suggestion_dict['change'],
            expected_suggestion_dict['score_category'],
            expected_suggestion_dict['language_code'], False, self.fake_date)
        suggestion.validate()

        suggestion.change.skill_difficulty = 0.4

        with self.assertRaisesRegex(
            utils.ValidationError,
            'Expected change skill_difficulty to be one of '
        ):
            suggestion.validate()