~rvb/maas/transaction-1.7-bug-1409852

« back to all changes in this revision

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

merged upstream

Show diffs side-by-side

added added

removed removed

Lines of Context:
14
14
__metaclass__ = type
15
15
__all__ = []
16
16
 
 
17
import re
 
18
 
17
19
from maastesting.matchers import (
18
20
    IsFiredDeferred,
19
21
    IsUnfiredDeferred,
26
28
    )
27
29
from provisioningserver.rpc import common
28
30
from provisioningserver.rpc.testing.doubles import DummyConnection
 
31
from testtools import ExpectedException
29
32
from testtools.matchers import (
30
33
    Equals,
31
34
    Is,
62
65
        self.assertThat(conn.callRemote, MockCalledOnceWith(
63
66
            sentinel.command, foo=sentinel.foo, bar=sentinel.bar))
64
67
 
 
68
    def test_call_with_keyword_arguments_raises_useful_error(self):
 
69
        conn = DummyConnection()
 
70
        client = common.Client(conn)
 
71
        expected_message = re.escape(
 
72
            "provisioningserver.rpc.common.Client called with 3 positional "
 
73
            "arguments, (1, 2, 3), but positional arguments are not "
 
74
            "supported. Usage: client(command, arg1=value1, ...)")
 
75
        with ExpectedException(TypeError, expected_message):
 
76
            client(sentinel.command, 1, 2, 3)
 
77
 
65
78
    def test_getHostCertificate(self):
66
79
        conn, client = self.make_connection_and_client()
67
80
        conn.hostCertificate = sentinel.hostCertificate