Beispiel #1
0
    def test_put_kv_instantiates_request_object(self):
        put_kv('some_key', 'some_value')

        self.request.Request.assert_called_once_with(
            url='http://localhost:8500/v1/kv/some_key',
            data=str.encode('some_value'),
            method='PUT')
Beispiel #2
0
    def test_put_kv_does_request_with_cas_version_number_as_query_param(self):
        put_kv('some_key', 'some_value', cas=127)

        self.request.Request.assert_called_once_with(
            url='http://localhost:8500/v1/kv/some_key/?cas=127',
            data=str.encode('some_value'),
            method='PUT')
Beispiel #3
0
 def put(self, k, v):
     """
     Put a key value pair at the configured endpoint
     :param str k: key to put
     :param str v: value to put
     :return None:
     """
     return put_kv(k, v, endpoint=self.kv_endpoint, timeout=self.timeout)
Beispiel #4
0
 def put(self, k, v, cas=None):
     """
     Put a key value pair at the configured endpoint
     :param str k: key to put
     :param int cas: the cas version number. If None, no cas is used.
     :param str v: value to put
     :return None:
     """
     return put_kv(
         k, v, cas,
         endpoint=join(self.endpoint, 'kv/'),
         timeout=self.timeout
     )
Beispiel #5
0
    def test_put_kv_logs_debug_message(self):
        put_kv('some_key', 'some_value')

        self.assertTrue(self.log.debug.called)
Beispiel #6
0
    def test_put_kv_does_request_with_specified_timeout(self):
        put_kv('some_key', 'some_value', timeout=10)

        self.request.urlopen.assert_called_once_with(
            self.request.Request.return_value, timeout=10)
Beispiel #7
0
    def test_put_kv_does_request(self):
        put_kv('some_key', 'some_value')

        self.request.urlopen.assert_called_once_with(
            self.request.Request.return_value,
            timeout=socket._GLOBAL_DEFAULT_TIMEOUT)