-
Notifications
You must be signed in to change notification settings - Fork 71
Home
Welcome to the python-valve wiki!
Tests depend on pytest (>=2.4) and Mock (==1.0.1). The tests can be thought of being split into unit tests and functional tests. The unit tests are just that: unit tests. They test the smallest testable units of the library. The target for unit test coverage is 100%.
Along side the unit tests are (will be :D) a number of functional tests which run the library against actual Valve services/products. For valve.source
tests can be run against Source Dedicated Server (SRCDS) instances if they're installed.
In order to run the functional tests against SRCDS instances there must be a little bit of setup before hand. Firstly there must be at least one SRCDS installed. This can be done through SteamCMD. The Valve wiki page goes over how to do this, but ...
Create a directory to hold all the SteamCMD/SRCDS stuff (you'll need rwx permissions)
$ mkdir /opt/srcds && cd /opt/srcds
Acquire a copy of SteamCMD
$ wget http://media.steampowered.com/installer/steamcmd_linux.tar.gz
Extract from the archive
$ tar -xzf steamcmd_linux.tar.gz
Run SteamCMD, letting it update it self
$ ./steamcmd.sh``
Login to Steam
Steam> login anonymous
Set the install directory. The instances/
component matters. <SYMBOLIC NAME>
should be replaced with a name identifies the type of server. E.g. tf2
for a Team Fortress 2 server.
Steam> force_install_dir instances/<SYMBOLIC NAME>
Install server. <APP ID>
should be application ID of the server you want to install. This may take a while.
Steam> app_update <APP ID>
Exit SteamCMD
Steam> quit
You should now have a SRCDS instance installed. However, actually running the tests requires one more step. The PYTHON_VALVE_SRCDS
environment variable must be set to the parent directory of the instances/
directory which contains all our servers. This is so that the tests can automatically find the servers to run.
Now you can run the tests as you normally do (py.test python-valve/valve
). However in order to have the functional tests run you'll need to specify the --srcds
parameter. This should be set to a comma-separated list of SCRDS instances. The names of these instances correspond to the names of the child directories within PYTHON_VALVE_SRCDS/instances
.
Continuing hte above example, if we installed two servers, one into /opt/srcds/tf2
and the other into /opt/srcds/gmod
, then running py.test python-valve/valve --srcds=tf2,gmod
will run all the functional tests for both servers.
By default each SRCDS instance will be started with -console -norestart -nohltv -dev -debug
along with -ip
and -port
set to automatically generated values. If you need to add additional options you can do so by setting the environment variable PYTHON_VALVE_SRCDS_<CAPITALISED SYMBOLIC NAME>
.