Exemple #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
Exemple #2
0
def test_model_factory(schema):
    App = model.model_factory('App', schema, schema['definitions']['app'])
    assert App.__name__ == 'App'
    assert App.schema == schema
Exemple #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>'
Exemple #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'
Exemple #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'
Exemple #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'