Ejemplo n.º 1
0
    def setUpClass(cls):
        anno = datetime.now().year
        # Create logger
        cls.logger = logging.getLogger(__name__)    
        super().logInfoTitle(
            "Test Certificazione Data Provider : Accredia {}".format(anno))

        super().logInfoMessage("Creo connessione con il db e ottengo lista cf...")
        
        cls.ii = I2FVG(True)
        cf_list = cls.ii.get_fiscalcode_list()
        
        super().logInfoMessage("Carico file data provider...")
        cls.dp = Accredia(cls.dp_file_name)
        cls.dp.set_selected_fiscalcodes(cf_list)
        cls.dp.set_renamed_df()
        cls.data_dp = cls.dp.df
        cls.data_dp = cls.data_dp.apply(lambda col: trim_columns_spaces(col))
        cls.data_dp.drop(columns='id_istat_province', inplace=True)
        
        super().logInfoMessage("Carico le tabelle sul DB")
        cls.db = Certificazione()
        cls.data_db = cls.db.df
        cls.data_db = cls.data_db.apply(lambda col: trim_columns_spaces(col))
        super().logNewLine()
Ejemplo n.º 2
0
    def setUpClass(cls):
        anno = datetime.now().year
        # Create logger
        cls.logger = logging.getLogger(__name__)
        super().logInfoTitle(
            "Test Certificazione Data Provider : Rating Legalita {}".format(
                anno))

        super().logInfoMessage("Carico le tabelle sul DB...")
        cls.ii = I2FVG()

        cf_list = cls.ii.get_fiscalcode_list()
        cls.data_db = pd.read_sql_query(cls.db_query, cls.ii.engine)
        cls.data_db = cls.data_db.apply(lambda col: trim_columns_spaces(col))
        cls.data_db.set_index(cls.db_keys, inplace=True)

        super().logInfoMessage("Carico file data provider...")
        try:
            cls.dp = RatingLegalita()
        except:
            super().logErrorMessage("Errore apertura file '{}'!".format(
                cls.dp.file_path))

        cls.dp.update_rating_column_with_spaces()
        cls.data_dp = cls.dp.get_filtred_fiscal_codes_dataframe(cf_list)
        cls.data_dp = cls.data_dp.apply(lambda col: trim_columns_spaces(col))
        cls.data_dp.set_index(cls.dp_keys, inplace=True)

        super().logNewLine()
Ejemplo n.º 3
0
    def setUpClass(cls):
        anno = datetime.now().year
        # Create logger
        cls.logger = logging.getLogger(__name__)
        super().logInfoTitle(
            "Test Certificazione Data Provider : Anagrafica Infocamere {}".
            format(anno))

        super().logInfoMessage("Carico file data provider...")
        try:
            cls.dp = AnagraficaInfocamere(cls.dp_file_name)
        except:
            super().logErrorMessage("Errore apertura file '{}'!".format(
                cls.dp_file_name))

        cls.data_dp = cls.dp.df
        cls.data_dp = cls.data_dp.apply(lambda col: trim_columns_spaces(col))
        cls.data_dp.set_index(cls.dp_keys, inplace=True)

        super().logInfoMessage("Carico le tabelle sul DB...")
        try:
            cls.ii = I2FVG()
        except:
            super().logErrorMessage("Errore connessione con il DB!")

        cls.data_db = pd.read_sql_query(cls.db_query, cls.ii.engine)
        cls.data_db = cls.data_db.apply(lambda col: trim_columns_spaces(col))
        cls.data_db.set_index(cls.db_keys, inplace=True)

        super().logNewLine()
Ejemplo n.º 4
0
def getColumnsInfo(info: I2FVG.Info, sel: slice = None) -> I2FVG.InfoCols:
    name_list = getColumnNames(info)
    type_list = getColumnTypes(info)
    length_list = getColumnLengths(info)
    nullable_list = getColumnNullables(info)

    if not sel:
        sel = slice(None)

    info_col = I2FVG.InfoCols(names=list(name_list.values())[sel],
                              types=list(type_list.values())[sel],
                              lengths=list(length_list.values())[sel],
                              nullables=list(nullable_list.values())[sel])

    return info_col
Ejemplo n.º 5
0
    def setUpClass(cls):
        cls.maxDiff = None

        # Create logger
        cls.logger = logging.getLogger(__name__)
        cls.logger.info(
            "\n\n## Test Data Provider : Ateco Infocamere 2020\n{}\n".format(
                super().log_new_line))

        cls.logger.info("\n\nApertura del file excel...\n")
        try:
            cls.anagrafica = AtecoInfocamere(cls.file_name)  # To change
        except:
            cls.logger.error("\n\nErrore apertura file '{}'!\n".format(
                cls.file_name))

        cls.logger.info("\n\nApertura connessione con il DB...\n")
        try:
            cls.i2fvg = I2FVG()
        except:
            cls.logger.error("\n\nErrore connessione con il DB!\n")

        cls.logger.info(
            "\n\nScarico le informazioni sulla tabella '{}'...\n".format(
                cls.db_table_name))
        try:
            cls.db_info = cls.i2fvg.get_stats(cls.db_table_name)
        except:
            cls.logger.error(
                "\n\nImpossibile scaricare le informazioni dalla tabella {}\n".
                format(cls.db_table_name))

        # Formatto info dal DB per i controlli
        cls.db_columns_info = getColumnsInfo(cls.db_info, slice(1, -2))
        cls.default_columns_type = getNumpyTypesConversion(
            cls.db_columns_info.types)

        # Log info del data provider
        super().logDataFrameInfo(cls.anagrafica.df)
        cls.logger.info("\n\n{}".format(super().log_new_line))
Ejemplo n.º 6
0
 def setUpClass(cls):
     col1 = {
         'name': 'col1',
         'type': types.VARCHAR(length=11),
         'nullable': True,
         'default': None
     }
     col2 = {
         'name': 'col2',
         'type': types.DATE(),
         'nullable': False,
         'default': None
     }
     col3 = {
         'name': 'col3',
         'type': types.INTEGER(),
         'nullable': True,
         'default': None
     }
     col4 = {
         'name': 'col4',
         'type': types.FLOAT(),
         'nullable': True,
         'default': None
     }
     col5 = {
         'name': 'col5',
         'type': types.CHAR(length=10, collation='Latin1_General_CI_AS'),
         'nullable': True,
         'default': None
     }
     cols = [col1, col2, col3, col4, col5]
     cls.info = I2FVG.Info(name='tbl_prova',
                           unique=['pk1', 'pk2'],
                           keys=[],
                           foreign=[],
                           columns=cols)