Exemple #1
0
    def test_transform_function(self):
        # type: () -> None
        config = ConfigFactory.from_dict({})

        transformer = BigqueryUsageTransformer()
        transformer.init(config)

        key = TableColumnUsageTuple(
            database=TestBigQueryUsageTransform.DATABASE,
            cluster=TestBigQueryUsageTransform.CLUSTER,
            schema=TestBigQueryUsageTransform.DATASET,
            table=TestBigQueryUsageTransform.TABLE,
            column=TestBigQueryUsageTransform.COLUMN,
            email=TestBigQueryUsageTransform.EMAIL)

        t1 = (key, TestBigQueryUsageTransform.READ_COUNT)
        xformed = transformer.transform(t1)

        self.assertIsInstance(xformed, TableColumnUsage)
        self.assertEqual(len(xformed.col_readers), 1)
        col_reader = xformed.col_readers[0]
        self.assertEqual(col_reader.cluster,
                         TestBigQueryUsageTransform.CLUSTER)
        self.assertEqual(col_reader.database,
                         TestBigQueryUsageTransform.DATABASE)
        self.assertEqual(col_reader.schema, TestBigQueryUsageTransform.DATASET)
        self.assertEqual(col_reader.table, TestBigQueryUsageTransform.TABLE)
        self.assertEqual(col_reader.column, TestBigQueryUsageTransform.COLUMN)
        self.assertEqual(col_reader.user_email,
                         TestBigQueryUsageTransform.EMAIL)
        self.assertEqual(col_reader.read_count,
                         TestBigQueryUsageTransform.READ_COUNT)
Exemple #2
0
    def test_transform_function(self) -> None:
        config = ConfigFactory.from_dict({})

        transformer = BigqueryUsageTransformer()
        transformer.init(config)

        key = TableColumnUsageTuple(database=TestBigQueryUsageTransform.DATABASE,
                                    cluster=TestBigQueryUsageTransform.CLUSTER,
                                    schema=TestBigQueryUsageTransform.DATASET,
                                    table=TestBigQueryUsageTransform.TABLE,
                                    column=TestBigQueryUsageTransform.COLUMN,
                                    email=TestBigQueryUsageTransform.EMAIL)

        t1 = (key, TestBigQueryUsageTransform.READ_COUNT)
        xformed = transformer.transform(t1)

        assert xformed is not None
        self.assertIsInstance(xformed, TableColumnUsage)
        col_readers = list(xformed.col_readers)
        self.assertEqual(len(col_readers), 1)
        col_reader = col_readers[0]
        self.assertEqual(col_reader.start_label, 'Table')
        self.assertEqual(col_reader.start_key, TestBigQueryUsageTransform.TABLE_KEY)
        self.assertEqual(col_reader.user_email, TestBigQueryUsageTransform.EMAIL)
        self.assertEqual(col_reader.read_count, TestBigQueryUsageTransform.READ_COUNT)