def test_truncate_fact_table_cli(self):
        data_marts_api.create_taxon_dimension('taxon_dim')
        data_marts_api.create_fact_table('fact_table', ['taxon_dim'], ['n'])

        class TestCLIFactTablePublisher(BaseFactTablePublisher):
            @classmethod
            def get_key(cls):
                return 'test_cli_fact_table_publisher'

            def _process(self, *args, **kwargs):
                dim = data_marts_api.get_dimension('taxon_dim')
                df = dim.get_values()
                df['n'] = df.index
                df['taxon_dim_id'] = df.index
                return df[['taxon_dim_id', 'n']]

        data_marts_api.populate_fact_table('fact_table',
                                           'test_cli_fact_table_publisher')

        runner = CliRunner()
        result = runner.invoke(
            data_marts.truncate_fact_table_cli,
            ["fact_table"],
        )
        self.assertEqual(result.exit_code, 0)
Beispiel #2
0
def create_taxon_dim_cli(populate=True):
    """
    Create the taxon dimension.
    """
    from niamoto.api import data_marts_api
    click.echo("Creating the taxon dimension...")
    data_marts_api.create_taxon_dimension(populate=populate)
    click.echo("The taxon dimension had been successfully created!")
 def test_populate_dimension_cli(self):
     data_marts_api.create_taxon_dimension(populate=False)
     runner = CliRunner()
     result = runner.invoke(data_marts.populate_dimension_cli,
                            ['taxon_dimension'])
     self.assertEqual(result.exit_code, 0)
     result = runner.invoke(data_marts.populate_dimension_cli,
                            ['taxon_dimension', '--truncate'])
     self.assertEqual(result.exit_code, 0)
 def test_create_taxon_dimension(self):
     data_marts_api.create_taxon_dimension()
 def test_populate_dimension(self):
     dim = data_marts_api.create_taxon_dimension(populate=False)
     data_marts_api.populate_dimension(dim.name)
     data_marts_api.populate_dimension(dim.name, truncate=True)