diff options
author | Aleksey Lim <alsroot@sugarlabs.org> | 2012-06-05 18:11:00 (GMT) |
---|---|---|
committer | Aleksey Lim <alsroot@sugarlabs.org> | 2012-06-05 18:11:00 (GMT) |
commit | aeb351d0ab406d0f1fd9823358ac1802dee7c2b4 (patch) | |
tree | 58e9e52f68772e7865f536a8b957fa9320a3f720 | |
parent | d4a328c6a56ddf429b8ce3378d5f62ff161cd0ed (diff) |
Fix fetching properties while maing remote context local
-rw-r--r-- | local_document/mounts.py | 14 | ||||
-rw-r--r-- | tests/__init__.py | 2 | ||||
-rwxr-xr-x | tests/units/activities.py | 36 | ||||
-rwxr-xr-x | tests/units/mounts.py | 14 |
4 files changed, 33 insertions, 33 deletions
diff --git a/local_document/mounts.py b/local_document/mounts.py index 3a9ae01..8e9599a 100644 --- a/local_document/mounts.py +++ b/local_document/mounts.py @@ -312,14 +312,13 @@ class _RemoteMount(ad.CommandsProcessor, _Mount): if not request.content: result = guid - headers = { - 'Content-Type': 'application/json', - 'Accept-Language': ','.join(request.accept_language), - } - if result is None: result = http.request(method, path, - data=request.content, params=request, headers=headers) + data=request.content, params=request, + headers={ + 'Content-Type': 'application/json', + 'Accept-Language': ','.join(request.accept_language), + }) if document == 'context' and patch: directory = self._home_volume['context'] @@ -344,8 +343,7 @@ class _RemoteMount(ad.CommandsProcessor, _Mount): if directory.exists(guid): directory.update(guid, patch) elif [True for prop, value in patch.items() if value]: - props = http.request('GET', ['context', guid], - headers=headers) + props = http.request('GET', ['context', guid]) props.update(patch) props['user'] = [sugar.uid()] directory.create_with_guid(guid, props) diff --git a/tests/__init__.py b/tests/__init__.py index e77165d..505f80d 100644 --- a/tests/__init__.py +++ b/tests/__init__.py @@ -37,6 +37,8 @@ class Test(unittest.TestCase): def setUp(self): self._overriden = [] + os.environ['LANG'] = 'en_US' + global tmpdir tmpdir = join(tmproot, '.'.join(self.id().split('.')[1:])) shutil.rmtree(tmpdir, ignore_errors=True) diff --git a/tests/units/activities.py b/tests/units/activities.py index 50deefc..821bdb0 100755 --- a/tests/units/activities.py +++ b/tests/units/activities.py @@ -38,9 +38,9 @@ class ActivitiesTest(tests.Test): self.mounts.home_volume['context'].create_with_guid( 'org.sugarlabs.HelloWorld', { 'type': 'activity', - 'title': 'title', - 'summary': 'summary', - 'description': 'description', + 'title': {'en': 'title'}, + 'summary': {'en': 'summary'}, + 'description': {'en': 'description'}, 'user': [sugar.uid()], }) @@ -65,7 +65,7 @@ class ActivitiesTest(tests.Test): abspath('Activities/activity'), os.readlink('activities/context/org.sugarlabs.HelloWorld/' + hashed_path)) self.assertEqual( - {'guid': 'org.sugarlabs.HelloWorld', 'title': 'title', 'keep': False, 'keep_impl': 2}, + {'guid': 'org.sugarlabs.HelloWorld', 'title': {'en': 'title'}, 'keep': False, 'keep_impl': 2}, self.mounts.home_volume['context'].get('org.sugarlabs.HelloWorld').properties(['guid', 'title', 'keep', 'keep_impl'])) def test_Checkin_Copy(self): @@ -75,9 +75,9 @@ class ActivitiesTest(tests.Test): self.mounts.home_volume['context'].create_with_guid( 'org.sugarlabs.HelloWorld', { 'type': 'activity', - 'title': 'title', - 'summary': 'summary', - 'description': 'description', + 'title': {'en': 'title'}, + 'summary': {'en': 'summary'}, + 'description': {'en': 'description'}, 'user': [sugar.uid()], }) @@ -99,7 +99,7 @@ class ActivitiesTest(tests.Test): abspath('Activities/activity'), os.readlink('activities/context/org.sugarlabs.HelloWorld/' + hashed_path)) self.assertEqual( - {'guid': 'org.sugarlabs.HelloWorld', 'title': 'title', 'keep': False, 'keep_impl': 2}, + {'guid': 'org.sugarlabs.HelloWorld', 'title': {'en': 'title'}, 'keep': False, 'keep_impl': 2}, self.mounts.home_volume['context'].get('org.sugarlabs.HelloWorld').properties(['guid', 'title', 'keep', 'keep_impl'])) def test_Checkin_Hardlink(self): @@ -109,9 +109,9 @@ class ActivitiesTest(tests.Test): self.mounts.home_volume['context'].create_with_guid( 'org.sugarlabs.HelloWorld', { 'type': 'activity', - 'title': 'title', - 'summary': 'summary', - 'description': 'description', + 'title': {'en': 'title'}, + 'summary': {'en': 'summary'}, + 'description': {'en': 'description'}, 'user': [sugar.uid()], }) @@ -135,7 +135,7 @@ class ActivitiesTest(tests.Test): abspath('Activities/activity'), os.readlink('activities/context/org.sugarlabs.HelloWorld/' + hashed_path)) self.assertEqual( - {'guid': 'org.sugarlabs.HelloWorld', 'title': 'title', 'keep': False, 'keep_impl': 2}, + {'guid': 'org.sugarlabs.HelloWorld', 'title': {'en': 'title'}, 'keep': False, 'keep_impl': 2}, self.mounts.home_volume['context'].get('org.sugarlabs.HelloWorld').properties(['guid', 'title', 'keep', 'keep_impl'])) def test_OfflineCheckin(self): @@ -160,7 +160,7 @@ class ActivitiesTest(tests.Test): os.readlink('activities/context/org.sugarlabs.HelloWorld/' + hashed_path)) self.assertEqual( - {'guid': 'org.sugarlabs.HelloWorld', 'title': 'HelloWorld', 'keep': False, 'keep_impl': 2}, + {'guid': 'org.sugarlabs.HelloWorld', 'title': {'en': 'HelloWorld'}, 'keep': False, 'keep_impl': 2}, self.mounts.home_volume['context'].get('org.sugarlabs.HelloWorld').properties(['guid', 'title', 'keep', 'keep_impl'])) def test_Checkout(self): @@ -169,9 +169,9 @@ class ActivitiesTest(tests.Test): self.mounts.home_volume['context'].create_with_guid( 'org.sugarlabs.HelloWorld', { 'type': 'activity', - 'title': 'title', - 'summary': 'summary', - 'description': 'description', + 'title': {'en': 'title'}, + 'summary': {'en': 'summary'}, + 'description': {'en': 'description'}, 'user': [sugar.uid()], }) @@ -190,7 +190,7 @@ class ActivitiesTest(tests.Test): assert exists('activities/checkins/' + hashed_path) assert exists('activities/context/org.sugarlabs.HelloWorld/' + hashed_path) self.assertEqual( - {'guid': 'org.sugarlabs.HelloWorld', 'title': 'title', 'keep': False, 'keep_impl': 2}, + {'guid': 'org.sugarlabs.HelloWorld', 'title': {'en': 'title'}, 'keep': False, 'keep_impl': 2}, self.mounts.home_volume['context'].get('org.sugarlabs.HelloWorld').properties(['guid', 'title', 'keep', 'keep_impl'])) shutil.rmtree('Activities/activity') @@ -199,7 +199,7 @@ class ActivitiesTest(tests.Test): assert not exists('activities/checkins/' + hashed_path) assert not exists('activities/context/org.sugarlabs.HelloWorld/' + hashed_path) self.assertEqual( - {'guid': 'org.sugarlabs.HelloWorld', 'title': 'title', 'keep': False, 'keep_impl': 0}, + {'guid': 'org.sugarlabs.HelloWorld', 'title': {'en': 'title'}, 'keep': False, 'keep_impl': 0}, self.mounts.home_volume['context'].get('org.sugarlabs.HelloWorld').properties(['guid', 'title', 'keep', 'keep_impl'])) diff --git a/tests/units/mounts.py b/tests/units/mounts.py index 80bf849..43998ac 100755 --- a/tests/units/mounts.py +++ b/tests/units/mounts.py @@ -172,9 +172,9 @@ class MountsTest(tests.Test): self.mounts.home_volume['context'].create_with_guid(guid, { 'type': 'activity', - 'title': 'local', - 'summary': 'summary', - 'description': 'description', + 'title': {'en': 'local'}, + 'summary': {'en': 'summary'}, + 'description': {'en': 'description'}, 'keep': True, 'keep_impl': 2, 'user': [sugar.uid()], @@ -362,9 +362,9 @@ class MountsTest(tests.Test): guid = remote.Context( type='activity', - title='title', - summary='summary', - description='description', + title={'en': 'title'}, + summary={'en': 'summary'}, + description={'en': 'description'}, keep=True).post() subscription = sockets.SocketFile(coroutine.socket(socket.AF_UNIX)) @@ -630,7 +630,7 @@ class MountsTest(tests.Test): 'title', remote.Context(guid, reply=['title'])['title']) self.assertEqual( - 'title', + {'en-US': 'title'}, http.request('GET', ['context', guid])['title']) self.touch(('Activities/activity/activity/activity.info', [ |