def test_project_delete_no_configuration(self): path = generate_path() with mock.patch( "jupyter_project.project.ProjectTemplate.get_configuration" ) as mock_configuration: mock_configuration.side_effect = ValueError with assert_http_error(404): self.api_tester.delete(["projects", path]) mock_configuration.assert_called_once_with(Path(self.notebook_dir) / path)
def test_fail_template_rendering(self, renderer, default_name): instance = default_name.return_value name = str(uuid.uuid4()) instance.render.return_value = name renderer.side_effect = jinja2.TemplateError path = generate_path() body = dict(dummy="hello", smart="world") with assert_http_error(500): self.api_tester.post( ["files", quote("template1/file1", safe=""), path], body=body )
def test_project_post_invalid_configuration(self): path = generate_path() body = dict(dummy="hello", smart="world") with mock.patch( "jupyter_project.project.ProjectTemplate.render" ) as mock_render: mock_render.side_effect = jsonschema.ValidationError(message="failure") with assert_http_error(500): self.api_tester.post(["projects", path], body=body) mock_render.assert_called_once_with(body, Path(self.notebook_dir) / path)
def test_project_post_cookiecutter_failure(self): path = generate_path() body = dict(dummy="hello", smart="world") with mock.patch( "jupyter_project.handlers.ProjectTemplate.render" ) as mock_render: mock_render.side_effect = CookiecutterException with assert_http_error(500): self.api_tester.post(["projects", path], body=body) mock_render.assert_called_once_with(body, Path(self.notebook_dir) / path)
def test_project_delete_invalid_configuration(self): path = generate_path() with mock.patch( "jupyter_project.project.ProjectTemplate.get_configuration" ) as mock_configuration: mock_configuration.side_effect = jsonschema.ValidationError( message="failure" ) with assert_http_error(404): self.api_tester.delete(["projects", path]) mock_configuration.assert_called_once_with(Path(self.notebook_dir) / path)
def test_missing_body(self): with assert_http_error(500): self.api_tester.post(["files", quote("template3/file1", safe="")])
def test_missing_endpoint(self): with assert_http_error(404): self.api_tester.post(["files", quote("template4/file", safe="")], body={})