import {{package}}.model as model
from {{package}}.tests import *

class TestRest(TestModel):
    
    def setUp(self):
        TestModel.setUp(self)
    

    def test_metadata(self):
        tgt = 'A collection of Tables and their associated schema constructs.'
        assert tgt in model.metadata.__doc__
    

    def test_session(self):
        assert model.Session.connection().dialect.name is 'sqlite'
    

    def test_model_ops(self):
        import datetime
        g = model.Session.query(model.Group).filter_by(
                    name=u"Administrators").all()
        assert len(g) == 1
        assert g[0].name == "Administrators"
        u = model.Session.query(model.User).filter_by(username=u"admin").all()
        assert len(u) == 1
        assert u[0].username == 'admin'
        groups = model.Session.query(model.Group).all()
        group = model.Session.query(model.Group).get(2)
        print(group)
        print(list(groups))
        assert group.name == u'Subscription Members'
        u = model.Session.query(model.User).all()
        assert len(u) == 2
        print(group.permissions)
        assert len(group.permissions) == 1
        
    



