2018-08-28 15:45:42 +00:00
|
|
|
import pytest
|
|
|
|
from selenium.common.exceptions import WebDriverException
|
2018-08-22 13:48:47 +00:00
|
|
|
|
|
|
|
|
2018-08-23 08:32:52 +00:00
|
|
|
def test_load_from_url(selenium_standalone, web_server):
|
2018-08-22 13:48:47 +00:00
|
|
|
|
2018-08-23 08:32:52 +00:00
|
|
|
url, port = web_server
|
2018-08-22 13:48:47 +00:00
|
|
|
|
|
|
|
selenium_standalone.load_package(f"http://{url}:{port}/pyparsing.js")
|
|
|
|
assert "Invalid package name or URI" not in selenium_standalone.logs
|
|
|
|
|
|
|
|
selenium_standalone.run("from pyparsing import Word, alphas")
|
|
|
|
selenium_standalone.run("Word(alphas).parseString('hello')")
|
|
|
|
|
2018-08-23 08:32:52 +00:00
|
|
|
selenium_standalone.load_package(f"http://{url}:{port}/numpy.js")
|
|
|
|
selenium_standalone.run("import numpy as np")
|
|
|
|
|
2018-08-22 13:48:47 +00:00
|
|
|
|
|
|
|
def test_uri_mismatch(selenium_standalone):
|
|
|
|
selenium_standalone.load_package('pyparsing')
|
2018-08-28 15:45:42 +00:00
|
|
|
with pytest.raises(WebDriverException,
|
|
|
|
match="URI mismatch, attempting "
|
|
|
|
"to load package pyparsing"):
|
|
|
|
selenium_standalone.load_package('http://some_url/pyparsing.js')
|
2018-08-22 13:48:47 +00:00
|
|
|
assert "Invalid package name or URI" not in selenium_standalone.logs
|
|
|
|
|
|
|
|
|
|
|
|
def test_invalid_package_name(selenium):
|
2018-08-28 15:45:42 +00:00
|
|
|
with pytest.raises(WebDriverException,
|
|
|
|
match="Invalid package name or URI"):
|
|
|
|
selenium.load_package('wrong name+$')
|
2018-08-22 13:48:47 +00:00
|
|
|
selenium.clean_logs()
|
2018-08-28 15:45:42 +00:00
|
|
|
|
|
|
|
with pytest.raises(WebDriverException,
|
|
|
|
match="Invalid package name or URI"):
|
|
|
|
selenium.load_package('tcp://some_url')
|