Example #1
0
class CeleryConfigMixin:
    _CELERY_BACKENDS = ["ampq", "redis"]
    CELERY_BROKER_BACKEND = props.Choice(default="ampq",
                                         choices=_CELERY_BACKENDS)
    CELERY_RESULTS_BACKEND = props.Choice(default="ampq",
                                          choices=_CELERY_BACKENDS)
    CELERY_REDIS_DATABASE_ID = props.String(default="0")
Example #2
0
class PostgresConfigMixin:
    TEST_DB_URL = props.String(default="sqlite:///:memory:")
    DB_DRIVER = props.String(default="postgres")
    DB_HOST = props.String(default="localhost")
    DB_PORT = props.Int(default=5432)
    DB_USER = props.String(default="postgres")
    DB_PASS = props.String(default="postgres")
    DB_NAME = props.String(default="postgres")
Example #3
0
class CreateItemSchema:
    name = props.String(min_length=3, max_length=32)
Example #4
0
def test_fields():
    config = make_config(thing=props.Int(), other=props.String())
    assert hasattr(config, "THING")
    assert hasattr(config, "OTHER")
Example #5
0
class RedisConfigMixin:
    REDIS_DRIVER = props.String(default="redis")
    REDIS_HOST = props.String(default="localhost")
    REDIS_PORT = props.Int(default=6379)
    REDIS_PASS = props.String(nullable=True)
Example #6
0
class RabbitConfigMixin:
    RABBIT_DRIVER = props.String(default="ampq")
    RABBIT_HOST = props.String(default="localhost")
    RABBIT_PORT = props.Int(default=5672)
    RABBIT_USER = props.String(default="guest")
    RABBIT_PASS = props.String(default="guest")
Example #7
0
def test_nullable():
    props.String(nullable=True).load(None)
Example #8
0
def test_not_nullable():
    with pytest.raises(props.PropertyValidationError):
        props.String().load(None)
Example #9
0
 class ModelB(props.Model):
     x = props.String()
Example #10
0
def test_too_long():
    with pytest.raises(props.PropertyValidationError):
        props.String(max_length=2).load("123")
Example #11
0
def test_too_short():
    with pytest.raises(props.PropertyValidationError):
        props.String(min_length=10).load("123")
Example #12
0
def test_default():
    assert props.String(default="12345").load(None) == "12345"
Example #13
0
def test_wrong_type():
    with pytest.raises(props.PropertyValidationError):
        props.String().load(12345)