Revision 7fa5c263

b/kamaki/clients/__init__.py
125 125
        url += '' if url.endswith('/') else '/'
126 126
        if path:
127 127
            url += _encode(path[1:] if path.startswith('/') else path)
128
        for i, (key, val) in enumerate(params.items()):
128
        delim = '?'
129
        for key, val in params.items():
129 130
            val = _encode(val)
130
            url += '%s%s' % ('&' if i else '?', key)
131
            if val:
132
                url += '=%s' % val
131
            url += '%s%s%s' % (delim, key, ('=%s' % val) if val else '')
132
            delim = '&'
133 133
        parsed = urlparse(url)
134 134
        self.url = url
135 135
        self.path = parsed.path or '/'
......
144 144
        assert method in HTTP_METHODS, 'Invalid http method %s' % method
145 145
        if headers:
146 146
            assert isinstance(headers, dict)
147
            self.headers = dict(headers)
147
        self.headers = dict(headers)
148 148
        self.method, self.data = method, data
149 149
        self.scheme, self.netloc = self._connection_info(url, path, params)
150 150

  
b/kamaki/clients/test.py
38 38
from itertools import product
39 39
from random import randint
40 40

  
41
from kamaki.clients.connection.test import (
42
    KamakiConnection,
43
    KamakiHTTPConnection,
44
    KamakiResponse,
45
    KamakiHTTPResponse)
46 41
from kamaki.clients.utils.test import Utils
47 42
from kamaki.clients.astakos.test import AstakosClient
48 43
from kamaki.clients.compute.test import ComputeClient, ComputeRestClient
......
97 92
            self.assertEqual(exp_details, ce.details)
98 93

  
99 94

  
95
class RequestManager(TestCase):
96

  
97
    def setUp(self):
98
        from kamaki.clients import RequestManager
99
        self.RM = RequestManager
100

  
101
    def test___init__(self):
102
        from kamaki.clients import HTTP_METHODS
103
        method_values = HTTP_METHODS + [v.lower() for v in HTTP_METHODS]
104
        for args in product(
105
                tuple(method_values),
106
                ('http://www.example.com', 'https://example.com', ''),
107
                ('/some/path', '/' ''),
108
                ('Some data', '', None),
109
                (dict(k1='v1', k2='v2'), dict()),
110
                (dict(k='v', k2=None, k3='v3'), dict(k=0), dict(k='v'), {})):
111
            req = self.RM(*args)
112
            method, url, path, data, headers, params = args
113
            self.assertEqual(req.method, method.upper())
114
            for i, (k, v) in enumerate(params.items()):
115
                path += '%s%s%s' % (
116
                    '&' if '?' in path or i else '?',
117
                    k,
118
                    ('=%s' % v) if v else '')
119
            self.assertEqual(req.path, path)
120
            self.assertEqual(req.data, data)
121
            self.assertEqual(req.headers, headers)
122
        self.assertRaises(AssertionError, self.RM, 'GOT', '', '', '', {}, {})
123

  
124

  
100 125
class SilentEvent(TestCase):
101 126

  
102 127
    def thread_content(self, methodid, raiseException=0):

Also available in: Unified diff