Beispiel #1
0
 def get_cubes_workspace(self):
     workspace = Workspace()
     workspace.register_default_store(
         "sql",
         url=Connector.get_database_url(),
         schema=settings.NIAMOTO_FACT_TABLES_SCHEMA,
         dimension_schema=settings.NIAMOTO_DIMENSIONS_SCHEMA,
     )
     workspace.import_model(self.generate_cubes_model())
     return workspace
 def test_base_data_publisher(self):
     dp = BaseDataPublisher()
     temp_csv = tempfile.TemporaryFile(mode='w')
     data = pd.DataFrame.from_records([[1, 2, 3, 4], [5, 6, 7, 8]])
     dp._publish_csv(data, destination=temp_csv)
     dp.publish(data, 'csv', destination=temp_csv)
     engine = Connector.get_engine()
     db_url = Connector.get_database_url()
     dp.publish(data,
                'sql',
                destination='test_publish_table',
                schema=settings.NIAMOTO_SCHEMA)
     dp.publish(data,
                'sql',
                destination='test_publish_table',
                db_url=db_url,
                if_exists='replace',
                schema=settings.NIAMOTO_SCHEMA)
     inspector = Inspector.from_engine(engine)
     self.assertIn(
         'test_publish_table',
         inspector.get_table_names(schema=settings.NIAMOTO_SCHEMA),
     )
     temp_csv.close()