diff options
author | Aleksey Lim <alsroot@sugarlabs.org> | 2013-07-27 22:06:18 (GMT) |
---|---|---|
committer | Aleksey Lim <alsroot@sugarlabs.org> | 2013-07-27 22:06:18 (GMT) |
commit | 5224a51b3e9b78b54aa108f750681d55ad95ef6f (patch) | |
tree | 2f7d4ca6dc97542f6b2a6c575035446eb1138957 | |
parent | f68b009e2260ddf6d97eb0fa2ee7d15cf695aeea (diff) |
More polishing; rename client.*Client to more appropriate client.*Connection
58 files changed, 221 insertions, 149 deletions
diff --git a/sugar-network b/sugar-network index 0cc70e5..b25bd5c 100755 --- a/sugar-network +++ b/sugar-network @@ -28,7 +28,7 @@ from gevent import monkey from sugar_network import db, client, toolkit from sugar_network.model import RESOURCES -from sugar_network.client import IPCClient, Client +from sugar_network.client import IPCConnection, Connection from sugar_network.client.routes import ClientRoutes from sugar_network.node.routes import load_bundle from sugar_network.toolkit.router import Router, Request, Response @@ -103,7 +103,7 @@ class Application(application.Application): ) def launch(self): enforce(self.check_for_instance(), 'No sugar-network-client session') - ipc = IPCClient() + ipc = IPCConnection() enforce(self.args, 'BUNDLE_ID was not specified') bundle_id = self.args.pop(0) @@ -120,7 +120,7 @@ class Application(application.Application): ) def clone(self): enforce(self.check_for_instance(), 'No sugar-network-client session') - ipc = IPCClient() + ipc = IPCConnection() enforce(self.args, 'BUNDLE_ID was not specified') bundle_id = self.args.pop(0) @@ -197,9 +197,9 @@ class Application(application.Application): def _connect(self): if self.check_for_instance(): - return IPCClient() + return IPCConnection() else: - return Client(client.api_url.value) + return Connection(client.api_url.value) def _request(self, method, post): request = Request(method=method) @@ -239,7 +239,7 @@ class Application(application.Application): cp = None try: if self.check_for_instance(): - cp = IPCClient() + cp = IPCConnection() else: pid_path = self.new_instance() if not client.anonymous.value: diff --git a/sugar-network-node b/sugar-network-node index 681c8f2..4f6ef84 100755 --- a/sugar-network-node +++ b/sugar-network-node @@ -28,7 +28,7 @@ from sugar_network.node import stats_node, stats_user, obs from sugar_network.node.master import MasterRoutes from sugar_network.node.slave import SlaveRoutes from sugar_network.model import RESOURCES -from sugar_network.toolkit.http import Client +from sugar_network.toolkit.http import Connection from sugar_network.toolkit.router import Router from sugar_network.toolkit import coroutine, application, util, Option, enforce @@ -123,7 +123,8 @@ class Application(application.Daemon): def _ensure_instance(self): enforce(self.check_for_instance(), 'Node is not started') - return Client('http://localhost:%s' % node.port.value, trust_env=False) + return Connection('http://localhost:%s' % + node.port.value, trust_env=False) # Let toolkit.http work in concurrence diff --git a/sugar_network/client/__init__.py b/sugar_network/client/__init__.py index 2c4f23b..30dd541 100644 --- a/sugar_network/client/__init__.py +++ b/sugar_network/client/__init__.py @@ -161,7 +161,7 @@ def path(*args): return str(result) -def Client(url=None): +def Connection(url=None): from sugar_network.toolkit import http if url is None: url = api_url.value @@ -172,13 +172,13 @@ def Client(url=None): else: _logger.warning('Sugar session was never started (no DSA key),' 'fallback to anonymous mode') - return http.Client(url, creds=creds) + return http.Connection(url, creds=creds) -def IPCClient(): +def IPCConnection(): from sugar_network.toolkit import http - return http.Client( + return http.Connection( api_url='http://127.0.0.1:%s' % ipc_port.value, creds=None, # No need in proxy for localhost diff --git a/sugar_network/client/cache.py b/sugar_network/client/cache.py index d95b1fc..76c3dd0 100644 --- a/sugar_network/client/cache.py +++ b/sugar_network/client/cache.py @@ -20,9 +20,7 @@ import shutil import logging from os.path import exists, join, isdir -from sugar_network import toolkit -from sugar_network.client import IPCClient, local_root -from sugar_network.client import cache_limit, cache_lifetime +from sugar_network import toolkit, client from sugar_network.toolkit.bundle import Bundle from sugar_network.toolkit import pipe, enforce @@ -31,10 +29,10 @@ _logger = logging.getLogger('cache') def recycle(): - stat = os.statvfs(local_root.value) + stat = os.statvfs(client.local_root.value) total = stat.f_blocks * stat.f_frsize free = stat.f_bfree * stat.f_frsize - to_free = cache_limit.value * total / 100 - free + to_free = client.cache_limit.value * total / 100 - free ts = time.time() __, items = _list() @@ -46,8 +44,8 @@ def recycle(): elif mtime == 0: shutil.rmtree(path, ignore_errors=True) _logger.debug('Recycled malformed cache item %r', path) - elif cache_lifetime.value and \ - cache_lifetime.value < (ts - mtime) / 86400.0: + elif client.cache_lifetime.value and \ + client.cache_lifetime.value < (ts - mtime) / 86400.0: shutil.rmtree(path, ignore_errors=True) _logger.debug('Recycled stale %r to get %s bytes', path, -neg_size) else: @@ -55,14 +53,14 @@ def recycle(): def ensure(requested_size=0, temp_size=0): - stat = os.statvfs(local_root.value) + stat = os.statvfs(client.local_root.value) if stat.f_blocks == 0: # TODO Sonds like a tmpfs or so return total = stat.f_blocks * stat.f_frsize free = stat.f_bfree * stat.f_frsize - to_free = max(cache_limit.value * total / 100, temp_size) - \ + to_free = max(client.cache_limit.value * total / 100, temp_size) - \ (free - requested_size) if to_free <= 0: return @@ -82,7 +80,7 @@ def ensure(requested_size=0, temp_size=0): def get(guid, hints=None): - path = join(local_root.value, 'cache', 'implementation', guid) + path = join(client.local_root.value, 'cache', 'implementation', guid) if exists(path): pipe.trace('Reuse cached %s implementation from %r', guid, path) ts = time.time() @@ -94,7 +92,7 @@ def get(guid, hints=None): pipe.feedback('download') ensure(hints.get('unpack_size') or 0, hints.get('bundle_size') or 0) - blob = IPCClient().download(['implementation', guid, 'data']) + blob = client.IPCConnection().download(['implementation', guid, 'data']) _unpack_stream(blob, path) with toolkit.new_file(join(path, '.unpack_size')) as f: json.dump(hints.get('unpack_size') or 0, f) @@ -114,7 +112,7 @@ def get(guid, hints=None): def _list(): total = 0 result = [] - root = join(local_root.value, 'cache', 'implementation') + root = join(client.local_root.value, 'cache', 'implementation') if not exists(root): os.makedirs(root) diff --git a/sugar_network/client/injector.py b/sugar_network/client/injector.py index b7bfd83..cdcdc5e 100644 --- a/sugar_network/client/injector.py +++ b/sugar_network/client/injector.py @@ -149,7 +149,7 @@ def _clone(context): def _clone_impl(context_guid, params): - conn = client.IPCClient() + conn = client.IPCConnection() context = conn.get(['context', context_guid], reply=['title']) impl = conn.meta(['context', context_guid], cmd='clone', **params) @@ -183,7 +183,7 @@ def _solve(context): pipe.trace('Reuse cached solution') return solution - conn = client.IPCClient() + conn = client.IPCConnection() if solution is not None and conn.get(cmd='status')['route'] == 'offline': pipe.trace('Reuse stale cached solution in offline mode') return solution diff --git a/sugar_network/client/routes.py b/sugar_network/client/routes.py index 709bba2..e9c85e1 100644 --- a/sugar_network/client/routes.py +++ b/sugar_network/client/routes.py @@ -342,7 +342,7 @@ class ClientRoutes(model.Routes, journal.Routes): def handshake(url): _logger.debug('Connecting to %r node', url) - self._node = client.Client(url) + self._node = client.Connection(url) info = self._node.get(cmd='info') impl_info = info['documents'].get('implementation') if impl_info: diff --git a/sugar_network/node/obs.py b/sugar_network/node/obs.py index 753e59e..18400dc 100644 --- a/sugar_network/node/obs.py +++ b/sugar_network/node/obs.py @@ -118,7 +118,7 @@ def _request(*args, **kwargs): global _client if _client is None: - _client = http.Client(obs_url.value) + _client = http.Connection(obs_url.value) response = _client.request(*args, allowed=(400, 404), **kwargs) enforce(response.headers.get('Content-Type') == 'text/xml', diff --git a/sugar_network/node/slave.py b/sugar_network/node/slave.py index 5ea4140..bbf9e00 100644 --- a/sugar_network/node/slave.py +++ b/sugar_network/node/slave.py @@ -57,11 +57,11 @@ class SlaveRoutes(NodeRoutes): 'machine_uuid': '', 'pubkey': toolkit.pubkey(self._key_path), } - conn = http.Client(api_url.value, + conn = http.Connection(api_url.value, creds=(self.guid, self._key_path, lambda: profile)) # TODO In case if slave user is not created on master - # `http.Client` should handle re-POSTing without loosing payload + # `http.Connection` should handle re-POSTing without loosing payload conn.get(cmd='whoami') push = [('diff', None, volume.diff(self.volume, self._push_seq))] diff --git a/sugar_network/node/volume.py b/sugar_network/node/volume.py index a31a28b..dcc0ab7 100644 --- a/sugar_network/node/volume.py +++ b/sugar_network/node/volume.py @@ -28,7 +28,7 @@ _logger = logging.getLogger('node.volume') def diff(volume, in_seq, out_seq=None, exclude_seq=None, layer=None, fetch_blobs=False, ignore_documents=None, **kwargs): - connection = http.Client() + connection = http.Connection() if out_seq is None: out_seq = toolkit.Sequence([]) is_the_only_seq = not out_seq diff --git a/sugar_network/toolkit/http.py b/sugar_network/toolkit/http.py index 3638f47..de01442 100644 --- a/sugar_network/toolkit/http.py +++ b/sugar_network/toolkit/http.py @@ -89,10 +89,10 @@ class ServiceUnavailable(Status): def download(url, dst_path=None): # TODO (?) Reuse HTTP session - return Client().download(url, dst_path) + return Connection().download(url, dst_path) -class Client(object): +class Connection(object): def __init__(self, api_url='', creds=None, trust_env=True, max_retries=0): self.api_url = api_url diff --git a/tests/data/node/context/ac/activity2/aliases b/tests/data/node/context/ac/activity2/aliases new file mode 100644 index 0000000..9331b9d --- /dev/null +++ b/tests/data/node/context/ac/activity2/aliases @@ -0,0 +1 @@ +{"seqno": 2, "value": {}}
\ No newline at end of file diff --git a/tests/data/node/context/ac/activity2/author b/tests/data/node/context/ac/activity2/author new file mode 100644 index 0000000..6be2b3e --- /dev/null +++ b/tests/data/node/context/ac/activity2/author @@ -0,0 +1 @@ +{"seqno": 2, "value": ["alsroot"]}
\ No newline at end of file diff --git a/tests/data/node/context/ac/activity2/clone b/tests/data/node/context/ac/activity2/clone new file mode 100644 index 0000000..86e4350 --- /dev/null +++ b/tests/data/node/context/ac/activity2/clone @@ -0,0 +1 @@ +{"seqno": 0, "value": 0}
\ No newline at end of file diff --git a/tests/data/node/context/ac/activity2/ctime b/tests/data/node/context/ac/activity2/ctime new file mode 100644 index 0000000..1d8fcc5 --- /dev/null +++ b/tests/data/node/context/ac/activity2/ctime @@ -0,0 +1 @@ +{"seqno": 2, "value": 1350031825}
\ No newline at end of file diff --git a/tests/data/node/context/ac/activity2/dependencies b/tests/data/node/context/ac/activity2/dependencies new file mode 100644 index 0000000..8cbfb95 --- /dev/null +++ b/tests/data/node/context/ac/activity2/dependencies @@ -0,0 +1 @@ +{"seqno": 2, "value": []}
\ No newline at end of file diff --git a/tests/data/node/context/ac/activity2/description b/tests/data/node/context/ac/activity2/description new file mode 100644 index 0000000..0198dfa --- /dev/null +++ b/tests/data/node/context/ac/activity2/description @@ -0,0 +1 @@ +{"seqno": 2, "value": {"en-US": "description"}}
\ No newline at end of file diff --git a/tests/data/node/context/ac/activity2/favorite b/tests/data/node/context/ac/activity2/favorite new file mode 100644 index 0000000..051a6dc --- /dev/null +++ b/tests/data/node/context/ac/activity2/favorite @@ -0,0 +1 @@ +{"seqno": 0, "value": false}
\ No newline at end of file diff --git a/tests/data/node/context/ac/activity2/guid b/tests/data/node/context/ac/activity2/guid new file mode 100644 index 0000000..d440ce8 --- /dev/null +++ b/tests/data/node/context/ac/activity2/guid @@ -0,0 +1 @@ +{"seqno": 2, "value": "activity2"}
\ No newline at end of file diff --git a/tests/data/node/context/ac/activity2/homepage b/tests/data/node/context/ac/activity2/homepage new file mode 100644 index 0000000..7c57ae8 --- /dev/null +++ b/tests/data/node/context/ac/activity2/homepage @@ -0,0 +1 @@ +{"seqno": 2, "value": ""}
\ No newline at end of file diff --git a/tests/data/node/context/ac/activity2/implement b/tests/data/node/context/ac/activity2/implement new file mode 100644 index 0000000..8cbfb95 --- /dev/null +++ b/tests/data/node/context/ac/activity2/implement @@ -0,0 +1 @@ +{"seqno": 2, "value": []}
\ No newline at end of file diff --git a/tests/data/node/context/ac/activity2/keep b/tests/data/node/context/ac/activity2/keep new file mode 100644 index 0000000..13c2b1d --- /dev/null +++ b/tests/data/node/context/ac/activity2/keep @@ -0,0 +1,8 @@ +(dp1 +Vseqno +p2 +I2 +sVvalue +p3 +I00 +s.
\ No newline at end of file diff --git a/tests/data/node/context/ac/activity2/keep_impl b/tests/data/node/context/ac/activity2/keep_impl new file mode 100644 index 0000000..2cdb5f0 --- /dev/null +++ b/tests/data/node/context/ac/activity2/keep_impl @@ -0,0 +1,8 @@ +(dp1 +Vseqno +p2 +I2 +sVvalue +p3 +I0 +s.
\ No newline at end of file diff --git a/tests/data/node/context/ac/activity2/layer b/tests/data/node/context/ac/activity2/layer new file mode 100644 index 0000000..5584ac9 --- /dev/null +++ b/tests/data/node/context/ac/activity2/layer @@ -0,0 +1 @@ +{"seqno": 2, "value": ["public"]}
\ No newline at end of file diff --git a/tests/data/node/context/ac/activity2/mime_types b/tests/data/node/context/ac/activity2/mime_types new file mode 100644 index 0000000..8cbfb95 --- /dev/null +++ b/tests/data/node/context/ac/activity2/mime_types @@ -0,0 +1 @@ +{"seqno": 2, "value": []}
\ No newline at end of file diff --git a/tests/data/node/context/ac/activity2/mtime b/tests/data/node/context/ac/activity2/mtime new file mode 100644 index 0000000..1d8fcc5 --- /dev/null +++ b/tests/data/node/context/ac/activity2/mtime @@ -0,0 +1 @@ +{"seqno": 2, "value": 1350031825}
\ No newline at end of file diff --git a/tests/data/node/context/ac/activity2/packages b/tests/data/node/context/ac/activity2/packages new file mode 100644 index 0000000..9331b9d --- /dev/null +++ b/tests/data/node/context/ac/activity2/packages @@ -0,0 +1 @@ +{"seqno": 2, "value": {}}
\ No newline at end of file diff --git a/tests/data/node/context/ac/activity2/position b/tests/data/node/context/ac/activity2/position new file mode 100644 index 0000000..a21b8ca --- /dev/null +++ b/tests/data/node/context/ac/activity2/position @@ -0,0 +1,10 @@ +(dp1 +Vseqno +p2 +I2 +sVvalue +p3 +(lp4 +I-1 +aI-1 +as.
\ No newline at end of file diff --git a/tests/data/node/context/ac/activity2/presolve b/tests/data/node/context/ac/activity2/presolve new file mode 100644 index 0000000..7c94802 --- /dev/null +++ b/tests/data/node/context/ac/activity2/presolve @@ -0,0 +1,8 @@ +(dp1 +Vseqno +p2 +I2 +sVvalue +p3 +(dp4 +s.
\ No newline at end of file diff --git a/tests/data/node/context/ac/activity2/rating b/tests/data/node/context/ac/activity2/rating new file mode 100644 index 0000000..86e4350 --- /dev/null +++ b/tests/data/node/context/ac/activity2/rating @@ -0,0 +1 @@ +{"seqno": 0, "value": 0}
\ No newline at end of file diff --git a/tests/data/node/context/ac/activity2/reviews b/tests/data/node/context/ac/activity2/reviews new file mode 100644 index 0000000..dd3f63c --- /dev/null +++ b/tests/data/node/context/ac/activity2/reviews @@ -0,0 +1 @@ +{"seqno": 0, "value": [0, 0]}
\ No newline at end of file diff --git a/tests/data/node/context/ac/activity2/seqno b/tests/data/node/context/ac/activity2/seqno new file mode 100644 index 0000000..829c37d --- /dev/null +++ b/tests/data/node/context/ac/activity2/seqno @@ -0,0 +1 @@ +{"seqno": 2, "value": 2}
\ No newline at end of file diff --git a/tests/data/node/context/ac/activity2/summary b/tests/data/node/context/ac/activity2/summary new file mode 100644 index 0000000..d15ae6a --- /dev/null +++ b/tests/data/node/context/ac/activity2/summary @@ -0,0 +1 @@ +{"seqno": 2, "value": {"en-US": "summary"}}
\ No newline at end of file diff --git a/tests/data/node/context/ac/activity2/tags b/tests/data/node/context/ac/activity2/tags new file mode 100644 index 0000000..8cbfb95 --- /dev/null +++ b/tests/data/node/context/ac/activity2/tags @@ -0,0 +1 @@ +{"seqno": 2, "value": []}
\ No newline at end of file diff --git a/tests/data/node/context/ac/activity2/title b/tests/data/node/context/ac/activity2/title new file mode 100644 index 0000000..45a74f6 --- /dev/null +++ b/tests/data/node/context/ac/activity2/title @@ -0,0 +1 @@ +{"seqno": 2, "value": {"en-US": "title1"}}
\ No newline at end of file diff --git a/tests/data/node/context/ac/activity2/type b/tests/data/node/context/ac/activity2/type new file mode 100644 index 0000000..bf9b04a --- /dev/null +++ b/tests/data/node/context/ac/activity2/type @@ -0,0 +1 @@ +{"seqno": 2, "value": ["activity"]}
\ No newline at end of file diff --git a/tests/data/node/context/ac/activity2/user b/tests/data/node/context/ac/activity2/user new file mode 100644 index 0000000..fba3c78 --- /dev/null +++ b/tests/data/node/context/ac/activity2/user @@ -0,0 +1,10 @@ +(dp1 +Vseqno +p2 +I2 +sVvalue +p3 +(lp4 +V25c081e29242cf7a19ae893a420ab3de56e9e989 +p5 +as.
\ No newline at end of file diff --git a/tests/data/node/context/ac/activity2/versions b/tests/data/node/context/ac/activity2/versions new file mode 100644 index 0000000..14ad676 --- /dev/null +++ b/tests/data/node/context/ac/activity2/versions @@ -0,0 +1,8 @@ +(dp1 +Vseqno +p2 +I2 +sVvalue +p3 +(lp4 +s.
\ No newline at end of file diff --git a/tests/integration/master_personal.py b/tests/integration/master_personal.py index 20b5376..8acc959 100755 --- a/tests/integration/master_personal.py +++ b/tests/integration/master_personal.py @@ -13,7 +13,7 @@ import rrdtool from __init__ import tests, src_root -from sugar_network.client import Client, sugar_uid +from sugar_network.client import Connection, sugar_uid from sugar_network.toolkit.rrd import Rrd from sugar_network.toolkit import coroutine @@ -49,11 +49,11 @@ class MasterPersonalTest(tests.Test): os.makedirs('client/mnt/disk/sugar-network') coroutine.sleep(2) - ipc = Client('http://127.0.0.1:8102') + ipc = Connection('http://127.0.0.1:8102') if ipc.get(cmd='status')['route'] == 'offline': self.wait_for_events(ipc, event='inline', state='online').wait() - Client('http://127.0.0.1:8100').get(cmd='whoami') - Client('http://127.0.0.1:8101').get(cmd='whoami') + Connection('http://127.0.0.1:8100').get(cmd='whoami') + Connection('http://127.0.0.1:8101').get(cmd='whoami') def tearDown(self): self.waitpid(self.master_pid, signal.SIGINT) @@ -61,8 +61,8 @@ class MasterPersonalTest(tests.Test): tests.Test.tearDown(self) def test_SyncMounts(self): - master = Client('http://127.0.0.1:8100') - client = Client('http://127.0.0.1:8102') + master = Connection('http://127.0.0.1:8100') + client = Connection('http://127.0.0.1:8102') uid = sugar_uid() # Create shared files on master diff --git a/tests/integration/master_slave.py b/tests/integration/master_slave.py index 217997e..101c169 100755 --- a/tests/integration/master_slave.py +++ b/tests/integration/master_slave.py @@ -13,7 +13,7 @@ import rrdtool from __init__ import tests, src_root -from sugar_network.client import Client +from sugar_network.client import Connection from sugar_network.toolkit.rrd import Rrd from sugar_network.toolkit import coroutine @@ -55,8 +55,8 @@ class MasterSlaveTest(tests.Test): def test_OnlineSync(self): ts = int(time.time()) - master = Client('http://127.0.0.1:8100') - slave = Client('http://127.0.0.1:8101') + master = Connection('http://127.0.0.1:8100') + slave = Connection('http://127.0.0.1:8101') # Initial data @@ -174,8 +174,8 @@ class MasterSlaveTest(tests.Test): self.assertEqual('file2', file('slave/files/file2').read()) def test_OfflineSync(self): - master = Client('http://127.0.0.1:8100') - slave = Client('http://127.0.0.1:8101') + master = Connection('http://127.0.0.1:8100') + slave = Connection('http://127.0.0.1:8101') # Create shared files on master self.touch(('master/files/1/1', '1')) diff --git a/tests/integration/node_client.py b/tests/integration/node_client.py index db37a74..db41138 100755 --- a/tests/integration/node_client.py +++ b/tests/integration/node_client.py @@ -11,7 +11,7 @@ from os.path import exists, join, dirname, abspath from __init__ import tests, src_root from sugar_network import toolkit -from sugar_network.client import IPCClient, Client +from sugar_network.client import Connection from sugar_network.toolkit import coroutine @@ -146,7 +146,7 @@ class NodeClientTest(tests.Test): '--api-url=http://127.0.0.1:8100', ]) coroutine.sleep(2) - ipc = Client('http://127.0.0.1:5101') + ipc = Connection('http://127.0.0.1:5101') if ipc.get(cmd='status')['route'] == 'offline': self.wait_for_events(ipc, event='inline', state='online').wait() diff --git a/tests/integration/node_packages.py b/tests/integration/node_packages.py index e6ef11e..1b38c64 100755 --- a/tests/integration/node_packages.py +++ b/tests/integration/node_packages.py @@ -15,7 +15,7 @@ import rrdtool from __init__ import tests, src_root from sugar_network import db, client -from sugar_network.client import Client, IPCClient +from sugar_network.client import Connection, IPCConnection from sugar_network.node.obs import obs_url from sugar_network.toolkit.router import Router, route, fallbackroute from sugar_network.toolkit.rrd import Rrd @@ -74,8 +74,8 @@ class NodePackagesSlaveTest(tests.Test): '--index-flush-threshold=1', '--pull-timeout=1', '--obs-url=http://127.0.0.1:9999', ])) - coroutine.sleep(2) - conn = Client('http://127.0.0.1:8100') + coroutine.sleep(3) + conn = Connection('http://127.0.0.1:8100') conn.post(['/context'], { 'guid': 'package', @@ -104,7 +104,7 @@ class NodePackagesSlaveTest(tests.Test): '--index-flush-threshold=1', '--ipc-port=8200', ]) client.ipc_port.value = 8200 - ipc = IPCClient() + ipc = IPCConnection() coroutine.sleep(2) if ipc.get(cmd='status')['route'] == 'offline': self.wait_for_events(ipc, event='inline', state='online').wait() @@ -124,7 +124,7 @@ class NodePackagesSlaveTest(tests.Test): '--index-flush-threshold=1', '--sync-layers=pilot', ])) coroutine.sleep(2) - conn = Client('http://127.0.0.1:8101') + conn = Connection('http://127.0.0.1:8101') conn.post(cmd='online-sync') @@ -142,7 +142,7 @@ class NodePackagesSlaveTest(tests.Test): '--index-flush-threshold=1', '--ipc-port=8200', ]) client.ipc_port.value = 8200 - ipc = IPCClient() + ipc = IPCConnection() coroutine.sleep(2) if ipc.get(cmd='status')['route'] == 'offline': self.wait_for_events(ipc, event='inline', state='online').wait() @@ -162,9 +162,9 @@ class NodePackagesSlaveTest(tests.Test): '--mounts-root=client/mnt', '--ipc-port=8202', ])) coroutine.sleep(2) - conn = Client('http://127.0.0.1:8102') + conn = Connection('http://127.0.0.1:8102') client.ipc_port.value = 8202 - ipc = IPCClient() + ipc = IPCConnection() if ipc.get(cmd='status')['route'] == 'offline': self.wait_for_events(ipc, event='inline', state='online').wait() diff --git a/tests/units/client/cache.py b/tests/units/client/cache.py index 221572a..3342ce8 100755 --- a/tests/units/client/cache.py +++ b/tests/units/client/cache.py @@ -28,7 +28,7 @@ class CacheTest(tests.Test): cache_limit.value = 0 def test_get(self): - self.override(http.Client, 'download', lambda self_, path: StringIO(self.zips(('topdir/probe', '/'.join(path))))) + self.override(http.Connection, 'download', lambda self_, path: StringIO(self.zips(('topdir/probe', '/'.join(path))))) cache.get('impl', {'unpack_size': 100}) self.assertEqual(100, json.load(file('cache/implementation/impl/.unpack_size'))) self.assertEqual('implementation/impl/data', file('cache/implementation/impl/topdir/probe').read()) diff --git a/tests/units/client/injector.py b/tests/units/client/injector.py index c198f81..1010343 100755 --- a/tests/units/client/injector.py +++ b/tests/units/client/injector.py @@ -20,7 +20,7 @@ from sugar_network.node import obs from sugar_network.model.user import User from sugar_network.model.context import Context from sugar_network.model.implementation import Implementation -from sugar_network.client import IPCClient, packagekit, injector, clones, solver +from sugar_network.client import IPCConnection, packagekit, injector, clones, solver from sugar_network import client @@ -34,7 +34,7 @@ class InjectorTest(tests.Test): def test_clone(self): self.start_online_client([User, Context, Implementation]) - conn = IPCClient() + conn = IPCConnection() context = conn.post(['context'], { 'type': 'activity', @@ -112,7 +112,7 @@ Can't find all required implementations: def test_clone_impl(self): self.start_online_client([User, Context, Implementation]) - conn = IPCClient() + conn = IPCConnection() context = conn.post(['context'], { 'type': 'activity', @@ -159,7 +159,7 @@ Can't find all required implementations: def test_clone_CachedSolutionPointsToClonedPath(self): self.start_online_client([User, Context, Implementation]) - conn = IPCClient() + conn = IPCConnection() context = conn.post(['context'], { 'type': 'activity', @@ -198,7 +198,7 @@ Can't find all required implementations: def test_launch_Online(self): self.start_online_client([User, Context, Implementation]) - conn = IPCClient() + conn = IPCConnection() context = conn.post(['context'], { 'type': 'activity', @@ -325,7 +325,7 @@ Can't find all required implementations: def test_InstallDeps(self): self.start_online_client([User, Context, Implementation]) - conn = IPCClient() + conn = IPCConnection() context = conn.post(['context'], { 'type': 'activity', @@ -415,7 +415,7 @@ Can't find all required implementations: def test_SolutionsCache_Set(self): solution = [{'name': 'name', 'context': 'context', 'id': 'id', 'version': 'version'}] - self.override(client, 'IPCClient', lambda: _FakeConnection(True)) + self.override(client, 'IPCConnection', lambda: _FakeConnection(True)) self.override(solver, 'solve', lambda *args: solution) self.assertEqual(solution, injector._solve('context')) @@ -423,7 +423,7 @@ Can't find all required implementations: def test_SolutionsCache_InvalidateByAPIUrl(self): solution = [{'name': 'name', 'context': 'context', 'id': 'id', 'version': 'version'}] - self.override(client, 'IPCClient', lambda: _FakeConnection(True)) + self.override(client, 'IPCConnection', lambda: _FakeConnection(True)) self.override(solver, 'solve', lambda *args: solution) cached_path = 'cache/solutions/co/context' @@ -438,7 +438,7 @@ Can't find all required implementations: def test_SolutionsCache_InvalidateByMtime(self): solution = [{'name': 'name', 'context': 'context', 'id': 'id', 'version': 'version'}] - self.override(client, 'IPCClient', lambda: _FakeConnection(True)) + self.override(client, 'IPCConnection', lambda: _FakeConnection(True)) self.override(solver, 'solve', lambda *args: solution) cached_path = 'cache/solutions/co/context' @@ -459,7 +459,7 @@ Can't find all required implementations: def test_SolutionsCache_InvalidateByPMSMtime(self): solution = [{'name': 'name', 'context': 'context', 'id': 'id', 'version': 'version'}] - self.override(client, 'IPCClient', lambda: _FakeConnection(True)) + self.override(client, 'IPCConnection', lambda: _FakeConnection(True)) self.override(solver, 'solve', lambda *args: solution) cached_path = 'cache/solutions/co/context' @@ -486,13 +486,13 @@ Can't find all required implementations: self.override(solver, 'solve', lambda *args: solution1) cached_path = 'cache/solutions/co/context' - self.override(client, 'IPCClient', lambda: _FakeConnection(True)) + self.override(client, 'IPCConnection', lambda: _FakeConnection(True)) self.touch((cached_path, json.dumps([client.api_url.value, solution2]))) os.utime(cached_path, (1, 1)) injector.invalidate_solutions(2) self.assertEqual(solution1, injector._solve('context')) - self.override(client, 'IPCClient', lambda: _FakeConnection(False)) + self.override(client, 'IPCConnection', lambda: _FakeConnection(False)) self.touch((cached_path, json.dumps([client.api_url.value, solution2]))) os.utime(cached_path, (1, 1)) injector.invalidate_solutions(2) @@ -501,7 +501,7 @@ Can't find all required implementations: def test_SolutionsCache_InvalidateBySpecMtime(self): solution = [{'name': 'name', 'context': 'context', 'id': 'id', 'version': 'version'}] - self.override(client, 'IPCClient', lambda: _FakeConnection(True)) + self.override(client, 'IPCConnection', lambda: _FakeConnection(True)) self.override(solver, 'solve', lambda *args: solution) cached_path = 'cache/solutions/co/context' @@ -523,7 +523,7 @@ Can't find all required implementations: def test_clone_SetExecPermissionsForActivities(self): self.start_online_client([User, Context, Implementation]) - conn = IPCClient() + conn = IPCConnection() context = conn.post(['context'], { 'type': 'activity', @@ -569,7 +569,7 @@ Can't find all required implementations: def test_clone_InvalidateSolutionByAbsentImpls(self): self.start_online_client([User, Context, Implementation]) - conn = IPCClient() + conn = IPCConnection() context = conn.post(['context'], { 'type': 'activity', @@ -628,7 +628,7 @@ Can't find all required implementations: def test_ProcessCommonDependencies(self): self.start_online_client([User, Context, Implementation]) - conn = IPCClient() + conn = IPCConnection() context = conn.post(['context'], { 'type': 'activity', @@ -715,7 +715,7 @@ Can't find all required implementations: def test_LoadFeed_SetPackages(self): self.start_online_client([User, Context, Implementation]) - conn = IPCClient() + conn = IPCConnection() context = conn.post(['context'], { 'type': 'activity', @@ -788,7 +788,7 @@ Can't find all required implementations: imp.load_module('jarabe', file_, pathname_, description_) self.start_online_client([User, Context, Implementation]) - conn = IPCClient() + conn = IPCConnection() context = conn.post(['context'], { 'type': 'activity', @@ -858,7 +858,7 @@ Can't find all required implementations: imp.load_module('jarabe', file_, pathname_, description_) self.start_online_client([User, Context, Implementation]) - conn = IPCClient() + conn = IPCConnection() context = conn.post(['context'], { 'type': 'activity', @@ -915,7 +915,7 @@ Can't find all required implementations: home_volume = self.start_client() clones.populate(home_volume['context'], ['Activities']) - ipc = IPCClient() + ipc = IPCConnection() self.assertEqual([ {'context': 'context', 'state': 'fork'}, diff --git a/tests/units/client/offline_routes.py b/tests/units/client/offline_routes.py index ced30d1..961bbb5 100755 --- a/tests/units/client/offline_routes.py +++ b/tests/units/client/offline_routes.py @@ -6,7 +6,7 @@ from os.path import exists from __init__ import tests, src_root from sugar_network import client, model -from sugar_network.client import IPCClient, clones +from sugar_network.client import IPCConnection, clones from sugar_network.client.routes import ClientRoutes from sugar_network.db import Volume from sugar_network.toolkit.router import Router @@ -24,7 +24,7 @@ class OfflineRoutes(tests.Test): coroutine.dispatch() def test_NoAuthors(self): - ipc = IPCClient() + ipc = IPCConnection() guid = ipc.post(['context'], { 'type': 'activity', @@ -40,7 +40,7 @@ class OfflineRoutes(tests.Test): ipc.get(['context', guid, 'author'])) def test_HandleDeletes(self): - ipc = IPCClient() + ipc = IPCConnection() guid = ipc.post(['context'], { 'type': 'activity', @@ -57,14 +57,14 @@ class OfflineRoutes(tests.Test): assert not exists(guid_path) def test_whoami(self): - ipc = IPCClient() + ipc = IPCConnection() self.assertEqual( {'guid': tests.UID, 'roles': []}, ipc.get(cmd='whoami')) def test_clone(self): - ipc = IPCClient() + ipc = IPCConnection() context = ipc.post(['context'], { 'type': 'activity', @@ -76,7 +76,7 @@ class OfflineRoutes(tests.Test): self.assertRaises(RuntimeError, ipc.put, ['context', context], 1, cmd='clone') def test_favorite(self): - ipc = IPCClient() + ipc = IPCConnection() context = ipc.post(['context'], { 'type': 'activity', @@ -102,7 +102,7 @@ class OfflineRoutes(tests.Test): ipc.get(['context', context], reply=['favorite'])) def test_subscribe(self): - ipc = IPCClient() + ipc = IPCConnection() events = [] def read_events(): @@ -134,7 +134,7 @@ class OfflineRoutes(tests.Test): events) def test_BLOBs(self): - ipc = IPCClient() + ipc = IPCConnection() guid = ipc.post(['context'], { 'type': 'activity', @@ -185,7 +185,7 @@ class OfflineRoutes(tests.Test): 'requires = dep1; dep2 = 1; dep3 < 2; dep4 >= 3', ])) - ipc = IPCClient() + ipc = IPCConnection() monitor = coroutine.spawn(clones.monitor, self.home_volume['context'], ['Activities']) coroutine.dispatch() @@ -226,7 +226,7 @@ class OfflineRoutes(tests.Test): ipc.get(['context', 'bundle_id'], cmd='feed')) def test_LocalAPIShouldDuplicateNodeButWith503Response(self): - ipc = IPCClient() + ipc = IPCConnection() self.assertRaises(http.ServiceUnavailable, ipc.get, ['context', 'foo'], cmd='feed') self.assertRaises(http.ServiceUnavailable, ipc.get, ['packages', 'foo', 'bar']) diff --git a/tests/units/client/online_routes.py b/tests/units/client/online_routes.py index 10d9b4b..7dc3409 100755 --- a/tests/units/client/online_routes.py +++ b/tests/units/client/online_routes.py @@ -12,7 +12,7 @@ from os.path import exists from __init__ import tests, src_root from sugar_network import client, db, model -from sugar_network.client import IPCClient, journal, clones, injector, routes +from sugar_network.client import IPCConnection, journal, clones, injector, routes from sugar_network.toolkit import coroutine, http from sugar_network.toolkit.spec import Spec from sugar_network.client.routes import ClientRoutes, Request, Response @@ -52,7 +52,7 @@ class OnlineRoutes(tests.Test): def test_whoami(self): self.start_online_client() - ipc = IPCClient() + ipc = IPCConnection() self.assertEqual( {'guid': tests.UID, 'roles': []}, @@ -60,7 +60,7 @@ class OnlineRoutes(tests.Test): def test_clone_Activities(self): self.home_volume = self.start_online_client() - ipc = IPCClient() + ipc = IPCConnection() coroutine.spawn(clones.monitor, self.home_volume['context'], ['Activities']) context = ipc.post(['context'], { @@ -159,7 +159,7 @@ class OnlineRoutes(tests.Test): def test_clone_ActivityImpl(self): self.home_volume = self.start_online_client() - ipc = IPCClient() + ipc = IPCConnection() coroutine.spawn(clones.monitor, self.home_volume['context'], ['Activities']) context = ipc.post(['context'], { @@ -296,7 +296,7 @@ class OnlineRoutes(tests.Test): self.override(journal.Routes, 'journal_update', journal_update) self.override(journal.Routes, 'journal_delete', lambda self, guid: updates.append((guid,))) - ipc = IPCClient() + ipc = IPCConnection() context = ipc.post(['context'], { 'type': 'content', @@ -374,7 +374,7 @@ class OnlineRoutes(tests.Test): self.override(journal.Routes, 'journal_update', journal_update) self.override(journal.Routes, 'journal_delete', lambda self, guid: updates.append((guid,))) - ipc = IPCClient() + ipc = IPCConnection() artifact = ipc.post(['artifact'], { 'context': 'context', @@ -433,7 +433,7 @@ class OnlineRoutes(tests.Test): def test_favorite(self): self.start_online_client() - ipc = IPCClient() + ipc = IPCConnection() context = ipc.post(['context'], { 'type': 'activity', @@ -474,7 +474,7 @@ class OnlineRoutes(tests.Test): def test_subscribe(self): self.start_online_client() - ipc = IPCClient() + ipc = IPCConnection() events = [] def read_events(): @@ -532,7 +532,7 @@ class OnlineRoutes(tests.Test): def test_BLOBs(self): self.start_online_client() - ipc = IPCClient() + ipc = IPCConnection() guid = ipc.post(['context'], { 'type': 'activity', @@ -564,7 +564,7 @@ class OnlineRoutes(tests.Test): def test_Feeds(self): self.start_online_client() - ipc = IPCClient() + ipc = IPCConnection() context = ipc.post(['context'], { 'type': 'activity', @@ -631,7 +631,7 @@ class OnlineRoutes(tests.Test): def test_Feeds_RestrictLayers(self): self.start_online_client([User, Context, Implementation, Artifact]) - ipc = IPCClient() + ipc = IPCConnection() context = ipc.post(['context'], { 'type': 'activity', @@ -773,7 +773,7 @@ class OnlineRoutes(tests.Test): def test_Feeds_PreferLocalFeeds(self): home_volume = self.start_online_client() - ipc = IPCClient() + ipc = IPCConnection() context = ipc.post(['context'], { 'type': 'activity', @@ -840,7 +840,7 @@ class OnlineRoutes(tests.Test): def test_InvalidateSolutions(self): self.start_online_client() - ipc = IPCClient() + ipc = IPCConnection() self.assertNotEqual(None, injector._mtime) mtime = injector._mtime @@ -891,7 +891,7 @@ class OnlineRoutes(tests.Test): def test_ContentDisposition(self): self.start_online_client([User, Context, Implementation, Artifact]) - ipc = IPCClient() + ipc = IPCConnection() artifact = ipc.post(['artifact'], { 'type': 'instance', @@ -916,7 +916,7 @@ class OnlineRoutes(tests.Test): raise http.Redirect(URL) self.start_online_client([User, Document]) - ipc = IPCClient() + ipc = IPCConnection() guid = ipc.post(['document'], {}) response = requests.request('GET', client.api_url.value + '/document/' + guid + '/blob', allow_redirects=False) @@ -925,7 +925,7 @@ class OnlineRoutes(tests.Test): def test_Proxy_Activities(self): home_volume = self.start_online_client() - ipc = IPCClient() + ipc = IPCConnection() context = ipc.post(['context'], { 'type': 'activity', @@ -960,7 +960,7 @@ class OnlineRoutes(tests.Test): def test_Proxy_Content(self): self.start_online_client([User, Context, Implementation, Artifact]) - ipc = IPCClient() + ipc = IPCConnection() guid = ipc.post(['context'], { 'type': 'content', @@ -996,7 +996,7 @@ class OnlineRoutes(tests.Test): def test_Proxy_Artifacts(self): self.start_online_client([User, Context, Implementation, Artifact]) - ipc = IPCClient() + ipc = IPCConnection() guid = ipc.post(['artifact'], { 'type': 'instance', @@ -1032,7 +1032,7 @@ class OnlineRoutes(tests.Test): def test_Proxy_NoNeedlessRemoteRequests(self): home_volume = self.start_online_client() - ipc = IPCClient() + ipc = IPCConnection() guid = ipc.post(['context'], { 'type': 'content', @@ -1058,7 +1058,7 @@ class OnlineRoutes(tests.Test): def test_HomeVolumeEvents(self): self.home_volume = self.start_online_client() - ipc = IPCClient() + ipc = IPCConnection() coroutine.spawn(clones.monitor, self.home_volume['context'], ['Activities']) context1 = ipc.post(['context'], { @@ -1139,7 +1139,7 @@ class OnlineRoutes(tests.Test): self.override(routes, '_LocalRoutes', LocalRoutes) home_volume = self.start_client([User]) - ipc = IPCClient() + ipc = IPCConnection() self.assertEqual('local', ipc.get(cmd='sleep')) self.assertEqual('local', ipc.get(cmd='yield_raw_and_sleep')) @@ -1208,7 +1208,7 @@ class OnlineRoutes(tests.Test): node_pid = self.fork_master([User]) self.start_client([User]) - ipc = IPCClient() + ipc = IPCConnection() self.wait_for_events(ipc, event='inline', state='online').wait() def shutdown(): diff --git a/tests/units/client/routes.py b/tests/units/client/routes.py index 8ae8d44..e69c7ed 100755 --- a/tests/units/client/routes.py +++ b/tests/units/client/routes.py @@ -6,7 +6,7 @@ import json from __init__ import tests from sugar_network import db, client, model -from sugar_network.client import journal, injector, IPCClient +from sugar_network.client import journal, injector, IPCConnection from sugar_network.client.routes import ClientRoutes, CachedClientRoutes from sugar_network.model.user import User from sugar_network.model.report import Report @@ -67,7 +67,7 @@ class RoutesTest(tests.Test): def test_InlineSwitchInFind(self): self.home_volume = self.start_online_client() - ipc = IPCClient() + ipc = IPCConnection() guid1 = ipc.post(['context'], { 'type': 'activity', diff --git a/tests/units/client/server_routes.py b/tests/units/client/server_routes.py index bea8f7f..d1ffda0 100755 --- a/tests/units/client/server_routes.py +++ b/tests/units/client/server_routes.py @@ -8,7 +8,7 @@ from os.path import exists from __init__ import tests, src_root from sugar_network import db, client, model -from sugar_network.client import IPCClient +from sugar_network.client import IPCConnection from sugar_network.client.routes import ClientRoutes from sugar_network.db import Volume from sugar_network.toolkit.router import Router @@ -65,7 +65,7 @@ class ServerCommandsTest(tests.Test): def test_whoami(self): self.start_node() - ipc = IPCClient() + ipc = IPCConnection() self.assertEqual( {'guid': tests.UID, 'roles': []}, @@ -73,7 +73,7 @@ class ServerCommandsTest(tests.Test): def test_subscribe(self): self.start_node() - ipc = IPCClient() + ipc = IPCConnection() events = [] def read_events(): @@ -104,7 +104,7 @@ class ServerCommandsTest(tests.Test): def test_BLOBs(self): self.start_node() - ipc = IPCClient() + ipc = IPCConnection() guid = ipc.post(['context'], { 'type': 'activity', diff --git a/tests/units/client/solver.py b/tests/units/client/solver.py index 42499fe..b4bed8d 100755 --- a/tests/units/client/solver.py +++ b/tests/units/client/solver.py @@ -5,7 +5,7 @@ import os from __init__ import tests -from sugar_network.client import IPCClient, packagekit, solver, clones +from sugar_network.client import IPCConnection, packagekit, solver, clones from sugar_network.toolkit import lsb_release @@ -48,7 +48,7 @@ class SolverTest(tests.Test): home_volume = self.start_online_client() clones.populate(home_volume['context'], ['Activities']) - ipc = IPCClient() + ipc = IPCConnection() ipc.post(['context'], { 'guid': 'dep', diff --git a/tests/units/model/comment.py b/tests/units/model/comment.py index 7cf23b9..4b97723 100755 --- a/tests/units/model/comment.py +++ b/tests/units/model/comment.py @@ -3,7 +3,7 @@ from __init__ import tests -from sugar_network.client import Client +from sugar_network.client import Connection from sugar_network.model.user import User from sugar_network.model.context import Context from sugar_network.model.review import Review @@ -18,7 +18,7 @@ class CommentTest(tests.Test): def test_SetContext(self): volume = self.start_master([User, Context, Review, Feedback, Solution, Comment, Implementation]) - client = Client() + client = Connection() self.assertRaises(http.NotFound, client.post, ['comment'], {'message': '', 'review': 'absent'}) self.assertRaises(http.NotFound, client.post, ['comment'], {'message': '', 'feedback': 'absent'}) diff --git a/tests/units/model/context.py b/tests/units/model/context.py index d8c5628..c63ab14 100755 --- a/tests/units/model/context.py +++ b/tests/units/model/context.py @@ -4,7 +4,7 @@ from __init__ import tests from sugar_network.node import obs -from sugar_network.client import IPCClient, Client +from sugar_network.client import IPCConnection from sugar_network.toolkit import coroutine, enforce @@ -12,7 +12,7 @@ class ContextTest(tests.Test): def test_SetCommonLayerForPackages(self): self.start_online_client() - ipc = IPCClient() + ipc = IPCConnection() guid = ipc.post(['context'], { 'type': 'package', diff --git a/tests/units/model/implementation.py b/tests/units/model/implementation.py index a3afd4b..ea238c7 100755 --- a/tests/units/model/implementation.py +++ b/tests/units/model/implementation.py @@ -10,7 +10,7 @@ from __init__ import tests from sugar_network import db from sugar_network.model import implementation from sugar_network.model.implementation import _fmt_version, Implementation -from sugar_network.client import IPCClient +from sugar_network.client import IPCConnection from sugar_network.toolkit import http, coroutine @@ -66,7 +66,7 @@ class ImplementationTest(tests.Test): def test_WrongAuthor(self): self.start_online_client() - client = IPCClient() + client = IPCConnection() self.node_volume['context'].create({ 'guid': 'context', diff --git a/tests/units/model/review.py b/tests/units/model/review.py index 0e50f5a..5cde1df 100755 --- a/tests/units/model/review.py +++ b/tests/units/model/review.py @@ -3,7 +3,7 @@ from __init__ import tests -from sugar_network.client import Client +from sugar_network.client import Connection from sugar_network.model.user import User from sugar_network.model.context import Context from sugar_network.model.review import Review @@ -15,7 +15,7 @@ class ReviewTest(tests.Test): def test_SetContext(self): volume = self.start_master([User, Context, Review, Artifact, Implementation]) - client = Client() + client = Connection() context = client.post(['context'], { 'type': 'package', diff --git a/tests/units/model/solution.py b/tests/units/model/solution.py index dafb5a7..908653d 100755 --- a/tests/units/model/solution.py +++ b/tests/units/model/solution.py @@ -3,7 +3,7 @@ from __init__ import tests -from sugar_network.client import Client +from sugar_network.client import Connection from sugar_network.model.user import User from sugar_network.model.context import Context from sugar_network.model.feedback import Feedback @@ -15,7 +15,7 @@ class SolutionTest(tests.Test): def test_SetContext(self): volume = self.start_master([User, Context, Feedback, Solution, Implementation]) - client = Client() + client = Connection() context = client.post(['context'], { 'type': 'package', diff --git a/tests/units/node/master.py b/tests/units/node/master.py index f5dbc1b..bae7d39 100755 --- a/tests/units/node/master.py +++ b/tests/units/node/master.py @@ -6,7 +6,7 @@ import os from __init__ import tests from sugar_network.node import obs -from sugar_network.client import IPCClient +from sugar_network.client import IPCConnection from sugar_network.toolkit import coroutine, enforce @@ -21,7 +21,7 @@ class MasterTest(tests.Test): self.override(obs, 'resolve', lambda repo, arch, names: ['fake']) self.start_online_client() - ipc = IPCClient() + ipc = IPCConnection() guid = ipc.post(['context'], { 'type': 'activity', @@ -57,7 +57,7 @@ class MasterTest(tests.Test): self.override(obs, 'resolve', lambda repo, arch, names: enforce(False, 'resolve failed')) self.start_online_client() - ipc = IPCClient() + ipc = IPCConnection() guid = ipc.post(['context'], { 'type': 'activity', @@ -96,7 +96,7 @@ class MasterTest(tests.Test): self.override(obs, 'resolve', resolve) self.start_online_client() - ipc = IPCClient() + ipc = IPCConnection() guid = ipc.post(['context'], { 'type': 'activity', @@ -148,7 +148,7 @@ class MasterTest(tests.Test): self.override(obs, 'resolve', lambda repo, arch, names: ['fake']) self.start_online_client() - ipc = IPCClient() + ipc = IPCConnection() events = [] def read_events(): @@ -184,7 +184,7 @@ class MasterTest(tests.Test): def test_InvalidateSolutionsOnDependenciesChanges(self): self.start_online_client() - ipc = IPCClient() + ipc = IPCConnection() events = [] def read_events(): diff --git a/tests/units/node/node.py b/tests/units/node/node.py index 65495f1..26b2741 100755 --- a/tests/units/node/node.py +++ b/tests/units/node/node.py @@ -11,7 +11,7 @@ from os.path import exists from __init__ import tests from sugar_network import db, node, model -from sugar_network.client import Client +from sugar_network.client import Connection from sugar_network.toolkit import http, coroutine from sugar_network.toolkit.rrd import Rrd from sugar_network.node import stats_user, stats_node, obs @@ -481,7 +481,7 @@ class NodeTest(tests.Test): node.files_root.value = '.' self.touch(('packages/repo/arch/package', 'file')) volume = self.start_master() - client = Client() + client = Connection() self.assertEqual(['repo'], client.get(['packages'])) self.assertEqual(['arch'], client.get(['packages', 'repo'])) @@ -497,7 +497,7 @@ class NodeTest(tests.Test): ('packages/repo/2.2', '', 2), ) volume = self.start_master() - ipc = Client() + ipc = Connection() self.assertEqual( sorted(['1', '2']), @@ -529,7 +529,7 @@ class NodeTest(tests.Test): def test_Clone(self): volume = self.start_master() - client = Client() + client = Connection() context = client.post(['context'], { 'type': 'activity', @@ -624,7 +624,7 @@ class NodeTest(tests.Test): def test_release(self): volume = self.start_master() - conn = Client() + conn = Connection() conn.post(['context'], { 'guid': 'bundle_id', diff --git a/tests/units/node/obs.py b/tests/units/node/obs.py index aaf4030..fef1b1d 100755 --- a/tests/units/node/obs.py +++ b/tests/units/node/obs.py @@ -18,7 +18,7 @@ class ObsTest(tests.Test): obs._repos = {} def test_get_repos(self): - self.override(http, 'Client', Client(self, [ + self.override(http, 'Connection', Client(self, [ (('GET', ['build', 'base']), {'allowed': (400, 404)}, [ '<directory>', ' <entry name="Debian-6.0" />', @@ -45,7 +45,7 @@ class ObsTest(tests.Test): obs.get_repos()) def test_resolve(self): - self.override(http, 'Client', Client(self, [ + self.override(http, 'Connection', Client(self, [ (('GET', ['resolve']), {'allowed': (400, 404), 'params': { 'project': 'base', @@ -75,7 +75,7 @@ class ObsTest(tests.Test): obs.resolve('repo', 'arch', ['pkg1', 'pkg2']) def test_presolve(self): - self.override(http, 'Client', lambda *args: Client(self, [ + self.override(http, 'Connection', lambda *args: Client(self, [ (('GET', ['build', 'presolve']), {'allowed': (400, 404)}, [ '<directory>', ' <entry name="OLPC-11.3.1" />', diff --git a/tests/units/node/sync_online.py b/tests/units/node/sync_online.py index c8bf5f8..4b46306 100755 --- a/tests/units/node/sync_online.py +++ b/tests/units/node/sync_online.py @@ -8,7 +8,7 @@ from os.path import exists from __init__ import tests from sugar_network import db, toolkit -from sugar_network.client import Client, api_url +from sugar_network.client import Connection, api_url from sugar_network.node import sync, stats_user, files_root from sugar_network.node.master import MasterRoutes from sugar_network.node.slave import SlaveRoutes @@ -59,7 +59,7 @@ class SyncOnlineTest(tests.Test): tests.Test.tearDown(self) def test_Push(self): - client = Client('http://127.0.0.1:9001') + client = Connection('http://127.0.0.1:9001') # Sync users client.post(cmd='online-sync') @@ -129,14 +129,14 @@ class SyncOnlineTest(tests.Test): def test_PushStats(self): stats_user.stats_user.value = True - client = Client('http://127.0.0.1:9001') + client = Connection('http://127.0.0.1:9001') client.post(cmd='online-sync') self.assertEqual(['ok'], self.stats_commit) self.assertEqual([{'stats': 'probe'}], self.stats_merge) def test_Pull(self): - client = Client('http://127.0.0.1:9000') - slave_client = Client('http://127.0.0.1:9001') + client = Connection('http://127.0.0.1:9000') + slave_client = Connection('http://127.0.0.1:9001') # Sync users slave_client.post(cmd='online-sync') @@ -210,7 +210,7 @@ class SyncOnlineTest(tests.Test): self.touch(('master/files/3/3/3', 'ccc', 3)) os.utime('master/files', (1, 1)) - client = Client('http://127.0.0.1:9001') + client = Connection('http://127.0.0.1:9001') client.post(cmd='online-sync') files, stamp = json.load(file('master/files.index')) @@ -228,8 +228,8 @@ class SyncOnlineTest(tests.Test): self.assertEqual('ccc', file('slave/files/3/3/3').read()) def test_PullFromPreviouslyMergedRecord(self): - master = Client('http://127.0.0.1:9000') - slave = Client('http://127.0.0.1:9001') + master = Connection('http://127.0.0.1:9000') + slave = Connection('http://127.0.0.1:9001') # Sync users slave.post(cmd='online-sync') diff --git a/tests/units/toolkit/http.py b/tests/units/toolkit/http.py index 4117cbc..7a63176 100755 --- a/tests/units/toolkit/http.py +++ b/tests/units/toolkit/http.py @@ -28,7 +28,7 @@ class HTTPTest(tests.Test): self.server = coroutine.WSGIServer(('127.0.0.1', local.ipc_port.value), Router(CommandsProcessor())) coroutine.spawn(self.server.serve_forever) coroutine.dispatch() - client = http.Client('http://127.0.0.1:%s' % local.ipc_port.value) + client = http.Connection('http://127.0.0.1:%s' % local.ipc_port.value) events = [] CommandsProcessor.events = ['', 'fake', 'data: fail', 'data: null', 'data: -1', 'data: {"foo": "bar"}'] @@ -69,7 +69,7 @@ class HTTPTest(tests.Test): self.server = coroutine.WSGIServer(('127.0.0.1', local.ipc_port.value), Router(Commands())) coroutine.spawn(self.server.serve_forever) coroutine.dispatch() - client = http.Client('http://127.0.0.1:%s' % local.ipc_port.value) + client = http.Connection('http://127.0.0.1:%s' % local.ipc_port.value) request = Request({ 'REQUEST_METHOD': 'GET', |