Skip to content

Commit

Permalink
Improved testing framework
Browse files Browse the repository at this point in the history
improved testing framework to only use Pytest and to use .env instead of configparser
  • Loading branch information
jmfernandes committed Aug 7, 2020
1 parent 1761366 commit d36b54f
Show file tree
Hide file tree
Showing 10 changed files with 497 additions and 509 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/pythonapp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ jobs:
robin_username: ${{ secrets.username }}
robin_password: ${{ secrets.password }}
robin_mfa: ${{ secrets.mfa }}
account_number: ${{ secrets.account }}
zipcode: ${{ secrets.zipcode }}
crypto_account: ${{ secrets.crypto }}
run: |
pip install pytest
pytest tests/test_github_actions.py
23 changes: 14 additions & 9 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,20 +1,25 @@
# general things to ignore
# sensitive environment information
.env
data.pickle
.vscode/

# build and distribution files that are auto-generated
build/
dist/

# notes to self
uploadnotes.txt
config.ini

# testing
tests/app_tests.py

# generated app info
.vscode/
.DS_Store
.pypirc
.cache/v/cache/
*.egg-info/
*.egg
*.py[cod]
__pycache__/
*.so
*~

.pypirc

tests/test_app.py

.cache/v/cache/
8 changes: 8 additions & 0 deletions .test.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#Fill me out with all your personal information to allow PyTest to work!
#For extra security, change the name of the file to simply ".env" instead of ".test.env"
robin_mfa=
robin_username=
robin_password=
account_number=
zipcode=
crypto_account=
20 changes: 20 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,26 @@ Contributing
============
If you would like to contribute to this project, follow our contributing guidelines `Here <https://github.com/jmfernandes/robin_stocks/blob/master/contributing.md>`_.

Automatic Testing
^^^^^^^^^^^^^^^^^

If you are contributing to this project and would like to use automatic testing for your changes, you will need to install pytest and pytest-dotenv. To do this type into terminal or command prompt:

>>> pip install pytest
>>> pip install pytest-dotenv

You will also need to fill out all the fields in .test.env. I recommend that you rename the file as .env once you are done adding in all your personal information. After that, you can simply run:

>>> pytest

to run all the tests. If you would like to run specific tests or run all the tests in a specific class then type:

>>> pytest tests/test_github_actions.py -k test_name_apple # runs only the 1 test
>>> pytest tests/test_github_actions.py -k TestStocks # runs every test in TestStocks but nothing else

Finally, if you would like the API calls to print out to terminal, then add the -s flag to any of the above pytest calls.


Installing
========================
There is no need to download these files directly. This project is published on PyPi,
Expand Down
12 changes: 0 additions & 12 deletions config_XxDELETExX.ini

This file was deleted.

11 changes: 7 additions & 4 deletions contributing.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,13 @@ that do not have a noticable effect on performance are generally not accepted.
XX is only changed when there is a fundamental and major change, YY is changed for features added, and ZZ is changed
for bug fixes. When updating a number, all the numbers to the right get changed to zero. i.e. 1.23.50 => 1.24.0. Numbers
are also allowed to go as high as you want, so 1.65289.0 is a valid version number.
4. After submitting a pull request, please be on the lookout for any messages from me about things that need to be fixed
before I merge the branch.


4. Write tests to cover the functionality of code you added.
5. After submitting a pull request, please be on the lookout for any messages from me about things that need to be fixed before I merge the branch.

## Testing

Make sure to install pytest and pytest-dotenv from PyPi and run every test in test_github_actions.py. Add new tests to cover the changes you have made, but not if you need to test placing orders. Currently there is no way to submit fake orders, so any tests for orders would submit a real order.

## Code of Conduct

### Our Pledge
Expand Down
4 changes: 4 additions & 0 deletions pytest.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[pytest]
env_files =
.env
.test.env
2 changes: 1 addition & 1 deletion robin_stocks/stocks.py
Original file line number Diff line number Diff line change
Expand Up @@ -539,7 +539,7 @@ def get_stock_historicals(inputSymbols, interval='hour', span='week', bounds='re
:type interval: Optional[str]
:param span: Sets the range of the data to be either 'day', 'week', 'month', '3month', 'year', or '5year'. Default is 'week'.
:type span: Optional[str]
:param bounds: Represents if graph will include extended trading hours or just regular trading hours. Values are 'extended' or 'regular'. Default is 'regular'
:param bounds: Represents if graph will include extended trading hours or just regular trading hours. Values are 'extended', 'trading', or 'regular'. Default is 'regular'
:type bounds: Optional[str]
:param info: Will filter the results to have a list of the values that correspond to key that matches info.
:type info: Optional[str]
Expand Down
Loading

0 comments on commit d36b54f

Please sign in to comment.