def test_data_uri(self): app_path = os.path.join(self.apps_path, 'dataicon.webapp') webapp = self.webapp_from_path(app_path) tasks.fetch_icon(webapp) eq_(webapp.icon_type, self.content_type) self.check_icons(webapp)
def test_cdn_icon(self, save, fetch, json): response = mock.Mock() response.read.return_value = '' webapp = app_factory() url = 'http://foo.com/bar' json.return_value = {'icons': {'128': url}} tasks.fetch_icon(webapp.pk, webapp.latest_version.all_files[0].pk) assert url in fetch.call_args[0][0]
def test_cdn_icon(self, save, fetch): response = mock.Mock() response.read.return_value = '' webapp = mock.Mock() url = 'http://foo.com/bar' webapp.get_manifest_json.return_value = {'icons': {'128': url}} tasks.fetch_icon(webapp) assert url in fetch.call_args[0][0]
def test_data_uri(self): app_path = os.path.join(self.apps_path, 'dataicon.webapp') webapp = self.webapp_from_path(app_path) file_obj = webapp.latest_version.all_files[0] tasks.fetch_icon(webapp, file_obj) eq_(webapp.icon_type, self.content_type) self.check_icons(webapp, file_obj)
def test_cdn_icon(self, save, fetch): response = mock.Mock() response.read.return_value = "" webapp = mock.Mock() webapp.is_packaged = False url = "http://foo.com/bar" webapp.get_manifest_json.return_value = {"icons": {"128": url}} tasks.fetch_icon(webapp) assert url in fetch.call_args[0][0]
def test_cdn_icon(self, save, fetch): response = mock.Mock() response.read.return_value = '' webapp = mock.Mock() webapp.is_packaged = False url = 'http://foo.com/bar' webapp.get_manifest_json.return_value = {'icons': {'128': url}} # Pass anything here for the `file_obj` argument to avoid it trying to # get the `current_version`. tasks.fetch_icon(webapp, mock.Mock()) assert url in fetch.call_args[0][0]
def test_packaged_icon(self, save, zip): response = mock.Mock() response.read.return_value = '' zf = mock.Mock() zip.return_value = zf webapp = mock.Mock() webapp.is_packaged = True url = '/path/to/icon.png' webapp.get_manifest_json.return_value = {'icons': {'128': url}} tasks.fetch_icon(webapp) assert url[1:] in zf.extract_path.call_args[0][0]
def test_packaged_icon(self, save, zip, json): response = mock.Mock() response.read.return_value = '' zf = mock.Mock() zip.return_value = zf webapp = app_factory(is_packaged=True) file_obj = webapp.latest_version.all_files[0] url = '/path/to/icon.png' json.return_value = {'icons': {'128': url}} tasks.fetch_icon(webapp.pk, file_obj.pk) assert url[1:] in zf.extract_path.call_args[0][0]
def _fix_missing_icons(id): try: webapp = Webapp.objects.get(pk=id) except Webapp.DoesNotExist: _log(id, u'Webapp does not exist') return # Check for missing icons. If we find one important size missing, call # fetch_icon for this app. dirname = webapp.get_icon_dir() destination = os.path.join(dirname, '%s' % webapp.id) for size in (64, 128): filename = '%s-%s.png' % (destination, size) if not storage.exists(filename): _log(id, u'Webapp is missing icon size %d' % (size, )) return fetch_icon(webapp)
def test_no_version(self): app = Webapp() eq_(tasks.fetch_icon(app), None)
def test_no_version(self): app = app_factory() eq_(tasks.fetch_icon(app.pk), None)
def test_no_icons(self): path = os.path.join(self.apps_path, 'noicon.webapp') iconless_app = self.webapp_from_path(path) tasks.fetch_icon(iconless_app) assert not self.requests_mock.called
def test_bad_icons(self): path = os.path.join(self.apps_path, 'badicon.webapp') iconless_app = self.webapp_from_path(path) tasks.fetch_icon(iconless_app) assert not self.urlopen_mock.called
def test_bad_icons(self): path = os.path.join(self.apps_path, 'badicon.webapp') iconless_app = self.webapp_from_path(path) tasks.fetch_icon(iconless_app.pk, iconless_app.latest_version.all_files[0].pk) assert not self.requests_mock.called
def test_bad_icons(self): path = os.path.join(self.apps_path, 'badicon.webapp') iconless_app = self.webapp_from_path(path) tasks.fetch_icon(iconless_app, iconless_app.latest_version.all_files[0]) assert not self.requests_mock.called