Skip to content

Commit

Permalink
Start on testing using Tox
Browse files Browse the repository at this point in the history
  • Loading branch information
GhostofGoes committed Oct 5, 2018
1 parent 14f460f commit f9d5abd
Show file tree
Hide file tree
Showing 4 changed files with 85 additions and 0 deletions.
21 changes: 21 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,24 @@ Feel free to contribute to this repository with pull requests! Here are some gui
* Contributions must be fully tested before you do a PR.

And that's it!


## Running the tests
Before running the tests, make sure the following are done:
1. Install Python 3.5, 3.6, and 3.7
2. Add a valid Discord application ID to the environment variable PYPRESENCE_CLIENT_ID (Windows Search -> "Environment variables")

```bash
# Install dependencies
pip3 install --user -U setuptools tox codespell flake8

# Run the functional tests
tox

# Check spelling
tox -e spellcheck

# Check code quality and formatting
tox -e flake8
```

Empty file added tests/__init__.py
Empty file.
26 changes: 26 additions & 0 deletions tests/basic_presence_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import os
import random

from pypresence import Presence

client_id = os.environ["PYPRESENCE_CLIENT_ID"]
RPC = Presence(client_id) # Initialize the Presence class
RPC.connect() # Start the handshake loop


quotes = [
"If you can dream it, you can achieve it.",
"Either write something worth reading or do something worth writing.",
"You become what you believe.",
"Fall seven times and stand up eight.",
"The best revenge is massive success.",
"Eighty percent of success is showing up.",
"Life is what happens to you while you’re busy making other plans.",
"Strive not to be a success, but rather to be of value.",
"The best time to plant a tree was 20 years ago. The second best time is now.",
"Everything you’ve ever wanted is on the other side of fear."
] # The quotes to choose from

for i in range(3):
RPC.update(details="Famous Quote:",
state=random.choice(quotes))
38 changes: 38 additions & 0 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
[tox]
envlist = py{35,36,37}-{linux,macos,windows}
skip_missing_interpreters = true
minversion = 3.0
requires = setuptools

[testenv]
description = Run CLI tests under {basepython}
setenv = PIP_DISABLE_VERSION_CHECK = 1
passenv = PYPRESENCE_CLIENT_ID http_proxy https_proxy no_proxy SSL_CERT_FILE TOXENV CI TRAVIS TRAVIS_* APPVEYOR APPVEYOR_* CODECOV_*

platform =
linux: linux
macos: darwin
windows: win32

# TODO: add tests for Client
# TODO: unit tests are probably a good thing to have someday
commands =
python tests/basic_presence_test.py

[testenv:spellcheck]
description = "Check spelling of code"
skip_install = true
ignore_errors = true
deps = codespell
commands = codespell --skip="*.pyc" pypresence examples tests

[testenv:flake8]
description = "Code quality inspection"
skip_install = true
ignore_errors = true
deps = flake8
commands = flake8 pypresence examples tests

[flake8]
max-line-length = 99
extend-ignore = E203, W503, E401, F401, E226

0 comments on commit f9d5abd

Please sign in to comment.