Example #1
0
def test_increment_restart(pg):
    table = "inc_re"
    src = Stream.from_postgres_increment(table,
                                         pg,
                                         initial_value=30,
                                         polling_interval=1,
                                         limit=10)
    L = src.sink_to_list()

    w = Writer(src.strategy.loader.connection, table)
    w.create_table()
    w.insert(50)
    src.start()

    wait_for(lambda: len(L) == 20, 1, period=0.1)
Example #2
0
def test_increment(pg):
    table = "inc"
    src = Stream.from_postgres_increment(table, pg, polling_interval=1)
    L = src.sink_to_list()

    w = Writer(src.strategy.loader.connection, table)
    w.create_table()
    w.insert(10)
    src.start()

    wait_for(lambda: len(L) == 10, 2, period=0.1)

    w.update(5)  # updates are not captured
    w.insert(8)
    wait_for(lambda: len(L) == 18, 2, period=0.1)

    w.insert(2)
    wait_for(lambda: len(L) == 20, 2, period=0.1)