Skip to content

Commit

Permalink
Fixes Bug: lp825024
Browse files Browse the repository at this point in the history
Added 'size' to the unsupported_fields array in image_add().

Added a test case to functional/test_misc.py that tests for this bug.

Change-Id: Ib223b31656cd75de0b95a0186ea907f93b6c943e
  • Loading branch information
Justin Shepherd committed Aug 30, 2011
1 parent ecbcc09 commit d29d2fb
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 1 deletion.
2 changes: 1 addition & 1 deletion bin/glance
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ EXAMPLES
'container_format': fields.pop('container_format', 'ovf')}

# Strip any args that are not supported
unsupported_fields = ['status']
unsupported_fields = ['status', 'size']
for field in unsupported_fields:
if field in fields.keys():
print 'Found non-settable field %s. Removing.' % field
Expand Down
36 changes: 36 additions & 0 deletions glance/tests/functional/test_misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import httplib2
import json
import os
import tempfile

from glance.tests import functional
from glance.tests.utils import execute
Expand Down Expand Up @@ -117,3 +118,38 @@ def test_exception_not_eaten_from_registry_to_api(self):
"in output: %s" % out)

self.stop_servers()

def test_api_treats_size_as_a_normal_property(self):
"""
A test for LP bug #825024 -- glance client currently
treats size as a normal property.
"""

self.cleanup()
self.start_servers()

# 1. POST /images with public image named Image1
# attribute and no custom properties. Verify a 200 OK is returned
with tempfile.NamedTemporaryFile() as image_file:
image_file.write("XXX")
image_file.flush()
image_file_name = image_file.name
cmd = "bin/glance --port=%d add is_public=True name=MyImage "\
"size=12345 < %s" % (self.api_port, image_file_name)

exitcode, out, err = execute(cmd)

self.assertEqual(0, exitcode)
self.assertTrue('Found non-settable field size. Removing.' in out)
self.assertTrue('Added new image with ID: 1' in out)

# 2. Verify image added as public image
cmd = "bin/glance --port=%d show %d" % (self.api_port, 1)

exitcode, out, err = execute(cmd)

self.assertEqual(0, exitcode)
lines = out.split("\n")[2:-1]
self.assertFalse("12345" in out)

self.stop_servers()

0 comments on commit d29d2fb

Please sign in to comment.