Skip to content

Latest commit

 

History

History
97 lines (66 loc) · 3.21 KB

File metadata and controls

97 lines (66 loc) · 3.21 KB

Contributing

Please be sure to read the contribution guidelines before making or requesting a change.

Development Environment

  1. Create a virtual environment: python3 -m venv venv
  2. Activate the virtual environment: source venv/bin/activate
  3. Install development dependencies: pip install -e '.[dev]'
  4. Hack away 🎉

Running Tests

Requirements:

To run tests, you will need the appropriate WebDriver for your chosen browser. This guide assumes you are using either Firefox or Chrome:

Firefox

Set up a local firefox specifically for testing

# 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

Chrome

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.

  1. Create an application on the developer dashboard
  2. Add https://example.com/auth as a redirect URI
  3. 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>'
  1. (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>'
  1. 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!

Configuring the Browser for Testing:

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 Chrome

Formatting

All code in this repository is formatted using black. Please format all contributions using the tool.

Creating a pull request

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.