/usr/lib/python2.7/dist-packages/notebook/services/nbconvert/tests/test_nbconvert_api.py is in python-notebook 5.2.2-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | import requests
from notebook.utils import url_path_join
from notebook.tests.launchnotebook import NotebookTestBase
class NbconvertAPI(object):
"""Wrapper for nbconvert API calls."""
def __init__(self, request):
self.request = request
def _req(self, verb, path, body=None, params=None):
response = self.request(verb,
url_path_join('api/nbconvert', path),
data=body, params=params,
)
response.raise_for_status()
return response
def list_formats(self):
return self._req('GET', '')
class APITest(NotebookTestBase):
def setUp(self):
self.nbconvert_api = NbconvertAPI(self.request)
def test_list_formats(self):
formats = self.nbconvert_api.list_formats().json()
self.assertIsInstance(formats, dict)
self.assertIn('python', formats)
self.assertIn('html', formats)
self.assertEqual(formats['python']['output_mimetype'], 'text/x-python')
|