Exemple #1
0
 def test_query_get_float_filter_lt_no_result(self):
     uuid = str(uuid4())
     self.TestEntity1(uuid, float_field=2.0, uuid=uuid).save()
     result = self.TestEntity1.query.filter(
         FloatField("float_field") < 1.0).filter(
             StringField("uuid") == uuid).first()
     self.assertIsNone(result)
Exemple #2
0
def test_query_get_float_filter_lt_result(ds_entity, uuid_gen):
    uuid_gen = uuid_gen()
    a = ds_entity(uuid_gen, float_field=1.0, uuid_gen=uuid_gen)
    a.save()
    result = ds_entity.query.filter(FloatField("float_field") < 2.0).filter(
        StringField("uuid_gen") == uuid_gen).first()
    assert result is not None
Exemple #3
0
 def test_float_field_default_callable(self):
     field = FloatField(default=float)
     self.assertEqual(float(), field.default)
Exemple #4
0
 def test_float_field_default_value(self):
     field = FloatField(default=1.2)
     self.assertEqual(1.2, field.default)
Exemple #5
0
 def test_float_field_default_default_None(self):
     field = FloatField()
     self.assertIsNone(field.default)
Exemple #6
0
 def test_float_field_dumps_enforce_type(self):
     field = FloatField(enforce_type=True)
     for value in [1, True, "foo", object(), {}, []]:
         with self.assertRaises(ValueError):
             field.dumps(value)
     self.assertEqual(1.2, field.dumps(1.2))
Exemple #7
0
 def test_float_field_dumps_no_enforce_type(self):
     field = FloatField()
     for value in [1, 1.2, True, "foo", object(), {}, []]:
         self.assertEqual(value, field.dumps(value))
Exemple #8
0
 def test_float_field_loads(self):
     field = FloatField()
     for value in [1, 1.2, True, "foo", object(), {}, []]:
         self.assertEqual(value, field.loads(value))
Exemple #9
0
 def test_query_get_float_filter_eq_no_result(self):
     result = self.TestEntity1.query.filter(
         FloatField("float_field") == 1.0).get(str(uuid4()))
     self.assertIsNone(result)
Exemple #10
0
def test_query_get_float_filter_ge_no_result(ds_entity, uuid_gen):
    uuid_gen = uuid_gen()
    ds_entity(uuid_gen, float_field=0.0, uuid_gen=uuid_gen).save()
    result = ds_entity.query.filter(FloatField("float_field") >= 1.0).filter(
        StringField("uuid_gen") == uuid_gen).first()
    assert result is None
Exemple #11
0
def test_query_get_float_filter_eq_no_result(ds_entity, uuid_gen):
    result = ds_entity.query.filter(FloatField("float_field") == 1.0).get(
        uuid_gen())
    assert result is None