File: test_sprockets.py

package info (click to toggle)
sprox 0.6.4-1
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 480 kB
  • ctags: 1,040
  • sloc: python: 3,235; sh: 20; makefile: 6
file content (99 lines) | stat: -rw-r--r-- 2,543 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
from sprox.sprockets import Sprocket, SprocketCache, ConfigCache, FillerCache, ViewCache, ConfigCacheError
from sprox.test.base import setup_database, sorted_user_columns, SproxTest, User
from nose.tools import raises, eq_

session = None
engine  = None
connection = None
trans = None
def setup():
    global session, engine, metadata, trans
    session, engine, metadata = setup_database()

class TestViewCache(SproxTest):
    def setup(self):
        super(TestViewCache, self).setup()
        self.cache = ViewCache(session)

    def test_create(self):
        pass

    @raises(ConfigCacheError)
    def test_config_not_found(self):
        self.cache['never_find_me']

    def test_get_model_view(self):
        base = self.cache['model_view']
        eq_(base(), """<div xmlns="http://www.w3.org/1999/xhtml" class="containerwidget">
<div class="entitylabelwidget">
<a href="Document/">Document</a>
</div>
<div class="entitylabelwidget">
<a href="Example/">Example</a>
</div>
<div class="entitylabelwidget">
<a href="Group/">Group</a>
</div>
<div class="entitylabelwidget">
<a href="Permission/">Permission</a>
</div>
<div class="entitylabelwidget">
<a href="Town/">Town</a>
</div>
<div class="entitylabelwidget">
<a href="User/">User</a>
</div>
</div>""")

    def test_get_empty(self):
        base = self.cache['listing__User']
        b = base()
        assert """<table class="grid">
    <thead>
        <tr>
            <th class="col_0">
            actions
            </th><th class="col_1">
            _password
            </th><th class="col_2">
            user_id
            </th><th class="col_3">
            user_name
            </th><th class="col_4">
            email_address
            </th><th class="col_5">
            display_name
            </th><th class="col_6">
            created
            </th><th class="col_7">
            town_id
            </th><th class="col_8">
            town
            </th><th class="col_9">
            password
            </th><th class="col_10">
            groups
            </th>
        </tr>
    </thead>
    <tbody>
    </tbody>
</table>
      No Records Found.
</div>""" in b, b

    @raises(ConfigCacheError)
    def get_not_found(self):
        self.cache['not_find_me']

class TestSprocketCache:
    def setup(self):
        self.cache = SprocketCache(session)

    def test_create(self):
        pass

    def test_get_sprocket(self):
        base = self.cache['listing__User']
        assert base.view is not None
        assert base.filler is not None