|
1 | 1 | # Contributing
|
2 | 2 |
|
3 |
| -If you would like to help out with this project, please submit an issue or a pull request (including tests). I will review/merge them as soon as possible. |
| 3 | +I am accepting pull requests. Sometimes life gets busy and it takes me a little while to get everything merged in. To help speed up the process, please write tests to cover your changes. I will review/merge them as soon as possible. |
| 4 | + |
| 5 | +# Testing |
| 6 | + |
| 7 | +I use [nose](https://nose.readthedocs.io/en/latest/index.html) and [Coverage](https://coverage.readthedocs.io/en/latest/) to run the test suite. |
| 8 | + |
| 9 | +*WARNING*: The Tests connect to the QBO API and create/modify/delete data. DO NOT USE A PRODUCTION ACCOUNT! |
| 10 | + |
| 11 | +## Testing setup: |
| 12 | + |
| 13 | +1. Create/login into your [Intuit Developer account](https://developer.intuit.com). |
| 14 | +2. On your Intuit Developer account, create a Sandbox company and an App. |
| 15 | +3. Go to the Intuit Developer OAuth 2.0 Playground and fill out the form to get an **access token** and **refresh token**. You will need to copy the following values into your enviroment variables: |
| 16 | + ``` |
| 17 | + export CLIENT_ID="<Client ID>" |
| 18 | + export CLIENT_SECRET="<Client Secret>" |
| 19 | + export COMPANY_ID="<Realm ID>" |
| 20 | + export ACCESS_TOKEN="<Access token>" |
| 21 | + export REFRESH_TOKEN="<Refresh token>" |
| 22 | + ``` |
| 23 | + |
| 24 | + *Note*: You will need to update the access token when it expires. |
| 25 | + |
| 26 | +5. Install *nose* and *coverage*. Using Pip: |
| 27 | + `pip install nose coverage` |
| 28 | + |
| 29 | +6. Run `nosetests . --with-coverage --cover-package=quickbooks` |
| 30 | + |
| 31 | +## Creating new tests |
| 32 | +Normal Unit tests that do not connect to the QBO API should be located under `test/unit` Test that connect to QBO API should go under `tests/integration`. Inheriting from `QuickbooksTestCase` will automatically setup `self.qb_client` to use when connecting to QBO. |
| 33 | + |
| 34 | +Example: |
| 35 | +``` |
| 36 | +from tests.integration.test_base import QuickbooksTestCase |
| 37 | +
|
| 38 | +class SampleTestCase(QuickbooksTestCase): |
| 39 | + def test_something(self): |
| 40 | + vendors = Vendor.all(max_results=1, qb=self.qb_client) |
| 41 | +``` |
0 commit comments