def test_redis(redisdb):
    redisdb.set('test1', 'test')
    redisdb.set('test2', 'test')

    test1 = redisdb.get('test1')
    assert test1 == 'test'

    test2 = redisdb.get('test2')
    assert test2 == 'test'


redis2_params = '--save "" --rdbcompression no --rdbchecksum no'
redis_proc2 = factories.redis_proc(port=6381, params=redis2_params)
redisdb2 = factories.redisdb('redis_proc2')


def test_second_redis(redisdb, redisdb2):
    redisdb.set('test1', 'test')
    redisdb.set('test2', 'test')
    redisdb2.set('test1', 'test_other')
    redisdb2.set('test2', 'test_other')

    test1 = redisdb.get('test1')
    assert test1 == 'test'

    test2 = redisdb.get('test2')
    assert test2 == 'test'

    assert redisdb2.get('test1') == 'test_other'
import pytest
from pytest_dbfixtures import factories

import os
from StringIO import StringIO
from werkzeug.test import EnvironBuilder
from werkzeug.wrappers import Request
import pickle

from phantomboreas.droneservice import app, redis_client, process



redis_proc = factories.redis_proc(host=app.config['REDIS_CONN']['host'], port=app.config['REDIS_CONN']['port'])
redisdb = factories.redisdb('redis_proc', db=app.config['REDIS_CONN']['db_index'])



class TestDroneServiceApp:
    def test_api_route_droneimages(self, monkeypatch):
        def receive_payload(payload):
            assert payload is not None

        monkeypatch.setattr(process, 'process', receive_payload)

        response = app.test_client().post(
            '/droneimages',
            buffered=True,
            content_type='multipart/form-data',
            data=dict(
                image=(StringIO('Hello, World!'), 'test.jpg'),
from pytest_dbfixtures import factories


def test_redis(redisdb):
    redisdb.set('test1', 'test')
    redisdb.set('test2', 'test')

    test1 = redisdb.get('test1')
    assert test1 == 'test'

    test2 = redisdb.get('test2')
    assert test2 == 'test'


redis_proc2 = factories.redis_proc(port=6381)
redisdb2 = factories.redisdb('redis_proc2', port=6381)


def test_second_redis(redisdb, redisdb2):
    redisdb.set('test1', 'test')
    redisdb.set('test2', 'test')
    redisdb2.set('test1', 'test_other')
    redisdb2.set('test2', 'test_other')

    test1 = redisdb.get('test1')
    assert test1 == 'test'

    test2 = redisdb.get('test2')
    assert test2 == 'test'

    assert redisdb2.get('test1') == 'test_other'
    'port':             '?',
    'db_index':         1,
    'queue_key':        'test:openalpr:queue',
    'processing_key':   'test:openalpr:processing',
    'results_key':      'test:parkinglog:queue'
}

openalpr_conf = {
    'country': 'us',
    'region': 'ca',
    'config_file': '/etc/openalpr/openalpr.conf',
    'runtime_dir': '/usr/share/openalpr/runtime_data'
}

redis_proc = factories.redis_proc(host=redis_conf['host'], port=redis_conf['port'])
redisdb = factories.redisdb('redis_proc', db=1)

image = open(os.path.join(os.path.dirname(os.path.realpath(__file__)), 'test.jpg'))
TEST_IMAGE_STREAM = image.read()
image.close()



class TestOpenALPRServiceWorker:
    # The UnloadableALPR class should be a proxy container for openalpr.Alpr
    # instances
    def test_UnloadableALPR_is_subclass(self):
        alpr = UnloadableALPR(openalpr_conf['country'], openalpr_conf['config_file'], openalpr_conf['runtime_dir'])

        assert isinstance(alpr, openalpr.Alpr)
Exemple #5
0
    'db_index': 1,
    'queue_key': 'test:openalpr:queue',
    'processing_key': 'test:openalpr:processing',
    'results_key': 'test:parkinglog:queue'
}

openalpr_conf = {
    'country': 'us',
    'region': 'ca',
    'config_file': '/etc/openalpr/openalpr.conf',
    'runtime_dir': '/usr/share/openalpr/runtime_data'
}

redis_proc = factories.redis_proc(host=redis_conf['host'],
                                  port=redis_conf['port'])
redisdb = factories.redisdb('redis_proc', db=1)

image = open(
    os.path.join(os.path.dirname(os.path.realpath(__file__)), 'test.jpg'))
TEST_IMAGE_STREAM = image.read()
image.close()


class TestOpenALPRServiceWorker:
    # The UnloadableALPR class should be a proxy container for openalpr.Alpr
    # instances
    def test_UnloadableALPR_is_subclass(self):
        alpr = UnloadableALPR(openalpr_conf['country'],
                              openalpr_conf['config_file'],
                              openalpr_conf['runtime_dir'])

def test_redis(redisdb):
    redisdb.set('test1', 'test')
    redisdb.set('test2', 'test')

    test1 = redisdb.get('test1')
    assert test1 == 'test'

    test2 = redisdb.get('test2')
    assert test2 == 'test'


redis2_params = '--save "" --rdbcompression no --rdbchecksum no'
redis_proc2 = factories.redis_proc(port=6381, params=redis2_params)
redisdb2 = factories.redisdb('redis_proc2')


def test_second_redis(redisdb, redisdb2):
    redisdb.set('test1', 'test')
    redisdb.set('test2', 'test')
    redisdb2.set('test1', 'test_other')
    redisdb2.set('test2', 'test_other')

    test1 = redisdb.get('test1')
    assert test1 == 'test'

    test2 = redisdb.get('test2')
    assert test2 == 'test'

    assert redisdb2.get('test1') == 'test_other'
    app.setup.setup_payments()
    app.setup.setup_landing_pages()
    app.setup.setup_creative_images()
    app.setup.setup_campaigns_running()
    app.setup.setup_strategies()
    app.setup.setup_adverts()

    for creative in app.setup.models['creative'].values():
        audit_creative(creative)

    return app


rc = factories.redisdb(
    'redis_proc',
    host=settings.spending_redis_host,
    port=settings.spending_redis_port,
)


class TestBiddingSpendingsSubscriber(object):
    def insert_redis_spendings(self, rc, db, model, ordered_spend_key,
                               spend_key, spendings):
        '''
        push some spendings into testing redis

        :param rc: redis client from fixture
        :param db: database factory oobject from fixture
        '''
        for name, spending in spendings.items():
            last_updated, value = spending
Exemple #8
0

def test_redis(redisdb):
    redisdb.set('test1', 'test')
    redisdb.set('test2', 'test')

    test1 = redisdb.get('test1')
    assert test1 == 'test'

    test2 = redisdb.get('test2')
    assert test2 == 'test'


redis2_params = '--save "" --rdbcompression no --rdbchecksum no'
redis_proc2 = factories.redis_proc(port=6381, params=redis2_params)
redisdb2 = factories.redisdb('redis_proc2', port=6381)


def test_second_redis(redisdb, redisdb2):
    redisdb.set('test1', 'test')
    redisdb.set('test2', 'test')
    redisdb2.set('test1', 'test_other')
    redisdb2.set('test2', 'test_other')

    test1 = redisdb.get('test1')
    assert test1 == 'test'

    test2 = redisdb.get('test2')
    assert test2 == 'test'

    assert redisdb2.get('test1') == 'test_other'
import pytest
from pytest_dbfixtures import factories

import os
from StringIO import StringIO
from werkzeug.test import EnvironBuilder
from werkzeug.wrappers import Request
import pickle

from phantomboreas.droneservice import app, redis_client, process

redis_proc = factories.redis_proc(host=app.config['REDIS_CONN']['host'],
                                  port=app.config['REDIS_CONN']['port'])
redisdb = factories.redisdb('redis_proc',
                            db=app.config['REDIS_CONN']['db_index'])


class TestDroneServiceApp:
    def test_api_route_droneimages(self, monkeypatch):
        def receive_payload(payload):
            assert payload is not None

        monkeypatch.setattr(process, 'process', receive_payload)

        response = app.test_client().post(
            '/droneimages',
            buffered=True,
            content_type='multipart/form-data',
            data=dict(image=(StringIO('Hello, World!'), 'test.jpg'),
                      latitude='38.537002',
                      longitude='-121.754725',

def test_redis(redisdb):
    redisdb.set("test1", "test")
    redisdb.set("test2", "test")

    test1 = redisdb.get("test1")
    assert test1 == "test"

    test2 = redisdb.get("test2")
    assert test2 == "test"


redis2_params = '--save "" --rdbcompression no --rdbchecksum no'
redis_proc2 = factories.redis_proc(port=6381, params=redis2_params)
redisdb2 = factories.redisdb("redis_proc2")


def test_second_redis(redisdb, redisdb2):
    redisdb.set("test1", "test")
    redisdb.set("test2", "test")
    redisdb2.set("test1", "test_other")
    redisdb2.set("test2", "test_other")

    test1 = redisdb.get("test1")
    assert test1 == "test"

    test2 = redisdb.get("test2")
    assert test2 == "test"

    assert redisdb2.get("test1") == "test_other"