PageRenderTime 35ms CodeModel.GetById 19ms app.highlight 12ms RepoModel.GetById 2ms app.codeStats 0ms

/shabti/templates/auth/+package+/tests/functional/test_elixir.py_tmpl

https://bitbucket.org/gawel/shabti
Unknown | 39 lines | 30 code | 9 blank | 0 comment | 0 complexity | ca34a1e4592caa8fc30d9d75ab924add MD5 | raw file
 1{{if elixir}}
 2# auth/tests/functional/test_elixir.py
 3import {{package}}.model as model
 4from {{package}}.tests import *
 5
 6class TestRest(TestModel):
 7    
 8    def test_metadata(self):
 9        """TestRest (auth): model is loaded"""
10        tgt = 'A collection of Tables and their associated schema constructs.'
11        assert tgt in model.metadata.__doc__
12    
13
14    def test_session(self):
15        """TestRest (auth): model is sqlite (brittle)"""
16        assert model.Session.connection().dialect.name is 'sqlite'
17    
18
19    def test_model_ops(self):
20        """TestRest (auth): entity retrieval is correct"""
21        g = model.Session.query(model.Group).filter_by(
22                    name=u"Administrators").all()
23        assert len(g) == 1, g
24        assert g[0].name == "Administrators"
25        u = model.Session.query(model.User).filter_by(
26                                    username=u"admin").all()
27        assert len(u) == 1, u
28        assert u[0].username == 'admin'
29        group = model.Session.query(model.Group).get(2)
30        assert group.name == u'Subscription Members'
31        u = model.Session.query(model.User).all()
32        assert len(u) == 2, u
33        print(group.permissions)
34        assert len(group.permissions) == 1
35        
36    
37
38# --- Added by Shabti auth template
39{{endif}}