Merge lp:~rvb/maas/bug-1154142-1.2 into lp:maas/1.2

Proposed by Raphaël Badin
Status: Merged
Approved by: Raphaël Badin
Approved revision: no longer in the source branch.
Merged at revision: 1373
Proposed branch: lp:~rvb/maas/bug-1154142-1.2
Merge into: lp:maas/1.2
Diff against target: 43 lines (+15/-0)
2 files modified
src/maasserver/api.py (+3/-0)
src/maasserver/tests/test_api.py (+12/-0)
To merge this branch: bzr merge lp:~rvb/maas/bug-1154142-1.2
Reviewer Review Type Date Requested Status
Raphaël Badin (community) Approve
Review via email: mp+152959@code.launchpad.net

Commit message

Backport revision 1455.

To post a comment you must log in.
Revision history for this message
Raphaël Badin (rvb) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'src/maasserver/api.py'
--- src/maasserver/api.py 2013-03-08 13:58:41 +0000
+++ src/maasserver/api.py 2013-03-12 16:31:21 +0000
@@ -102,6 +102,7 @@
102 PermissionDenied,102 PermissionDenied,
103 ValidationError,103 ValidationError,
104 )104 )
105from django.core.urlresolvers import reverse
105from django.db.utils import DatabaseError106from django.db.utils import DatabaseError
106from django.forms.models import model_to_dict107from django.forms.models import model_to_dict
107from django.http import (108from django.http import (
@@ -1087,6 +1088,8 @@
1087 # Encode the content as base64.1088 # Encode the content as base64.
1088 dict_representation['content'] = b64encode(1089 dict_representation['content'] = b64encode(
1089 getattr(stored_file, 'content'))1090 getattr(stored_file, 'content'))
1091 dict_representation['resource_uri'] = reverse(
1092 'file_handler', args=[stored_file.filename])
1090 # Emit the json for this object manually because, no matter what the1093 # Emit the json for this object manually because, no matter what the
1091 # piston documentation says, once a type is associated with a list1094 # piston documentation says, once a type is associated with a list
1092 # of fields by piston's typemapper mechanism, there is no way to1095 # of fields by piston's typemapper mechanism, there is no way to
10931096
=== modified file 'src/maasserver/tests/test_api.py'
--- src/maasserver/tests/test_api.py 2013-03-08 13:58:41 +0000
+++ src/maasserver/tests/test_api.py 2013-03-12 16:31:21 +0000
@@ -2948,6 +2948,18 @@
2948 b64decode(parsed_result['content'])2948 b64decode(parsed_result['content'])
2949 ))2949 ))
29502950
2951 def test_get_file_returns_file_object_with_resource_uri(self):
2952 filename = factory.make_name("file")
2953 content = sample_binary_data
2954 factory.make_file_storage(
2955 filename=filename, content=content, owner=self.logged_in_user)
2956 response = self.client.get(
2957 reverse('file_handler', args=[filename]))
2958 parsed_result = json.loads(response.content)
2959 self.assertEqual(
2960 reverse('file_handler', args=[filename]),
2961 parsed_result['resource_uri'])
2962
2951 def test_get_file_returns_owned_file(self):2963 def test_get_file_returns_owned_file(self):
2952 # If both an owned file and a non-owned file are present (with the2964 # If both an owned file and a non-owned file are present (with the
2953 # same name), the owned file is returned.2965 # same name), the owned file is returned.

Subscribers

People subscribed via source and target branches

to status/vote changes: