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 _create_swdb_group(self, group_id, pkg_types, pkgs):
        comps_group = self._base.comps._group_by_id(group_id)
        if not comps_group:
            self._raise_or_warn(self._skip_unavailable, _("Group id '%s' is not available.") % group_id)
            return None

        swdb_group = self._base.history.group.new(group_id, comps_group.name, comps_group.ui_name, pkg_types)

        try:
            for pkg in pkgs:
                name = pkg["name"]
                self._assert_type(name, str, "groups.packages.name", "string")
                installed = pkg["installed"]
                self._assert_type(installed, bool, "groups.packages.installed", "boolean")
                package_type = pkg["package_type"]
                self._assert_type(package_type, str, "groups.packages.package_type", "string")

                try:
                    swdb_group.addPackage(name, installed, libdnf.transaction.stringToCompsPackageType(package_type))
                except libdnf.error.Error as e:
                    raise TransactionError(str(e))

        except KeyError as e:
            raise TransactionError(
                _('Missing object key "{key}" in groups.packages.').format(key=e.args[0])
            )

        return swdb_group