~lutostag/ubuntu/trusty/maas/1.5.2+packagefix

« back to all changes in this revision

Viewing changes to src/provisioningserver/rpc/tests/test_arguments.py

  • Committer: Package Import Robot
  • Author(s): Andres Rodriguez
  • Date: 2014-03-28 10:43:53 UTC
  • mto: This revision was merged to the branch mainline in revision 57.
  • Revision ID: package-import@ubuntu.com-20140328104353-ekpolg0pm5xnvq2s
Tags: upstream-1.5+bzr2204
ImportĀ upstreamĀ versionĀ 1.5+bzr2204

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
"""Test AMP argument classes."""
 
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
from maastesting.testcase import MAASTestCase
 
18
from provisioningserver.rpc import arguments
 
19
from testtools.matchers import (
 
20
    Equals,
 
21
    IsInstance,
 
22
    )
 
23
 
 
24
 
 
25
class TestStructureAsJSON(MAASTestCase):
 
26
 
 
27
    example = {
 
28
        "an": "example", "structure": 12.34,
 
29
        "with": None, "and": ["lists", "of", "things"],
 
30
        "and": {"an": "embedded structure"},
 
31
    }
 
32
 
 
33
    def test_round_trip(self):
 
34
        argument = arguments.StructureAsJSON()
 
35
        encoded = argument.toString(self.example)
 
36
        self.assertThat(encoded, IsInstance(bytes))
 
37
        decoded = argument.fromString(encoded)
 
38
        self.assertThat(decoded, Equals(self.example))