Пример #1
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
Пример #2
0
def test_isolation(get_all_fact_classes):
    """ Make sure that subsequent facts get called, even if the first
    fact fails.
    """
    enable_logging()

    class FirstFact(Fact):
        @classmethod
        def update(cls):
            raise Exception

    class SecondFact(Fact):
        update = Mock()

    get_all_fact_classes.return_value = [FirstFact, SecondFact]
    commander = Commander()
    commander.run('update', 'FirstFact', 'SecondFact')
    assert SecondFact.update.called
Пример #3
0
def test_isolation(get_all_fact_classes):
    """ Make sure that subsequent facts get called, even if the first
    fact fails.
    """
    enable_logging()

    class FirstFact(Fact):
        @classmethod
        def update(cls):
            raise Exception

    class SecondFact(Fact):
        update = Mock()

    get_all_fact_classes.return_value = [FirstFact, SecondFact]
    commander = Commander()
    commander.run('update', 'FirstFact', 'SecondFact')
    assert SecondFact.update.called