예제 #1
0
파일: test_state.py 프로젝트: torp56/bokeh
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
파일: test_state.py 프로젝트: torp56/bokeh
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
파일: test_state.py 프로젝트: torp56/bokeh
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
파일: test_state.py 프로젝트: torp56/bokeh
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
파일: test_state.py 프로젝트: torp56/bokeh
def test_default_file_resources():
    s = state.State()
    s.output_file("foo.html")
    assert s.file['resources'].minified, True
예제 #15
0
파일: test_state.py 프로젝트: torp56/bokeh
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
파일: test_state.py 프로젝트: torp56/bokeh
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