Merge lp:~rvb/maas/empty-files-1.3 into lp:maas/1.3

Proposed by Raphaël Badin
Status: Merged
Approved by: Raphaël Badin
Approved revision: no longer in the source branch.
Merged at revision: 1467
Proposed branch: lp:~rvb/maas/empty-files-1.3
Merge into: lp:maas/1.3
Diff against target: 33 lines (+12/-1)
2 files modified
src/maasserver/models/filestorage.py (+1/-1)
src/maasserver/tests/test_api.py (+11/-0)
To merge this branch: bzr merge lp:~rvb/maas/empty-files-1.3
Reviewer Review Type Date Requested Status
Raphaël Badin (community) Approve
Review via email: mp+177117@code.launchpad.net

Commit message

Backport revision 1540: accept empty files.

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
1=== modified file 'src/maasserver/models/filestorage.py'
2--- src/maasserver/models/filestorage.py 2013-02-22 12:16:44 +0000
3+++ src/maasserver/models/filestorage.py 2013-07-26 09:39:19 +0000
4@@ -83,7 +83,7 @@
5 unique_together = ('filename', 'owner')
6
7 filename = CharField(max_length=255, unique=False, editable=False)
8- content = BinaryField(null=False)
9+ content = BinaryField(null=False, blank=True)
10 # owner can be None: this is to support upgrading existing
11 # installations where the files were not linked to users yet.
12 owner = ForeignKey(
13
14=== modified file 'src/maasserver/tests/test_api.py'
15--- src/maasserver/tests/test_api.py 2013-03-12 15:25:43 +0000
16+++ src/maasserver/tests/test_api.py 2013-07-26 09:39:19 +0000
17@@ -2719,6 +2719,17 @@
18 self.assertIn('text/plain', response['Content-Type'])
19 self.assertEqual("Filename not supplied", response.content)
20
21+ def test_add_empty_file(self):
22+ filename = "filename"
23+ response = self.make_API_POST_request(
24+ "add", filename=filename,
25+ fileObj=factory.make_file_upload(content=b''))
26+ self.assertEqual(httplib.CREATED, response.status_code)
27+ self.assertItemsEqual(
28+ [filename],
29+ FileStorage.objects.filter(
30+ filename=filename).values_list('filename', flat=True))
31+
32 def test_add_file_fails_with_no_file_attached(self):
33 response = self.make_API_POST_request("add", "foo")
34

Subscribers

People subscribed via source and target branches