当前位置: 首页>>代码示例>>Python>>正文


Python launchnotebook.assert_http_error函数代码示例

本文整理汇总了Python中notebook.tests.launchnotebook.assert_http_error函数的典型用法代码示例。如果您正苦于以下问题:Python assert_http_error函数的具体用法?Python assert_http_error怎么用?Python assert_http_error使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了assert_http_error函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_kernel_handler

    def test_kernel_handler(self):
        # GET kernel with given id
        kid = self.kern_api.start().json()['id']
        r = self.kern_api.get(kid)
        kern1 = r.json()
        self.assertEqual(r.status_code, 200)
        assert isinstance(kern1, dict)
        self.assertIn('id', kern1)
        self.assertEqual(kern1['id'], kid)

        # Request a bad kernel id and check that a JSON
        # message is returned!
        bad_id = '111-111-111-111-111'
        with assert_http_error(404, 'Kernel does not exist: ' + bad_id):
            self.kern_api.get(bad_id)

        # DELETE kernel with id
        r = self.kern_api.shutdown(kid)
        self.assertEqual(r.status_code, 204)
        kernels = self.kern_api.list().json()
        self.assertEqual(kernels, [])

        # Request to delete a non-existent kernel id
        bad_id = '111-111-111-111-111'
        with assert_http_error(404, 'Kernel does not exist: ' + bad_id):
            self.kern_api.shutdown(bad_id)
开发者ID:BarnetteME1,项目名称:DnD-stuff,代码行数:26,代码来源:test_kernels_api.py

示例2: test_delete_non_empty_dir

 def test_delete_non_empty_dir(self):
     if sys.platform == 'win32':
         self.skipTest("Disabled deleting non-empty dirs on Windows")
     # Test that non empty directory can be deleted
     self.api.delete(u'å b')
     # Check if directory has actually been deleted
     with assert_http_error(404):
         self.api.list(u'å b')
开发者ID:Carreau,项目名称:jupyter_notebook,代码行数:8,代码来源:test_contents_api.py

示例3: test_get_text_file_contents

    def test_get_text_file_contents(self):
        for d, name in self.dirs_nbs:
            path = url_path_join(d, name + '.txt')
            model = self.api.read(path).json()
            self.assertEqual(model['name'], u'%s.txt' % name)
            self.assertEqual(model['path'], path)
            self.assertIn('content', model)
            self.assertEqual(model['format'], 'text')
            self.assertEqual(model['type'], 'file')
            self.assertEqual(model['content'], self._txt_for_name(name))

        # Name that doesn't exist - should be a 404
        with assert_http_error(404):
            self.api.read('foo/q.txt')

        # Specifying format=text should fail on a non-UTF-8 file
        with assert_http_error(400):
            self.api.read('foo/bar/baz.blob', type='file', format='text')
开发者ID:drastorguev,项目名称:pythondojo,代码行数:18,代码来源:test_contents_api.py

示例4: test_delete

    def test_delete(self):
        newsession = self.sess_api.create('foo/nb1.ipynb').json()
        sid = newsession['id']

        resp = self.sess_api.delete(sid)
        self.assertEqual(resp.status_code, 204)

        sessions = self.sess_api.list().json()
        self.assertEqual(sessions, [])

        with assert_http_error(404):
            self.sess_api.get(sid)
开发者ID:AFJay,项目名称:notebook,代码行数:12,代码来源:test_sessions_api.py

示例5: test_get_binary_file_contents

    def test_get_binary_file_contents(self):
        for d, name in self.dirs_nbs:
            path = url_path_join(d, name + '.blob')
            model = self.api.read(path).json()
            self.assertEqual(model['name'], u'%s.blob' % name)
            self.assertEqual(model['path'], path)
            self.assertIn('content', model)
            self.assertEqual(model['format'], 'base64')
            self.assertEqual(model['type'], 'file')
            self.assertEqual(
                decodebytes(model['content'].encode('ascii')),
                self._blob_for_name(name),
            )

        # Name that doesn't exist - should be a 404
        with assert_http_error(404):
            self.api.read('foo/q.txt')
开发者ID:drastorguev,项目名称:pythondojo,代码行数:17,代码来源:test_contents_api.py

示例6: test_clear

    def test_clear(self):
        with assert_http_error(500):
            self.build_api.clear()

        def build_thread():
            with assert_http_error(500):
                self.build_api.build()

        t1 = threading.Thread(target=build_thread)
        t1.start()

        while 1:
            resp = self.build_api.getStatus().json()
            if resp['status'] == 'building':
                break

        resp = self.build_api.clear()
        assert resp.status_code == 204
开发者ID:AlbertHilb,项目名称:jupyterlab,代码行数:18,代码来源:test_build_api.py

示例7: test_mkdir_hidden_400

 def test_mkdir_hidden_400(self):
     with assert_http_error(400):
         resp = self.api.mkdir(u'å b/.hidden')
开发者ID:drastorguev,项目名称:pythondojo,代码行数:3,代码来源:test_contents_api.py

示例8: test_copy_put_400

 def test_copy_put_400(self):
     with assert_http_error(400):
         resp = self.api.copy_put(u'å b/ç d.ipynb', u'å b/cøpy.ipynb')
开发者ID:drastorguev,项目名称:pythondojo,代码行数:3,代码来源:test_contents_api.py

示例9: test_get_bad

 def test_get_bad(self):
     with assert_http_error(404):
         self.settings_api.get('foo')
开发者ID:7125messi,项目名称:jupyterlab,代码行数:3,代码来源:test_settings_api.py

示例10: test_get_bad_type

    def test_get_bad_type(self):
        with assert_http_error(400):
            self.api.read(u'unicodé', type='file')  # this is a directory

        with assert_http_error(400):
            self.api.read(u'unicodé/innonascii.ipynb', type='directory')
开发者ID:drastorguev,项目名称:pythondojo,代码行数:6,代码来源:test_contents_api.py

示例11: test_get_contents_no_such_file

 def test_get_contents_no_such_file(self):
     # Name that doesn't exist - should be a 404
     with assert_http_error(404):
         self.api.read('foo/q.ipynb')
开发者ID:drastorguev,项目名称:pythondojo,代码行数:4,代码来源:test_contents_api.py

示例12: test_put_wrong_id

 def test_put_wrong_id(self):
     with assert_http_error(404):
         self.settings_api.put('foo', dict())
开发者ID:7125messi,项目名称:jupyterlab,代码行数:3,代码来源:test_settings_api.py

示例13: test_patch_bad_data

 def test_patch_bad_data(self):
     id = 'jupyter.services.codemirror-commands'
     data = dict(keyMap=10)
     with assert_http_error(400):
         self.settings_api.patch(id, data)
开发者ID:cameronoelsen,项目名称:jupyterlab,代码行数:5,代码来源:test_settings_api.py

示例14: test_list_nonexistant_dir

 def test_list_nonexistant_dir(self):
     with assert_http_error(404):
         self.api.list('nonexistant')
开发者ID:drastorguev,项目名称:pythondojo,代码行数:3,代码来源:test_contents_api.py

示例15: test_rename_existing

 def test_rename_existing(self):
     with assert_http_error(409):
         self.api.rename('foo/a.ipynb', 'foo/b.ipynb')
开发者ID:drastorguev,项目名称:pythondojo,代码行数:3,代码来源:test_contents_api.py


注:本文中的notebook.tests.launchnotebook.assert_http_error函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。