Ejemplo n.º 1
0
def test_text_valid_data():
    schema = {
        'type': 'object',
        'properties': {
            'test': datatypes.Text.JSON_SCHEMA
        }
    }
    data = {'test': datatypes.Text("Example")}
    raw_data = json.loads(json.dumps(data, cls=datatypes.JSONEncoder))
    jsonschema.validate(raw_data, schema)
Ejemplo n.º 2
0
def test_text_contains(objects):
    objects.create_object(action_id=0, data={'t': datatypes.Text("Beispiel")}, schema={}, user_id=0)
    object1 = objects.create_object(action_id=0, data={'t': datatypes.Text("Example")}, schema={}, user_id=0)
    assert [object1] == objects.get_current_objects(lambda data: where_filters.text_contains(data['t'], 'amp'))
Ejemplo n.º 3
0
def test_text_deserialization():
    s = json.dumps(datatypes.Text("Test"), cls=datatypes.JSONEncoder)
    t = json.loads(s, object_hook=datatypes.JSONEncoder.object_hook)
    assert t.text == "Test"
Ejemplo n.º 4
0
def test_text_equals():
    assert datatypes.Text("Test") == datatypes.Text("Test")
    assert datatypes.Text("Test") != datatypes.Text("ABCD")
Ejemplo n.º 5
0
def test_text_serialization():
    s = json.dumps(datatypes.Text("Test"), cls=datatypes.JSONEncoder)
    l = json.loads(s)
    assert json.loads(s) == {'_type': 'text', 'text': 'Test'}