Exemplo n.º 1
0
def test_schema_crud(a_class):
    a_class.create()
    f1 = Class.SchemaField(name='foo')
    f2 = Class.SchemaField(name='bar')
    f3 = Class.SchemaField(name='baz')
    a_class.edit_schema(add_fields=(f1, f2))
    a_class.edit_schema(remove_fields=(f1, ), add_fields=(f3, ))
def cls(request, domain, namespace):
    tcls = Class(
        name="Request",
        namespace=namespace,
        setup_schema=[Class.SchemaField(name="rel5", type_="Relationship")])
    tcls.create()
    request.addfinalizer(lambda: tcls.delete() if tcls.exists() else None)
    return tcls
def original_method(request, original_method_write_data, original_domain):
    method = Method(name=fauxfactory.gen_alphanumeric(),
                    data=METHOD_TORSO.format(original_method_write_data),
                    cls=Class(name="Request",
                              namespace=Namespace(name="System",
                                                  parent=original_domain),
                              setup_schema=[
                                  Class.SchemaField(name="meth5",
                                                    type_="Method")
                              ]))
    method.create()
    request.addfinalizer(lambda: method.delete() if method.exists() else None)
    return method
def original_instance(request, original_method, original_domain):
    instance = Instance(name=fauxfactory.gen_alphanumeric(),
                        values={"meth5": {
                            "value": original_method.name
                        }},
                        cls=Class(name="Request",
                                  namespace=Namespace(name="System",
                                                      parent=original_domain),
                                  setup_schema=[
                                      Class.SchemaField(name="meth5",
                                                        type_="Method")
                                  ]))
    instance.create()
    request.addfinalizer(lambda: instance.delete()
                         if instance.exists() else None)
    return instance