Skip to content

Commit

Permalink
add mimetype and check for position
Browse files Browse the repository at this point in the history
  • Loading branch information
zalun committed Jul 5, 2012
1 parent d9a2bf8 commit 095f5af
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
5 changes: 2 additions & 3 deletions python/lib/marketplace.py
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,8 @@ def delete(self, app_id):
# XXX: This isn't yet implemented on API
return self.remove(self.url('app') % app_id)

def create_screenshot(self, app_id, filename, position=1):
def create_screenshot(self, app_id, filename, mimetype='image/jpg',
position=1):
"""Add a screenshot to the web app identified by by ``app_id``.
Screenshots are ordered by ``position``.
Expand All @@ -240,8 +241,6 @@ def create_screenshot(self, app_id, filename, position=1):
s_content = s_file.read()
s_encoded = b64encode(s_content)
url = self.url('create_screenshot') % app_id
# TODO find the mimetype of the file
mimetype = 'image/jpg'
data = {'position': position,
'file': {'type': mimetype,
'data': s_encoded}}
Expand Down
8 changes: 8 additions & 0 deletions python/tests/testMarketplace.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ def test_update(self):
'categories': ['Business', 'Game'],
'support_email': 'john@doe.com',
'device_types': ['phone',],
'privacy_policy': 'any',
'payment_type': 'free'})
eq_(response.status_code, 202)
assert not response.content
Expand Down Expand Up @@ -200,3 +201,10 @@ def test_add_screenshot(self):
data = json.loads(requests.post.call_args[1]['data'])
eq_(data['position'], 1)
eq_(data['file']['data'], b64_file)
eq_(data['file']['type'], 'image/jpg')
# create a screenshot with a png image and not default position
self.marketplace.create_screenshot(123,
path('mozilla.jpg'), mimetype='image/png', position=2)
data = json.loads(requests.post.call_args[1]['data'])
eq_(data['position'], 2)
eq_(data['file']['type'], 'image/png')

0 comments on commit 095f5af

Please sign in to comment.