def test_insert(empty_warehouse): """ Inserts a fact with MAX_ITERATIONS ^ 2 rows. """ enable_logging() Warehouse.use(empty_warehouse) Store.build() stores = _get_instances('store') Store.insert(*stores) Product.build() products = _get_instances('product') Product.insert(*products) Sales.build() sales = _get_instances('sales') start_time = datetime.datetime.now() print 'Starting bulk insert of fact at ', start_time try: Sales.insert(*sales) except OperationalError: pytest.fail('The connection broke.') end_time = datetime.datetime.now() print 'Ending bulk insert of fact at ', end_time delta = end_time - start_time print 'Time taken = ', delta
def test_single_insert(self, empty_warehouse, store): """ Insert a single Dimension instance. There shoudn't be any problems. """ Warehouse.use(empty_warehouse) Store.build() Store.insert(store) assert self._fetch_store_row_count() == 1
def test_modified_insert(self, empty_warehouse, store, modified_store): """ Insert a Dimension, followed by a modified version. """ Warehouse.use(empty_warehouse) Store.build() Store.insert(store) Store.insert(modified_store) assert self._fetch_store_row_count() == 2
def test_duplicate_insert(self, empty_warehouse, store, modified_store): """ Insert a Dimension twice. The row shouldn't be duplicated. """ Warehouse.use(empty_warehouse) Store.build() Store.insert(store) Store.insert(store) assert self._fetch_store_row_count() == 1
def test_null_values(self, empty_warehouse, store, null_store): """ If the second instance contains a NULL column, then we expect a new row to be created. """ Warehouse.use(empty_warehouse) Store.build() Store.insert(store) Store.insert(null_store) assert self._fetch_store_row_count() == 2
def test_null_values(self, empty_warehouse, null_store): """ Test that inserting NULL values into Columns doesn't break the unique keys i.e. if we keep on inserting the same row, where one column is NULL, it won't keep on making copies of that row. """ Warehouse.use(empty_warehouse) Store.build() Store.insert(null_store) Store.insert(null_store) assert self._fetch_store_row_count() == 1