Exemplo n.º 1
0
 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
Exemplo n.º 2
0
 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
Exemplo n.º 3
0
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
Exemplo n.º 4
0
def _generate_store():
    instances = []
    for store_id in xrange(1, MAX_ITERATIONS):
        obj = Store()
        obj['store_id'] = store_id
        obj['manager'] = 'Mr Smith %i' % store_id
        instances.append(obj)
    return instances
Exemplo n.º 5
0
 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
Exemplo n.º 6
0
 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
Exemplo n.º 7
0
 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
Exemplo n.º 8
0
 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
Exemplo n.º 9
0
 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
Exemplo n.º 10
0
 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
Exemplo n.º 11
0
 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
Exemplo n.º 12
0
 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
Exemplo n.º 13
0
def store():
    obj = Store()
    obj['store_id'] = 1
    obj['manager'] = 'Mr Smith'
    return obj
Exemplo n.º 14
0
def null_store():
    obj = Store()
    obj['store_id'] = 1
    obj['manager'] = None
    return obj
Exemplo n.º 15
0
def modified_store():
    obj = Store()
    obj['store_id'] = 1
    obj['manager'] = 'Mrs Smith'
    return obj
Exemplo n.º 16
0
def test_can_drop_dimension(empty_warehouse):
    Warehouse.use(empty_warehouse)
    Store.create_table()
    Store.drop_table()
    assert not Store.table_exists
Exemplo n.º 17
0
def test_cannot_create_dimension_twice(empty_warehouse):
    Warehouse.use(empty_warehouse)
    assert Store.create_table()
    assert not Store.create_table()
Exemplo n.º 18
0
def test_can_create_dimension(empty_warehouse):
    Warehouse.use(empty_warehouse)
    assert Store.create_table()
    assert Store.table_exists