Skip to content
Browse files

add mimetype and check for position

  • Loading branch information...
1 parent d9a2bf8 commit 095f5afa69382559c354d0942fc1f84a484e771b @zalun committed Jul 5, 2012
Showing with 10 additions and 3 deletions.
  1. +2 −3 python/lib/marketplace.py
  2. +8 −0 python/tests/testMarketplace.py
View
5 python/lib/marketplace.py
@@ -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``.
@@ -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}}
View
8 python/tests/testMarketplace.py
@@ -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
@@ -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.
Something went wrong with that request. Please try again.