Source

wheezy.html / src / wheezy / html / ext / tests / test_lexer.py

Full commit
  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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721

""" Unit tests for ``wheezy.html.ext.lexer``.
"""

import unittest


def generate_white_space_patterns():
    for t in ['x', ' x', 'x ', ' x ', '[ x', 'x ]', '[ x ]', 'xx', 'x x']:
        for s in [' ', '\t', '\n', ' \t', ' \n', '\n ']:
            for n in [1, 3]:
                yield t.replace(' ', s * n).replace('x', '%(w)s')


class PreprocessorInitTestCase(unittest.TestCase):
    """ Test the ``Preprocessor.__init__``.
    """

    def test_assert_widgets_placeholder(self):
        """ Assert widgets pattern has a placeholder for supported
            widgets.
        """
        from wheezy.html.ext.lexer import Preprocessor
        self.assertRaises(AssertionError, lambda: Preprocessor(''))

    def test_widgets(self):
        """ Ensure widgets supported.
        """
        from wheezy.html.ext.lexer import Preprocessor
        p = Preprocessor('%(widgets)s')
        assert 17 == len(p.widgets)
        assert 'checkbox|dropdown|emptybox|error|hidden|info|'\
            'label|listbox|multiple_checkbox|multiple_hidden|'\
            'multiple_select|password|radio|select|textarea|'\
            'textbox|warning' == '|'.join(
                sorted(p.RE_WIDGETS.pattern.split('|')))


class PreprocessorHelpersTestCase(unittest.TestCase):
    """ Test the ``Preprocessor`` helpers.
    """

    def setUp(self):
        from wheezy.html.ext.lexer import Preprocessor
        self.p = Preprocessor('%(widgets)s')

    def test_expression(self):
        """ Expression distinguish text, number and python object access.
            Python object access is filtered.
        """
        self.p.EXPRESSION = '%(expr)s|%(expr_filter)s'

        assert 'text' == self.p.expression('"text"')
        assert '100' == self.p.expression('100')
        assert 'user.name|filter' == self.p.expression('user.name', 'filter')

    def test_join_attrs(self):
        """ Ensure HTML attributes are joined correctly.
        """
        assert '' == self.p.join_attrs({})

        self.p.EXPRESSION = '%(expr)s%(expr_filter)s'
        assert ' autocomplete="off" disabled="${disabled}" ' \
            'maxlength="100"' == self.p.join_attrs({
            'autocomplete': 'off',
            'maxlength': '100',
            'disabled': '${disabled}'})

    def test_error_class_no_class(self):
        """ Substitute ``name`` in case ``class_`` is undefined.
        """
        self.p.ERROR_CLASS0 = '=%(name)s='
        assert '=x=' == self.p.error_class('x', class_='')

    def test_error_class(self):
        """ Substitute ``name`` and ``class`` in case ``class_``
            is defined.
        """
        self.p.ERROR_CLASS1 = '=%(name)s %(class)s='
        assert '=x c=' == self.p.error_class('x', class_='"c"')


class PreprocessorWidgetsTestCase(unittest.TestCase):
    """ Test the ``Preprocessor`` widgets.
    """

    def setUp(self):
        from wheezy.html.ext.lexer import Preprocessor
        self.p = Preprocessor('%(widgets)s')
        self.p.EXPRESSION = '%(expr)s%(expr_filter)s'
        self.p.ERROR_CLASS1 = '%(name)s %(class)s'

    def test_hidden(self):
        """ hidden widget
        """
        self.p.HIDDEN = '%(name)s %(value)s'
        assert 'pref model.pref|f' == self.p.hidden(
            'model.pref', None, '|f')

    def test_multiple_hidden(self):
        """ multiple_hidden widget
        """
        self.p.MULTIPLE_HIDDEN = '%(name)s %(value)s%(expr_filter)s'
        assert 'prefs model.prefs|f' == self.p.multiple_hidden(
            'model.prefs', None, '|f')

    def test_label(self):
        """ label widget
        """
        self.p.LABEL = """
            id = %(id)s
            name = %(name)s
            value = %(value)s
            attrs = %(attrs)s
            class = %(class)s
        """
        assert """
            id = user-name
            name = user_name
            value = User:
            attrs =  autocomplete="off"
            class = user_name x
        """ == self.p.label('model.user_name',
                            '"User:", class="x", autocomplete="off"', '|f')

    def test_emptybox(self):
        """ emptybox widget
        """
        self.p.INPUT = """
            id = %(id)s
            name = %(name)s
            type = %(type)s
            value = %(value)s
            condition = |%(condition)s|
            func = %(func)s
            expr_filter = %(expr_filter)s
            attrs = %(attrs)s
            class = %(class)s
        """
        assert """
            id = user-name
            name = user_name
            type = text
            value = model.user_name
            condition = ||
            func = model.user_name
            expr_filter = |f
            attrs =  autocomplete="off"
            class = user_name x
        """ == self.p.emptybox('model.user_name',
                               'class="x", autocomplete="off"', '|f')

    def test_textbox(self):
        """ textbox widget
        """
        self.p.INPUT = """
            id = %(id)s
            name = %(name)s
            type = %(type)s
            value = %(value)s
            condition = |%(condition)s|
            func = %(func)s
            expr_filter = %(expr_filter)s
            attrs = %(attrs)s
            class = %(class)s
        """
        assert """
            id = user-name
            name = user_name
            type = text
            value = model.user_name
            condition = | not in (None, '')|
            func = model.user_name
            expr_filter = |f
            attrs =  autocomplete="off"
            class = user_name x
        """ == self.p.textbox('model.user_name',
                              'class="x", autocomplete="off"', '|f')

    def test_password(self):
        """ password widget
        """
        self.p.INPUT = """
            id = %(id)s
            name = %(name)s
            type = %(type)s
            value = %(value)s
            condition = |%(condition)s|
            func = %(func)s
            expr_filter = %(expr_filter)s
            attrs = %(attrs)s
            class = %(class)s
        """
        assert """
            id = user-pwd
            name = user_pwd
            type = password
            value = model.user_pwd
            condition = | not in (None, '')|
            func = model.user_pwd
            expr_filter = |f
            attrs =  autocomplete="off"
            class = user_pwd x
        """ == self.p.password('model.user_pwd',
                               'class="x", autocomplete="off"', '|f')

    def test_textarea(self):
        """ textarea widget
        """
        self.p.TEXTAREA = """
            id = %(id)s
            name = %(name)s
            value = %(value)s
            attrs = %(attrs)s
            class = %(class)s
        """
        assert """
            id = comment
            name = comment
            value = model.comment|f
            attrs =  autocomplete="off" cols="40" rows="9"
            class = comment x
        """ == self.p.textarea('model.comment',
                               'class="x", autocomplete="off"', '|f')

    def test_checkbox(self):
        """ checkbox widget
        """
        self.p.CHECKBOX = """
            id = %(id)s
            name = %(name)s
            value = %(value)s
            attrs = %(attrs)s
            class = %(class)s
        """
        assert """
            id = accepts
            name = accepts
            value = model.accepts
            attrs =  autocomplete="off"
            class = accepts x
        """ == self.p.checkbox('model.accepts',
                               'class="x", autocomplete="off"', '|f')

    def test_multiple_checkbox(self):
        """ multiple_checkbox widget
        """
        self.p.MULTIPLE_CHECKBOX = """
            id = %(id)s
            name = %(name)s
            choices = %(choices)s
            value = %(value)s
            expr_filter = %(expr_filter)s
            attrs = %(attrs)s
            class = %(class)s
        """
        assert """
            id = colors
            name = colors
            choices = ${lst}
            value = model.colors
            expr_filter = |f
            attrs =  cursor="auto"
            class = colors x
        """ == self.p.multiple_checkbox(
            'model.colors',
            'class="x", cursor="auto", choices=${lst}', '|f')

    def test_radio(self):
        """ radio widget
        """
        self.p.RADIO = """
            id = %(id)s
            name = %(name)s
            choices = %(choices)s
            value = %(value)s
            expr_filter = %(expr_filter)s
            attrs = %(attrs)s
            class = %(class)s
        """
        assert """
            id = yes-no
            name = yes_no
            choices = ${lst}
            value = model.yes_no
            expr_filter = |f
            attrs =  cursor="auto"
            class = yes_no x
        """ == self.p.radio('model.yes_no',
                            'class="x", cursor="auto", choices=${lst}', '|f')

    def test_dropdown(self):
        """ dropdown widget
        """
        self.p.SELECT = """
            id = %(id)s
            name = %(name)s
            select_type = |%(select_type)s|
            choices = %(choices)s
            value = %(value)s
            expr_filter = %(expr_filter)s
            attrs = %(attrs)s
            class = %(class)s
        """
        assert """
            id = security-question
            name = security_question
            select_type = ||
            choices = ${lst}
            value = model.security_question
            expr_filter = |f
            attrs =  cursor="auto"
            class = security_question x
        """ == self.p.dropdown(
            'model.security_question',
            'class="x", cursor="auto", choices=${lst}', '|f')

    def test_listbox(self):
        """ listbox widget
        """
        self.p.SELECT = """
            id = %(id)s
            name = %(name)s
            select_type = %(select_type)s
            choices = %(choices)s
            value = %(value)s
            expr_filter = %(expr_filter)s
            attrs = %(attrs)s
            class = %(class)s
        """
        assert """
            id = languages
            name = languages
            select_type =  multiple="multiple"
            choices = ${lst}
            value = model.languages
            expr_filter = |f
            attrs =  cursor="auto"
            class = languages x
        """ == self.p.listbox(
            'model.languages',
            'class="x", cursor="auto", choices=${lst}', '|f')

    def test_error(self):
        """ error widget
        """
        self.p.ERROR = """
            name = %(name)s
            attrs = %(attrs)s
            expr_filter = %(expr_filter)s
        """
        assert """
            name = user_name
            attrs =  class="error" cursor="auto"
            expr_filter = |f
        """ == self.p.error('model.user_name',
                            'cursor="auto"', '|f')
        assert """
            name = user_name
            attrs =  class="error x" cursor="auto"
            expr_filter = |f
        """ == self.p.error('model.user_name',
                            'class="x", cursor="auto"', '|f')
        assert """
            name = __ERROR__
            attrs =  class="error-message" cursor="auto"
            expr_filter = |f
        """ == self.p.error('model',
                            'cursor="auto"', '|f')
        assert """
            name = __ERROR__
            attrs =  class="error-message x" cursor="auto"
            expr_filter = |f
        """ == self.p.error('model',
                            'class="x", cursor="auto"', '|f')

    def test_info(self):
        """ info widget
        """
        self.p.MESSAGE = """
            value = %(value)s
            info = %(info)s
            attrs = %(attrs)s
        """
        assert """
            value = model.username
            info = model.username|f
            attrs =  class="info" cursor="auto"
        """ == self.p.info('model.username', 'cursor="auto"', '|f')
        assert """
            value = model.username
            info = model.username|f
            attrs =  class="info x" cursor="auto"
        """ == self.p.info('model.username', 'class="x", cursor="auto"', '|f')
        assert """
            value = model
            info = model|f
            attrs =  class="info-message" cursor="auto"
        """ == self.p.info('model', 'cursor="auto"', '|f')
        assert """
            value = model
            info = model|f
            attrs =  class="info-message x" cursor="auto"
        """ == self.p.info('model', 'class="x", cursor="auto"', '|f')

    def test_warning(self):
        """ warning widget
        """
        self.p.MESSAGE = """
            value = %(value)s
            info = %(info)s
            attrs = %(attrs)s
        """
        assert """
            value = model.username
            info = model.username|f
            attrs =  class="warning" cursor="auto"
        """ == self.p.warning('model.username', 'cursor="auto"', '|f')
        assert """
            value = model.username
            info = model.username|f
            attrs =  class="warning x" cursor="auto"
        """ == self.p.warning('model.username',
                              'class="x", cursor="auto"', '|f')
        assert """
            value = model
            info = model|f
            attrs =  class="warning-message" cursor="auto"
        """ == self.p.warning('model', 'cursor="auto"', '|f')
        assert """
            value = model
            info = model|f
            attrs =  class="warning-message x" cursor="auto"
        """ == self.p.warning('model', 'class="x", cursor="auto"', '|f')


class PreprocessorMixin(object):
    """ Test the ``Preprocessor``.
    """
    from operator import itemgetter

    WHITE_SPACE_PATTERNS = ['%(w)s']

    class Dummy(object):
        pass

    scm = sorted({
        'git': 'Git', 'hg': 'Mercurial', 'svn': 'SVN'
    }.items(), key=itemgetter(1))

    def setUp(self):
        self.m = PreprocessorMixin.Dummy()
        self.e = {}

    def assert_render_equal(self, template, expected, **kwargs):
        pass

    def render(self, widget, html):
        """ hidden widget.
        """
        for wsp in self.WHITE_SPACE_PATTERNS:
            self.assert_render_equal(
                wsp % {'w': widget},
                wsp % {'w': html},
                model=self.m, errors=self.e, scm=self.scm,
                message=(hasattr(self.m, 'message') and self.m.message or ''))

    def test_hidden(self):
        """ hidden widget.
        """
        self.m.pref = 'ab<c>'
        self.render(self.HIDDEN,
                    '<input type="hidden" name="pref" value="ab&lt;c&gt;" />')

    def test_multiple_hidden(self):
        """ multiple_hidden widget.
        """
        self.m.prefs = ['a', 'b']
        self.render(self.MULTIPLE_HIDDEN,
                    '<input type="hidden" name="prefs" value="a" />'
                    '<input type="hidden" name="prefs" value="b" />')

    def test_label(self):
        """ label widget.
        """
        self.m.username = ''
        self.render(self.LABEL,
                    '<label for="username"><i>*</i>Username:</label>')
        self.e['username'] = 'Error'
        self.render(self.LABEL,
                    '<label for="username" class="error">'
                    '<i>*</i>Username:</label>')

    def test_emptybox(self):
        """ emptybox widget.
        """
        self.m.amount = 10
        self.render(self.EMPTYBOX,
                    '<input id="amount" name="amount" type="text" class="x" '
                    'value="10" />')
        self.m.amount = 0
        self.render(
            self.EMPTYBOX,
            '<input id="amount" name="amount" type="text" class="x" />')
        self.e['amount'] = 'Error'
        self.render(self.EMPTYBOX,
                    '<input id="amount" name="amount" type="text"'
                    ' class="error x" />')

    def test_textbox(self):
        """ textbox widget.
        """
        self.m.username = 'John'
        self.render(self.TEXTBOX,
                    '<input id="username" name="username" type="text" '
                    'autocomplete="off" value="John" />')
        self.m.username = ''
        self.render(self.TEXTBOX,
                    '<input id="username" name="username" type="text" '
                    'autocomplete="off" />')
        self.e['username'] = 'Error'
        self.render(self.TEXTBOX,
                    '<input id="username" name="username" type="text" '
                    'autocomplete="off" class="error" />')

    def test_password(self):
        """ password widget.
        """
        self.m.pwd = ''
        self.render(self.PASSWORD,
                    '<input id="pwd" name="pwd" type="password" />')
        self.e['pwd'] = 'Error'
        self.render(
            self.PASSWORD,
            '<input id="pwd" name="pwd" type="password" class="error" />')

    def test_textarea(self):
        """ textarea widget.
        """
        self.m.comment = 'x'
        self.render(self.TEXTAREA,
                    '<textarea id="comment" name="comment" '
                    'cols="40" rows="9">x</textarea>')
        self.e['comment'] = 'Error'
        self.render(self.TEXTAREA,
                    '<textarea id="comment" name="comment" '
                    'cols="40" rows="9" class="error">x</textarea>')

    def test_checkbox(self):
        """ checkbox widget.
        """
        self.m.remember_me = True
        self.render(self.CHECKBOX,
                    '<input id="remember-me" name="remember_me" '
                    'type="checkbox" value="1" checked="checked" />')
        self.m.remember_me = False
        self.render(self.CHECKBOX,
                    '<input id="remember-me" name="remember_me" '
                    'type="checkbox" value="1" />')
        self.e['remember_me'] = 'Error'
        self.render(self.CHECKBOX,
                    '<input id="remember-me" name="remember_me" '
                    'type="checkbox" value="1" class="error" />')

    def test_multiple_checkbox(self):
        """ multiple_checkbox widget.
        """
        self.m.scm = ['hg', 'git']
        self.render(self.MULTIPLE_CHECKBOX,
                    '<label><input id="scm" name="scm" type="checkbox" '
                    'value="1" checked="checked" />Git</label>'
                    '<label><input id="scm" name="scm" type="checkbox" '
                    'value="1" checked="checked" />Mercurial</label>'
                    '<label><input id="scm" name="scm" type="checkbox" '
                    'value="1" />SVN</label>')
        self.m.scm = []
        self.render(self.MULTIPLE_CHECKBOX,
                    '<label><input id="scm" name="scm" type="checkbox" '
                    'value="1" />Git</label>'
                    '<label><input id="scm" name="scm" type="checkbox" '
                    'value="1" />Mercurial</label>'
                    '<label><input id="scm" name="scm" type="checkbox" '
                    'value="1" />SVN</label>')
        self.e['scm'] = 'Error'
        self.render(
            self.MULTIPLE_CHECKBOX,
            '<label class="error"><input id="scm" name="scm" '
            'type="checkbox" value="1" class="error" />Git</label>'
            '<label class="error"><input id="scm" name="scm" '
            'type="checkbox" value="1" class="error" />Mercurial</label>'
            '<label class="error"><input id="scm" name="scm" '
            'type="checkbox" value="1" class="error" />SVN</label>')

    def test_radio(self):
        """ radio widget.
        """
        self.m.scm = 'hg'
        self.render(self.RADIO,
                    '<label><input type="radio" name="scm" value="git" />'
                    'Git</label>'
                    '<label><input type="radio" name="scm" value="hg" '
                    'checked="checked" />Mercurial</label>'
                    '<label><input type="radio" name="scm" value="svn" />'
                    'SVN</label>')
        self.m.scm = ''
        self.render(self.RADIO,
                    '<label><input type="radio" name="scm" value="git" />'
                    'Git</label>'
                    '<label><input type="radio" name="scm" value="hg" />'
                    'Mercurial</label>'
                    '<label><input type="radio" name="scm" value="svn" />'
                    'SVN</label>')
        self.e['scm'] = 'Error'
        self.render(self.RADIO,
                    '<label class="error"><input type="radio" name="scm" '
                    'value="git" class="error" />Git</label>'
                    '<label class="error"><input type="radio" name="scm" '
                    'value="hg" class="error" />Mercurial</label>'
                    '<label class="error"><input type="radio" name="scm" '
                    'value="svn" class="error" />SVN</label>')

    def test_dropdown(self):
        """ dropdown widget.
        """
        self.m.scm = 'hg'
        self.render(
            self.DROPDOWN,
            '<select id="scm" name="scm">'
            '<option value="git">Git</option>'
            '<option value="hg" selected="selected">Mercurial</option>'
            '<option value="svn">SVN</option>'
            '</select>')
        self.m.scm = ''
        self.render(self.DROPDOWN,
                    '<select id="scm" name="scm">'
                    '<option value="git">Git</option>'
                    '<option value="hg">Mercurial</option>'
                    '<option value="svn">SVN</option>'
                    '</select>')
        self.e['scm'] = 'Error'
        self.render(self.DROPDOWN,
                    '<select id="scm" name="scm" class="error">'
                    '<option value="git">Git</option>'
                    '<option value="hg">Mercurial</option>'
                    '<option value="svn">SVN</option>'
                    '</select>')

    def test_listbox(self):
        """ listbox widget.
        """
        self.m.scm = 'hg'
        self.render(
            self.LISTBOX,
            '<select id="scm" name="scm" multiple="multiple" class="x">'
            '<option value="git">Git</option>'
            '<option value="hg" selected="selected">Mercurial</option>'
            '<option value="svn">SVN</option>'
            '</select>')
        self.m.scm = ''
        self.render(
            self.LISTBOX,
            '<select id="scm" name="scm" multiple="multiple" class="x">'
            '<option value="git">Git</option>'
            '<option value="hg">Mercurial</option>'
            '<option value="svn">SVN</option>'
            '</select>')
        self.e['scm'] = 'Error'
        self.render(self.LISTBOX,
                    '<select id="scm" name="scm" multiple="multiple" '
                    'class="error x">'
                    '<option value="git">Git</option>'
                    '<option value="hg">Mercurial</option>'
                    '<option value="svn">SVN</option>'
                    '</select>')

    def test_attribute_error(self):
        """ attribute error widget.
        """
        self.render(self.ERROR, '')
        self.e['username'] = ['Error1', 'Error2']
        self.render(self.ERROR, '<span class="error">Error2</span>')

    def test_general_error(self):
        """ general error widget.
        """
        self.render(self.GENERAL_ERROR, '')
        self.e['__ERROR__'] = ['Error1', 'Error2']
        self.render(self.GENERAL_ERROR,
                    '<span class="error-message">Error2</span>')

    def test_attribute_info(self):
        """ attribute info widget.
        """
        self.m.user_info = None
        self.render(self.INFO, '')
        self.m.user_info = 'Info'
        self.render(self.INFO, '<span class="info">Info</span>')

    def test_general_info(self):
        """ general info widget.
        """
        self.render(self.GENERAL_INFO, '')
        self.m.message = 'Message'
        self.render(self.GENERAL_INFO,
                    '<span class="info-message">Message</span>')

    def test_attribute_warning(self):
        """ attribute warning widget.
        """
        self.m.user_info = None
        self.render(self.WARNING, '')
        self.m.user_info = 'Warn'
        self.render(self.WARNING, '<span class="warning">Warn</span>')

    def test_general_warning(self):
        """ general warning widget.
        """
        self.render(self.GENERAL_WARNING, '')
        self.m.message = 'Message'
        self.render(self.GENERAL_WARNING,
                    '<span class="warning-message">Message</span>')