コード例 #1
0
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'
コード例 #2
0
from pytest_dbfixtures.utils import extract_version, compare_version


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'
コード例 #3
0
    'host': 'localhost',
    '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'])
コード例 #4
0
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'),
コード例 #5
0
    'host':             'localhost',
    '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)
コード例 #6
0
    """Validate paths passed to py.test."""
    db_conf = early_config.getvalue('db_conf')
    if db_conf and not path(db_conf).isfile():
        raise ValueError(
            'argument passed to --dbfixtures-config is not a valid file path')
    redis_conf = early_config.getvalue('redis_conf')
    if redis_conf and not path(redis_conf).isfile():
        raise ValueError(
            'argument passed to --redis-config is not a valid file path')
    rabbit_conf = early_config.getvalue('rabbit_conf')
    if rabbit_conf and not path(rabbit_conf).isfile():
        raise ValueError(
            'argument passed to --rabbit-config is not a valid file path')


redis_proc = factories.redis_proc()
redisdb = factories.redisdb('redis_proc')

mysql_proc = factories.mysql_proc()
mysql = factories.mysql('mysql_proc')


@pytest.fixture
def mysqldb(mysql):
    warnings.warn(
        '`mysqldb` fixture is deprecated. Please use `mysql` instead.',
        DeprecationWarning, 2)
    return mysql


rabbitmq_proc = factories.rabbitmq_proc()
コード例 #7
0
        raise ValueError(
            'argument passed to --dbfixtures-config is not a valid file path'
        )
    redis_conf = early_config.getvalue('redis_conf')
    if redis_conf and not path(redis_conf).isfile():
        raise ValueError(
            'argument passed to --redis-config is not a valid file path'
        )
    rabbit_conf = early_config.getvalue('rabbit_conf')
    if rabbit_conf and not path(rabbit_conf).isfile():
        raise ValueError(
            'argument passed to --rabbit-config is not a valid file path'
        )


redis_proc = factories.redis_proc()
redisdb = factories.redisdb('redis_proc')

postgresql_proc = factories.postgresql_proc()
postgresql = factories.postgresql('postgresql_proc')

mysql_proc = factories.mysql_proc()
mysql = factories.mysql('mysql_proc')


@pytest.fixture
def mysqldb(mysql):
    warnings.warn(
        '`mysqldb` fixture is deprecated. Please use `mysql` instead.',
        DeprecationWarning,
        2
コード例 #8
0
from pytest_dbfixtures.utils import extract_version, compare_version


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'
コード例 #9
0
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'


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'
コード例 #10
0
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',
コード例 #11
0
from pytest_dbfixtures.utils import extract_version, compare_version


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"