Exemplo n.º 1
0
def test_model_getattr(schema):
    App = model.model_factory('App', schema, schema['definitions']['app'])
    a = App(name='my-app')
    assert a.name == 'my-app'
    with pytest.raises(AttributeError):
        a.foobar
Exemplo n.º 2
0
def test_model_factory(schema):
    App = model.model_factory('App', schema, schema['definitions']['app'])
    assert App.__name__ == 'App'
    assert App.schema == schema
Exemplo n.º 3
0
def test_model_repr(schema):
    App = model.model_factory('App', schema, schema['definitions']['app'])
    a = App(id='1234', name='my-app')
    assert repr(a) == '<App: my-app>'
Exemplo n.º 4
0
def test_model_identity_only_id(schema):
    AppSetup = model.model_factory('AppSetup', schema, schema['definitions']['app-setup'])
    a = AppSetup(id='1234')
    assert a.identity() == '1234'
Exemplo n.º 5
0
def test_model_identity_not_id(schema):
    App = model.model_factory('App', schema, schema['definitions']['app'])
    a = App(id='1234', name='my-app')
    assert a.identity() == 'my-app'
Exemplo n.º 6
0
def test_model_setattr(schema):
    App = model.model_factory('App', schema, schema['definitions']['app'])
    a = App(name='my-app')
    a.name = 'changed'
    assert a.name == 'changed'