Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

rename parameters

  • Loading branch information...
commit f45925ffb3d472965ec8e09e2ddde9f476d754ca 1 parent fd8dd14
@kiorky kiorky authored
View
4 README.rst
@@ -9,8 +9,8 @@ Documents are pulled by the webserver.
GET parameters are:
- **url**: a url to a document to be grabbed from transformation
-- **output_mt**: (optionnal, default to ``application/pdf`` if not provided)
-- **input_mt**: (optionnal, guessed from input url if not provided)
+- **to**: output mimetype (optionnal, default to ``application/pdf`` if not provided)
+- **from**: input mimetype (optionnal, guessed from input url if not provided)
Older transformed documents are cleaned after a defined time, tested at each http request on the application.
View
6 src/convertit/tests/test_functional.py
@@ -60,7 +60,7 @@ def test_with_valid_url_toword(self):
mock_req = Mock()
mock_req.read.return_value = odt_data
mock_urlopen.return_value = mock_req
- resp = self.testapp.get('/', params={'url': url, 'output_mt': 'application/msword'}, status=302)
+ resp = self.testapp.get('/', params={'url': url, 'to': 'application/msword'}, status=302)
mock_urlopen.assert_called_once_with(url)
filename = os.path.basename(resp.location)
filepath = os.path.join(self.settings['converted_dir'], filename)
@@ -80,13 +80,13 @@ def test_no_such_transform(self):
mock_req = Mock()
mock_req.read.return_value = odt_data
mock_urlopen.return_value = mock_req
- resp = self.testapp.get('/', params={'url': url, 'output_mimetype': 'application/pdf'}, status=302)
+ resp = self.testapp.get('/', params={'url': url, 'to': 'application/pdf'}, status=302)
self.assertTrue(
'Unsupported transform: application/pdfnocontent'
in self.testapp.get(
'/', params={
'url': url,
- 'output_mt': 'application/pdfnocontent'}, status=400).body)
+ 'to': 'application/pdfnocontent'}, status=400).body)
def test_invalid_hostname(self):
"Get homepage with `url` that triggers a DNS resolution error"
View
4 src/convertit/views.py
@@ -40,13 +40,13 @@ def home_view(request):
remove_old_files(request)
url = request.GET.get('url')
- output_mt = request.GET.get('output_mt', 'application/pdf')
+ output_mt = request.GET.get('to', 'application/pdf')
if url is None:
return HTTPBadRequest('Missing parameter: url')
guessed_mimetype, _ = guess_type(url)
- mimetype = request.GET.get('input_mt', guessed_mimetype)
+ mimetype = request.GET.get('from', guessed_mimetype)
if not mimetype:
return HTTPBadRequest('Can not guess mimetype')
Please sign in to comment.
Something went wrong with that request. Please try again.