Testing the Library

There are a few steps for testing the library.

  1. Install dependencies
  2. Modify your settings
  3. Run make test or make test-all

Install Dependencies

In order to run the tests, the dependencies need to be installed. To do this, run these commands

$ python3 -m virtualenv venv
$ source venv/bin/activate
(venv)$ python3 -m pip install -r requirements_test.txt

Modify Settings

Then copy .env.base to .env and edit the file. For example, the default .env.base file right now is:

################
# Testing

# When testing, there are a few variables that need to be modified to ensure
# that we can connect to remote servers and run their code. These mainly
# revolve around 3 main ideas:
#
# - how to connect to that server (hostname, port, user, password)
#
# - where to store the temporary files (directory, filename),
#
# - where to find the Python interpreter as well as what arguments to use
#   (name, arguments).

# The hostname of the server to connect to. This can be either an IP address
# (like 192.168.0.1) or an actual hostname (like example.com).
#
# Type: String
# Example(s):
#   TEST_SERVER_HOSTNAME=192.168.0.1
#   TEST_SERVER_HOSTNAME=example.com
#
TEST_SERVER_HOSTNAME=

# The SSH port of the server to connect to. This will almost always be port 22,
# but it could be different.
#
# Type: Number
# Example(s):
#   TEST_SERVER_PORT=22
#
TEST_SERVER_PORT=

# The remote user's username. This user should have password login enabled.
#
# Type: String
# Example(s):
#   TEST_REMOTE_USER=johnsmith
#
TEST_REMOTE_USER=

# The remote user's password. This will be used for initial connections during
# the tests as well as testing the functionality of the public key transfers.
#
# Type: String
# Example(s):
#   TEST_REMOTE_PASSWORD=p4ssw0rd
#
TEST_REMOTE_PASSWORD=

# The remote directory to store scripts in. This directory should already exist
# as the tests won't create it automatically.
#
# Also note that if this directory is used by other things, it could make the
# tests fail. For example, if you use /tmp/ as the remote directory and a root
# process writes something to /tmp/ while a test is running, the test will
# likely error because it doesn't have read permissions on that file.
#
# Type: String
# Example(s):
#   TEST_REMOTE_DIRECTORY=/tmp/django-remote-submission/
#
TEST_REMOTE_DIRECTORY=

# The filename to store the scripts as. Most tests only need one script to run,
# so this is the name of that script. As the tests are running Python scripts, it should probably end in .py.
#
# Type: String
# Example(s):
#   TEST_REMOTE_FILENAME=foobar.py
#
TEST_REMOTE_FILENAME=

# The path to the Python interpreter to use. If the path is not absolute, the
# $PATH variable will be searched to find the right executable. This can be
# either a Python 2 or Python 3 interpreter. Additionally, there is the option
# to use /usr/bin/env to find the full path to the executable.
#
# Type: String
# Example(s):
#   TEST_PYTHON_PATH=python3
#   TEST_PYTHON_PATH=/usr/bin/python3
#   TEST_PYTHON_PATH=/usr/bin/env
#
TEST_PYTHON_PATH=

# The comma-separated arguments to use when running the Python
# interpreter. This should include -u to make Python run in line-buffered mode.
#
# If using /usr/bin/env as the path, this should also include the executable
# name, like python3, in addition to the -u argument.
#
# Type: List of String
# Example(s):
#   TEST_PYTHON_ARGUMENTS=-u
#   TEST_PYTHON_ARGUMENTS=python3,-u
#
TEST_PYTHON_ARGUMENTS=

Run Tests

To run the tests on your current Python version, use the target test. To run tests on multiple Python versions, use the target test-all.

(venv)$ make test  # current python version
(venv)$ make test-all  # multiple python versions