/usr/lib/python2.7/dist-packages/etcd/tests/unit/__init__.py is in python-etcd 0.4.3-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | import etcd
import unittest
import urllib3
import json
try:
import mock
except ImportError:
from unittest import mock
class TestClientApiBase(unittest.TestCase):
def setUp(self):
self.client = etcd.Client()
def _prepare_response(self, s, d, cluster_id=None):
if isinstance(d, dict):
data = json.dumps(d).encode('utf-8')
else:
data = d.encode('utf-8')
r = mock.create_autospec(urllib3.response.HTTPResponse)()
r.status = s
r.data = data
r.getheader.return_value = cluster_id or "abcd1234"
return r
def _mock_api(self, status, d, cluster_id=None):
resp = self._prepare_response(status, d, cluster_id=cluster_id)
self.client.api_execute = mock.MagicMock(return_value=resp)
def _mock_exception(self, exc, msg):
self.client.api_execute = mock.Mock(side_effect=exc(msg))
|