def upload_addon(self, form): url = helpers.submit_url('upload-unlisted') csrfmiddlewaretoken = form.fields['csrfmiddlewaretoken'] with helpers.get_xpi() as addon_file: response = self.client.post( '/en-US/developers/upload/', {'csrfmiddlewaretoken': csrfmiddlewaretoken}, files={'upload': addon_file}, name='devhub.upload {}'.format( os.path.basename(addon_file.name)), allow_redirects=False, catch_response=True, ) if response.status_code == 302: poll_url = response.headers['location'] upload_uuid = gevent.spawn(self.poll_upload_until_ready, poll_url).get() if upload_uuid: form.fields['upload'] = upload_uuid self.submit_form(form=form, url=url) else: response.failure('Unexpected status: {}'.format( response.status_code))
def upload_addon(self, form): url = helpers.submit_url('upload-unlisted') csrfmiddlewaretoken = form.fields['csrfmiddlewaretoken'] with helpers.get_xpi() as addon_file: response = self.client.post( '/en-US/developers/upload/', {'csrfmiddlewaretoken': csrfmiddlewaretoken}, files={'upload': addon_file}, name='devhub.upload {}'.format( os.path.basename(addon_file.name)), allow_redirects=False, catch_response=True) if response.status_code == 302: poll_url = response.headers['location'] upload_uuid = gevent.spawn( self.poll_upload_until_ready, poll_url ).get() if upload_uuid: form.fields['upload'] = upload_uuid self.submit_form(form=form, url=url) else: response.failure('Unexpected status: {}'.format( response.status_code))
def load_upload_form(self): url = helpers.submit_url('upload-unlisted') response = self.client.get( url, allow_redirects=False, catch_response=True) if response.status_code == 200: html = lxml.html.fromstring(response.content) return html.get_element_by_id('create-addon') else: more_info = '' if response.status_code in (301, 302): more_info = ('Location: {}' .format(response.headers['Location'])) response.failure('Unexpected status: {}; {}' .format(response.status_code, more_info))
def load_upload_form(self): url = helpers.submit_url('upload-unlisted') response = self.client.get(url, allow_redirects=False, catch_response=True) if response.status_code == 200: response.success() html = lxml.html.fromstring(response.content) return html.get_element_by_id('create-addon') else: more_info = '' if response.status_code in (301, 302): more_info = 'Location: {}'.format(response.headers['Location']) response.failure( f'Unexpected status: {response.status_code}; {more_info}')