def test_pop_first_nonempty_queue_empty(db, test_project_data, test_queue, test_redis):
    init_redis()

    queue, data = pop_first_nonempty_queue(test_project_data)

    assert queue is None
    assert data is None
def test_init_redis_one_empty_queue(db, test_project, test_redis):
    add_queue(test_project, 10)

    test_redis.flushdb()
    init_redis()

    assert_redis_matches_db(test_redis)
def test_init_redis_one_nonempty_queue(db, test_project_data, test_redis):
    queue = add_queue(test_project_data, 10)
    fill_queue(queue, orderby="random")

    test_redis.flushdb()
    init_redis()

    assert_redis_matches_db(test_redis)
def test_init_redis_multiple_queues(db, test_project_data, test_redis):
    queue = add_queue(test_project_data, 10)
    fill_queue(queue, orderby="random")

    add_queue(test_project_data, 10)

    test_redis.flushdb()
    init_redis()

    assert_redis_matches_db(test_redis)
def test_init_redis_ignores_assigned_data(db, test_profile, test_queue,
                                          test_redis):
    fill_queue(test_queue, orderby="random")

    assigned_datum = test_queue.data.first()

    AssignedData.objects.create(profile=test_profile,
                                data=assigned_datum,
                                queue=test_queue)

    init_redis()

    # Make sure the assigned datum didn't get into the redis queue
    assert test_redis.llen("queue:" +
                           str(test_queue.pk)) == test_queue.length - 1
    assert test_redis.scard("set:" +
                            str(test_queue.pk)) == test_queue.length - 1
def test_init_redis_multiple_projects(db, test_project_data, test_redis,
                                      test_profile):
    # Try a mix of multiple queues in multiple projects with
    # and without data to see if everything initializes as expected.
    p1_queue1 = add_queue(test_project_data, 10)
    fill_queue(p1_queue1, orderby="random")
    add_queue(test_project_data, 10)

    project2 = create_project("test_project2", test_profile)
    project2_data = read_test_data_backend(
        file="./core/data/test_files/test_no_labels.csv")

    add_data(project2, project2_data)
    p2_queue1 = add_queue(project2, 10)
    fill_queue(p2_queue1, orderby="random")
    add_queue(project2, 10)

    test_redis.flushdb()
    init_redis()

    assert_redis_matches_db(test_redis)
def test_init_redis_empty(db, test_redis):
    init_redis()

    assert_redis_matches_db(test_redis)
Beispiel #8
0
"""
WSGI config for smart project.

It exposes the WSGI callable as a module-level variable named ``application``.

For more information on this file, see
https://docs.djangoproject.com/en/1.11/howto/deployment/wsgi/
"""

import os
from configurations.wsgi import get_wsgi_application

from core.utils.utils_redis import init_redis

os.environ.setdefault("DJANGO_SETTINGS_MODULE", "smart.settings")
os.environ.setdefault("DJANGO_CONFIGURATION", "Prod")

print('Core Config Startup')

init_redis()

application = get_wsgi_application()