def test_incarnation_change(webapp, path, data, with_empty_redis, flask_app):
    num_keys = 10
    paths = []
    for i in range(num_keys):
        if i % 3 == 0:
            path.object += 1
        path.key += 1
        paths.append(path.clone())
        webapp.put(path, data=data)
        data = "{0}__{1}".format(data, i)

    with flask_app.app_context():
        assert Record.query.filter(Record.entity == path.entity_str).count() == num_keys

        if with_empty_redis:
            for key in get_redis_connection().keys("*"):
                get_redis_connection().delete(key)


        path.incarnation += 1
        webapp.put(path, data=data)
        record = Record.query.filter(Record.entity == path.entity_str).one()
        assert record.incarnation == path.incarnation_str

    for prev_path in paths:
        assert webapp.get_raw(prev_path).status_code == requests.codes.not_found
Exemple #2
0
def clean_redis():
    get_redis_connection().flushall()