示例#1
0
def open_test_jupyter_note_book():
    """
    Open the Jupyter notebook for testing.

    Raises
    ------
    Exception
        If Jupyter is not running.

    Notes
    -----
    If the note does not exist in the target path for some
    reason, add a test notebook to the following path
    beforehand and place only one code cell.

    plot_playground/tests/notes/test_on_jupyter.ipynb
    """
    driver = selenium_helper.start_webdriver()
    root_url = get_jupyter_root_url_with_token()
    driver.get(root_url)
    test_note_url = TEST_JUPYTER_NOTE_URL
    driver.get(test_note_url)
    loop_count = 0
    while loop_count < 10:
        if driver.title == TEST_JUPYTER_NOTE_NAME:
            break
        loop_count += 1
        time.sleep(1)
    time.sleep(3)
def test_start_webdriver():
    """
    Test Command
    ------------
    $ python run_tests.py --module_name plot_playground.tests.test_selenium_helper:test_start_webdriver
    """
    driver = selenium_helper.start_webdriver()
    driver.get('https://www.google.com/')
    assert_equal(str(driver.title).lower(), 'google')
示例#3
0
def test__get_test_code_cell_elem():
    """
    Test Command
    ------------
    $ python run_tests.py --module_name plot_playground.tests.test_jupyter_helper:test__get_test_code_cell_elem
    """
    driver = selenium_helper.start_webdriver()
    driver.get('https://www.google.com/')
    assert_raises(Exception, jupyter_helper._get_test_code_cell_elem)

    jupyter_helper.open_test_jupyter_note_book()
    code_cell_elem = jupyter_helper._get_test_code_cell_elem()
    assert_true(isinstance(code_cell_elem, WebElement))
示例#4
0
def test__assert_current_page_is_test_notebook():
    """
    Test Command
    ------------
    $ python run_tests.py --module_name plot_playground.tests.test_jupyter_helper:test__assert_current_page_is_test_notebook
    """
    selenium_helper.exit_webdriver()
    assert_raises(Exception,
                  jupyter_helper._assert_current_page_is_test_notebook)

    driver = selenium_helper.start_webdriver()
    driver.get('https://www.google.com/')
    assert_raises(Exception,
                  jupyter_helper._assert_current_page_is_test_notebook)

    jupyter_helper.open_test_jupyter_note_book()
    jupyter_helper._assert_current_page_is_test_notebook()
示例#5
0
def setup():
    driver = selenium_helper.start_webdriver()
    jupyter_helper.open_test_jupyter_note_book()
def test_exit_webdriver():
    driver = selenium_helper.start_webdriver()
    assert_not_equal(driver, None)
    selenium_helper.exit_webdriver()
    assert_equal(selenium_helper.driver, None)