--- layout: docs title: Docs - Testing nav: docs toc: testing ---
We don't require authentication to use our production API endpoints, so you are welcome to develop and test against our real API. However, if you're running a bunch of continuous integration tests (Jenkins, Travis CI, etc.), you'll likely hit our rate limits quickly.
NOTE: If you want to setup a development environment and run tests for the ballotapi code itself, check out our contributing docs.
To make your lives easier, we have setup several testing domains with a small subset of data from our ballot database that have more test-friendly rate limits. That way, you can still run automated tests against them without constantly hitting our production rate limits.
api-test.ballotapi.org
api-test-ratelimited.ballotapi.org
api-test.ballotapi.org
,
but rate limits are set very low. You typically
want to use this domain to test your rate limit
handling logic.
If you want to run your tests completely internally, you
are welcome to spin up your own test server. Below are the
steps to quickly spin up an equivalent of
api-test.ballotapi.org
on your own system.
sudo apt-get install python postgresql postgis
sudo -u postgres psql -c "CREATE USER bapiuser WITH ENCRYPTED PASSWORD 'hunter2';"
sudo -u postgres psql -c "CREATE DATABASE bapidb;"
sudo -u postgres psql -c "GRANT ALL PRIVILEGES ON DATABASE bapidb TO bapiuser;"
wget https://code.ballotapi.org/ballotapi/releases/ballotapi-latest.tar.gz
tar -xzvf ballotapi-latest.tar.gz
rm ballotapi-latest.tar.gz
cd ballotapi/api
python server.py --load "testdata" --dbname "bapidb" --dbuser "bapiuser" --dbpass "hunter2"
brew install postgres
brew install postgis
sudo -u postgres psql -c "CREATE USER bapiuser WITH ENCRYPTED PASSWORD 'hunter2';"
sudo -u postgres psql -c "CREATE DATABASE bapidb;"
sudo -u postgres psql -c "GRANT ALL PRIVILEGES ON DATABASE bapidb TO bapiuser;"
cd ~/Downloads/ballotapi/api
(or wherever you unzipped the archive)python server.py --load "testdata" --dbname "bapidb" --dbuser "bapiuser" --dbpass "hunter2"
psql.exe -c "CREATE USER bapiuser WITH ENCRYPTED PASSWORD 'hunter2';"
psql.exe -c "CREATE DATABASE bapidb;"
psql.exe -c "GRANT ALL PRIVILEGES ON DATABASE bapidb TO bapiuser;"
cd Downloads\ballotapi\api
(or wherever you unzipped the archive)python.exe server.py --load "testdata" --dbname "bapidb" --dbuser "bapiuser" --dbpass "hunter2"
If you want to update your existing installation, simply
download our repo again (see "Download and unzip the repo..." steps above)
and run the same command (python server.py --load ...
).
It will automatically clear and reload the testdata dataset
into the database.
Are these setup instructions incorrect? Help us out by opening an issue or pull request