Please be sure to read the contribution guidelines before making or requesting a change.
- Create a virtual environment:
python3 -m venv venv - Activate the virtual environment:
source venv/bin/activate - Install development dependencies:
pip install -e '.[dev]' - Hack away 🎉
To run tests, you will need the appropriate WebDriver for your chosen browser. This guide assumes you are using either Firefox or Chrome:
- For Firefox, download geckodriver.
# Create a firefox binary for smartcar tests in home directory
wget -O /tmp/firefox-latest.tar.xz 'https://download.mozilla.org/?product=firefox-latest&lang=en-US&os=linux64'
mkdir -p ${HOME}/firefox-latest-smartcar
tar -xJf /tmp/firefox-latest.tar.xz -C ${HOME}/firefox-latest-smartcar
rm /tmp/firefox-latest.tar.xz
- For Chrome, download chromedriver.
Ensure that the chosen driver is in your system's PATH, or you can specify the path directly in your test scripts.
The tests make requests to the Smartcar API, so you'll need to create an application on Smartcar and get your client id and client secret. You'll also need to add the testing redirect URI to your application.
- Create an application on the developer dashboard
- Add
https://example.com/authas a redirect URI - Pass the client id and client secret to the tests as environment variables
export E2E_SMARTCAR_CLIENT_ID='<Your client id>'
export E2E_SMARTCAR_CLIENT_SECRET='<Your client secret>'
- (Optional) Pass Application Management Token and webhook id to test webhooks:
export E2E_SMARTCAR_AMT='<Your application management token>'
export E2E_SMARTCAR_WEBHOOK_ID='<Your webhook id>'
- Run tests:
make test
Alternatively, you can use the pytest command to run specific directories, files, or tests.
# Examples:
# Running all tests
pytest
# Running test_vehicle.py
pytest tests/e2e/test_vehicle.py
# Running test_info in the test_vehicle.py file
pytest tests/e2e/test_vehicle.py::test_vehicle
# Running test_odometer in the test_vehicle.py file with debugger! e.g. ipdb
pytest -s tests/e2e/test_vehicle.py::test_odometer
# Refer to pytest docs for more about pytest!You can specify which browser to use for running the tests by setting the BROWSER environment variable. If not set, it defaults to Firefox:
export BROWSER='firefox' # Use Firefox
# or
export BROWSER='chrome' # Use ChromeAll code in this repository is formatted using black. Please format all contributions using the tool.
Please make sure that your commits follow the Angular Commit Message Conventions and the "type" for each commit message conveys the intent with respect to releasing as defined by semantic-release.