示例#1
0
def test_output_file():
    s = state.State()
    s.output_file("foo.html")
    assert s.file['filename'] == "foo.html"
    assert s.file['title'] == "Bokeh Plot"
    assert s.file['resources'].log_level == 'info'
    assert s.file['resources'].minified == True
示例#2
0
 def test_output_file(self):
     s = state.State()
     s.output_file("foo.html")
     self.assertEqual(s.file['filename'], "foo.html")
     self.assertEqual(s.file['title'], "Bokeh Plot")
     self.assertEqual(s.file['resources'].log_level, 'info')
     self.assertEqual(s.file['resources'].minified, True)
示例#3
0
def test_creation():
    s = state.State()
    assert isinstance(s.document, Document)
    assert s.url == "http://localhost:5006/"
    assert s.file == None
    assert s.notebook == False
    assert s.server_enabled == False
    assert GENERATED_SESSION_ID_LEN == len(s.session_id)
示例#4
0
def test_reset():
    s = state.State()
    d = s.document
    s.output_file("foo.html")
    s.output_notebook()
    s.reset()
    assert s.file == None
    assert s.notebook == False
    assert isinstance(s.document, Document)
    assert s.document != d
示例#5
0
 def test_output_server(self):
     s = state.State()
     self.assertEqual(GENERATED_SESSION_ID_LEN, len(s.session_id))
     s.output_server()
     self.assertEqual(s.session_id, "default")
     self.assertEqual(s.server_url + "/", DEFAULT_SERVER_HTTP_URL)
     self.assertEqual(s.app_path, '/')
     s.output_server("foo")
     self.assertEqual(s.session_id, "foo")
     self.assertEqual(s.server_url + "/", DEFAULT_SERVER_HTTP_URL)
     self.assertEqual(s.app_path, '/')
示例#6
0
 def test_reset(self):
     s = state.State()
     d = s.document
     s.output_file("foo.html")
     s.output_server("default")
     s.output_notebook()
     s.reset()
     self.assertEqual(s.file, None)
     self.assertEqual(s.notebook, False)
     self.assertEqual(GENERATED_SESSION_ID_LEN, len(s.session_id))
     self.assertTrue(isinstance(s.document, Document))
     self.assertTrue(s.document != d)
示例#7
0
 def test_output_file_file_exists(self, mock_isfile, mock_logger):
     mock_isfile.return_value = True
     s = state.State()
     s.output_file("foo.html")
     self.assertEqual(s.file['filename'], "foo.html")
     self.assertEqual(s.file['title'], "Bokeh Plot")
     self.assertEqual(s.file['resources'].log_level, 'info')
     self.assertEqual(s.file['resources'].minified, True)
     self.assertTrue(state.logger.info.called)
     self.assertEqual(state.logger.info.call_args[0], (
         "Session output file 'foo.html' already exists, will be overwritten.",
     ))
示例#8
0
def test_output_file_file_exists(mock_isfile, mock_logger):
    mock_isfile.return_value = True
    s = state.State()
    s.output_file("foo.html")
    assert s.file['filename'] == "foo.html"
    assert s.file['title'] == "Bokeh Plot"
    assert s.file['resources'].log_level == 'info'
    assert s.file['resources'].minified == True
    assert state.logger.info.called
    assert state.logger.info.call_args[0] == (
        "Session output file 'foo.html' already exists, will be overwritten.",
    )
示例#9
0
def test_reset():
    s = state.State()
    d = s.document
    s.output_file("foo.html")
    s.output_server("default")
    s.output_notebook()
    s.reset()
    assert s.file == None
    assert s.notebook == False
    assert s.server_enabled == False
    assert GENERATED_SESSION_ID_LEN == len(s.session_id)
    assert isinstance(s.document, Document)
    assert s.document != d
示例#10
0
def test_output_server():
    s = state.State()
    assert GENERATED_SESSION_ID_LEN == len(s.session_id)
    assert s.server_enabled == False
    s.output_server()
    assert s.session_id == "default"
    assert s.session_id_allowing_none == "default"
    assert s.server_url + "/" == DEFAULT_SERVER_HTTP_URL
    assert s.app_path == '/'
    assert s.server_enabled == True
    s.output_server("foo")
    assert s.session_id == "foo"
    assert s.session_id_allowing_none == "foo"
    assert s.server_url + "/" == DEFAULT_SERVER_HTTP_URL
    assert s.app_path == '/'
    assert s.server_enabled == True
示例#11
0
def test_output_notebook_noarg():
    s = state.State()
    s.output_notebook()
    assert s.notebook == True
示例#12
0
 def test_creation(self):
     s = state.State()
     self.assertTrue(isinstance(s.document, Document))
     self.assertEqual(s.file, None)
     self.assertEqual(s.notebook, False)
     self.assertEqual(GENERATED_SESSION_ID_LEN, len(s.session_id))
示例#13
0
 def test_default_file_resources(self):
     s = state.State()
     s.output_file("foo.html")
     self.assertEqual(s.file['resources'].minified, True)
示例#14
0
def test_default_file_resources():
    s = state.State()
    s.output_file("foo.html")
    assert s.file['resources'].minified, True
示例#15
0
def test_creation():
    s = state.State()
    assert isinstance(s.document, Document)
    assert s.file == None
    assert s.notebook == False
示例#16
0
def test_output_invalid_notebook():
    s = state.State()
    with pytest.raises(Exception) as ex:
        s.notebook_type = "invalid_notebook"
    assert "Unknown notebook type 'invalid_notebook', valid notebook types are: jupyter, zeppelin" == str(
        ex.value)
示例#17
0
def test_output_notebook_witharg():
    s = state.State()
    s.output_notebook(notebook_type='zeppelin')
    assert s.notebook == True
    assert s.notebook_type == 'zeppelin'
示例#18
0
def test_output_notebook_noarg():
    s = state.State()
    s.output_notebook()
    assert s.notebook == True
    assert s.notebook_type == 'jupyter'
示例#19
0
 def test_output_notebook_noarg(self):
     s = state.State()
     s.output_notebook()
     self.assertEqual(GENERATED_SESSION_ID_LEN, len(s.session_id))
     self.assertEqual(s.notebook, True)
示例#20
0
def test_output_notebook_noarg():
    s = state.State()
    s.output_notebook()
    assert GENERATED_SESSION_ID_LEN == len(s.session_id)
    assert s.notebook == True
示例#21
0
def test_doc_set():
    s = state.State()
    d = Document()
    s.document = d
    assert isinstance(s.document, Document)
    assert s.document == d
示例#22
0
def test_output_invalid_notebook():
    s = state.State()
    with pytest.raises(Exception):
        s.notebook_type = None
    with pytest.raises(Exception):
        s.notebook_type = 10