コード例 #1
0
 class Visit(bloop.new_base()):
     page = bloop.Column(bloop.String, hash_key=True)
     visitor = bloop.Column(bloop.Integer)
     date = bloop.Column(bloop.String)
     not_projected = bloop.Column(bloop.Integer)
     by_date = bloop.GlobalSecondaryIndex(hash_key="date",
                                          projection=["visitor"])
コード例 #2
0
def test_dynamo_name():
    """ Returns model name unless dynamo name is specified """
    column = bloop.Column(bloop.Integer)
    # Normally set when a class is defined
    column.model_name = "foo"
    assert column.dynamo_name == "foo"

    column = bloop.Column(bloop.Integer, name="foo")
    column.model_name = "bar"
    assert column.dynamo_name == "foo"
コード例 #3
0
def test_contains():
    value = object
    column = bloop.Column(bloop.Integer)
    condition = column.contains(value)

    assert isinstance(condition, bloop.condition.Contains)
    assert condition.column is column
    assert condition.value == value
コード例 #4
0
def test_begins_with():
    value = object
    column = bloop.Column(bloop.Integer)
    condition = column.begins_with(value)

    assert isinstance(condition, bloop.condition.BeginsWith)
    assert condition.column is column
    assert condition.value == value
コード例 #5
0
def test_in():
    values = [object() for _ in range(3)]
    column = bloop.Column(bloop.Integer)
    condition = column.in_(values)

    assert isinstance(condition, bloop.condition.In)
    assert condition.column is column
    assert condition.values == values
コード例 #6
0
def test_comparison(operation):
    column = bloop.Column(bloop.Integer)
    value = object()

    condition = operation(column, value)
    assert condition.comparator is operation
    assert condition.column is column
    assert condition.value is value
コード例 #7
0
def test_between():
    lower, upper = object(), object()
    column = bloop.Column(bloop.Integer)
    condition = column.between(lower, upper)

    assert isinstance(condition, bloop.condition.Between)
    assert condition.column is column
    assert condition.lower is lower
    assert condition.upper is upper
コード例 #8
0
def test_column_path():
    """ Paths can be iteratively built up, with strings or ints as keys """
    column = bloop.Column(bloop.Integer)

    comparison = column["foo"]
    assert comparison.path == ["foo"]

    comparison = column["f"]["o"]["o"]["b"]["a"]["r"]
    assert comparison.path == list("foobar")

    with pytest.raises(ValueError):
        column[object()]
コード例 #9
0
def test_equals_alias_exists():
    """
    == and != should map to attribute_not_exists and attribute_exists
    when compared to None
    """
    column = bloop.Column(bloop.Integer)

    condition = column.is_(None)
    assert isinstance(condition, bloop.condition.AttributeExists)
    assert condition.column is column
    assert condition.negate is True

    condition = column.is_not(None)
    assert isinstance(condition, bloop.condition.AttributeExists)
    assert condition.column is column
    assert condition.negate is False
コード例 #10
0
 class Admin(User):
     admin_id = bloop.Column(bloop.Integer, hash_key=True)
コード例 #11
0
 class SubModel(base_model):
     id = bloop.Column(bloop.String, hash_key=True)
コード例 #12
0
 class Model(bloop.new_base()):
     id = bloop.Column(bloop.Integer, hash_key=True, name='this.is.id')
     data = bloop.Column(DocumentType)
コード例 #13
0
 class Model(bloop.new_base()):
     id = bloop.Column(bloop.Integer, hash_key=True)
     data = bloop.Column(bloop.TypedMap(bloop.UUID))
コード例 #14
0
    class Abstract(bloop.new_base()):
        class Meta:
            abstract = True

        id = bloop.Column(bloop.Integer, hash_key=True)
コード例 #15
0
 class UnboundModel(bloop.new_base()):
     id = bloop.Column(bloop.String, hash_key=True)
コード例 #16
0
 class HashAndRange(bloop.new_base()):
     foo = bloop.Column(bloop.Integer, hash_key=True)
     bar = bloop.Column(bloop.Integer, range_key=True)
コード例 #17
0
 class Visit(bloop.new_base()):
     hash = bloop.Column(bloop.String, hash_key=True)
     range = bloop.Column(bloop.Integer, range_key=True)
     non_key = bloop.Column(bloop.Integer)
コード例 #18
0
 class Model(bloop.new_base()):
     id = bloop.Column(bloop.UUID, hash_key=True)
     counter = bloop.Column(bloop.Integer)