示例#1
0
    def test_loading_with_single_object(self) -> None:
        """
        Test Loading functionality with single python object
        """
        loader = FileSystemCSVLoader()
        loader.init(conf=Scoped.get_scoped_conf(conf=self.conf,
                                                scope=loader.get_scope()))

        data = TableMetadataResult(database='test_database',
                                   schema='test_schema',
                                   name='test_table',
                                   description='test_description',
                                   column_name='test_column_name',
                                   column_type='test_column_type',
                                   column_comment='test_column_comment',
                                   owner='test_owner')
        loader.load(data)
        loader.close()

        expected = [
            ','.join([
                'database', 'schema', 'name', 'description', 'column_name',
                'column_type', 'column_comment', 'owner'
            ]), ','.join([
                'test_database', 'test_schema', 'test_table',
                'test_description', 'test_column_name', 'test_column_type',
                'test_column_comment', 'test_owner'
            ])
        ]

        self._check_results_helper(expected=expected)
示例#2
0
    def test_empty_loading(self) -> None:
        """
        Test loading functionality with no data
        """
        loader = FileSystemCSVLoader()
        loader.init(conf=Scoped.get_scoped_conf(conf=self.conf,
                                                scope=loader.get_scope()))

        loader.load(None)
        loader.close()

        self._check_results_helper(expected=[])
    def test_loading_with_list_of_objects(self):
        # type: () -> None
        """
        Test Loading functionality with list of objects.
        Check to ensure all objects are added to file
        """
        loader = FileSystemCSVLoader()
        loader.init(conf=Scoped.get_scoped_conf(conf=self.conf,
                                                scope=loader.get_scope()))

        data = [
            TableMetadataResult(database='test_database',
                                schema='test_schema',
                                name='test_table',
                                description='test_description',
                                column_name='test_column_name',
                                column_type='test_column_type',
                                column_comment='test_column_comment',
                                owner='test_owner')
        ] * 5

        for d in data:
            loader.load(d)
        loader.close()

        expected = [
            ','.join([
                'database', 'schema', 'name', 'description', 'column_name',
                'column_type', 'column_comment', 'owner'
            ])
        ]
        expected = expected + [
            ','.join([
                'test_database', 'test_schema', 'test_table',
                'test_description', 'test_column_name', 'test_column_type',
                'test_column_comment', 'test_owner'
            ])
        ] * 5

        self._check_results_helper(expected=expected)