Add ability to specify ports for wsgi test server #26
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Same PR as #25 except the branch is now in this repo.
The proposed code modifies the
wsgi_server_host_port
fixture inserverfixtures.py
so that if two specific arguments are passed to it, it will initiate the WSGI test server in the specified port range. This is useful if your browser tests need to be run on specific ports (eg ClinGen needs to be run on specific ports for testing Auth0 authentication). If the arguments are missing the fixture will default towebtest.http
'sget_free_port
method as before.The extra code was derived from
webtest.http
'sget_free_port
method, with modifications to make it loop through the specified port range until it finds a free port. If a free port is not found within the range, it will raise an exception.Testing:
Browser tests should run on any open port (default/original behavior):
bin/test -m bdd -v --splinter-webdriver chrome
Browser tests should run between ports 65525 and 65535:
bin/test -m bdd -v --splinter-webdriver chrome --wsgi-arg port_range.min 65525 --wsgi-arg port_range.max 65535
Browser tests should fail due to occupied port (assuming port 80 is occupied):
bin/test -m bdd -v --splinter-webdriver chrome --wsgi-arg port_range.min 80 --wsgi-arg port_range.max 80
Browser tests should run on any open port (default/original behavior because
port_range.max
is missing):bin/test -m bdd -v --splinter-webdriver chrome --wsgi-arg port_range.min 65525
For derivative projects (eg clincoded, encoded) their
tests/__init.py
file will need the additional line in the `pytest_addoption function for the command line arguments to be read properly:If the specified ports are also required for travis tests, the arguments must be added to
.travis.yml
as well. An example (see last two lines):