예제 #1
0
 def test_query_get_int_filter_lt_result(self):
     uuid = str(uuid4())
     self.TestEntity1(uuid, int_field=1, uuid=uuid).save()
     result = self.TestEntity1.query.filter(
         IntField("int_field") < 2).filter(
             StringField("uuid") == uuid).first()
     self.assertIsNotNone(result)
예제 #2
0
 def test_query_chained_projection_and_filters(self):
     uuid1 = str(uuid4())
     self.TestEntity1(uuid1, int_field=1, float_field=1.2).save()
     result = self.TestEntity1.query.only('int_field').filter(
         IntField('int_field') >= 1).first()
     self.assertEqual(result['int_field'], 1)
     self.assertFalse(hasattr(result, 'float_field'))
예제 #3
0
def test_query_chained_projection_and_filters(ds_entity, uuid_gen):
    uuid_gen1 = uuid_gen()
    ds_entity(uuid_gen1, int_field=1, float_field=1.2).save()
    result = ds_entity.query.only('int_field').filter(
        IntField('int_field') >= 1).first()
    assert result['int_field'] == 1
    assert not hasattr(result, 'float_field')
예제 #4
0
def field():
    return IntField()
예제 #5
0
 def test_int_field_loads(self):
     field = IntField()
     for value in [1, 1.2, True, "foo", object(), {}, []]:
         self.assertEqual(value, field.loads(value))
예제 #6
0
 def test_int_field_default_callable(self):
     field = IntField(default=int)
     self.assertEqual(int(), field.default)
예제 #7
0
 def test_int_field_default_value(self):
     field = IntField(default=1)
     self.assertEqual(1, field.default)
예제 #8
0
 def test_int_field_default_default_None(self):
     field = IntField()
     self.assertIsNone(field.default)
예제 #9
0
 def test_int_field_dumps_enforce_type(self):
     field = IntField(enforce_type=True)
     for value in [1.2, True, "foo", object(), {}, []]:
         with self.assertRaises(ValueError):
             field.dumps(value)
     self.assertEqual(1, field.dumps(1))
예제 #10
0
 def test_int_field_dumps_no_enforce_type(self):
     field = IntField()
     for value in [1, 1.2, True, "foo", object(), {}, []]:
         self.assertEqual(value, field.dumps(value))
예제 #11
0
 def test_query_get_int_filter_eq_no_result(self):
     result = self.TestEntity1.query.filter(IntField("int_field") == 1).get(
         str(uuid4()))
     self.assertIsNone(result)
예제 #12
0
def test_query_get_int_filter_lt_result(ds_entity, uuid_gen):
    uuid_gen = uuid_gen()
    ds_entity(uuid_gen, int_field=1, uuid_gen=uuid_gen).save()
    result = ds_entity.query.filter(IntField("int_field") < 2).filter(
        StringField("uuid_gen") == uuid_gen).first()
    assert result is not None
예제 #13
0
def test_query_get_int_filter_eq_no_result(ds_entity, uuid_gen):
    result = ds_entity.query.filter(IntField("int_field") == 1).get(uuid_gen())
    assert result is None