~rvb/maas/bug-1287310

« back to all changes in this revision

Viewing changes to src/maasserver/utils/tests/test_forms.py

  • Committer: Raphael Badin
  • Date: 2014-03-17 15:15:53 UTC
  • Revision ID: raphael.badin@canonical.com-20140317151553-qqtuaoab2akrqlo2
Fix bug 1287310.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# Copyright 2014 Canonical Ltd.  This software is licensed under the
 
2
# GNU Affero General Public License version 3 (see the file LICENSE).
 
3
 
 
4
"""Tests for forms helpers."""
 
5
 
 
6
from __future__ import (
 
7
    absolute_import,
 
8
    print_function,
 
9
    unicode_literals,
 
10
    )
 
11
 
 
12
str = None
 
13
 
 
14
__metaclass__ = type
 
15
__all__ = []
 
16
 
 
17
 
 
18
from maasserver.testing.factory import factory
 
19
from maasserver.utils.forms import compose_invalid_choice_text
 
20
from maastesting.testcase import MAASTestCase
 
21
from testtools.matchers import ContainsAll
 
22
 
 
23
 
 
24
class TestComposeInvalidChoiceText(MAASTestCase):
 
25
 
 
26
    def test_map_enum_includes_all_enum_values(self):
 
27
        choices = [
 
28
            (factory.make_name('value'), factory.make_name('key'))
 
29
            for _ in range(2)]
 
30
        msg = compose_invalid_choice_text(factory.make_name(), choices)
 
31
        self.assertThat(
 
32
            msg,
 
33
            ContainsAll(["'%s'" % key for key, val in choices]))