This repository was archived by the owner on Mar 22, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add unit- and integration tests (#6)
* Add unit test framework and integration test description * Add docker-compose file and integration test infrastructure * Remove debug print from message handler * Add linting and testing workflows * Add linter config * Fix flake errors * Add docformatter dependency * Fix isort * Fix integration test script * Finish unit tests in bot_test.py (#11) * Message handler unit tests (#12) * Finish unit tests in bot_test.py * WIP * Remove debug prints * Finish unit tests (#13) * Add integration tests (#14) * Make integration tests multiprocess * Add the first integration tests * Add uncommitted files' * Simplify code to expect reply * Fix weird merge errors * Fix unit test * Add file and reaction test * Minor adjustments * Finish tests, add one retry to expect_reply * Increase docker startup wait * Try de-flaking sleep test * Add random delay before each test to prevent overloading * Remove random delay, explicitly sort thread order * Wait 5 seconds between starting bot and sending messages * Use new docker image with different tokens
- Loading branch information
Showing
28 changed files
with
858 additions
and
70 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
version: 2 | ||
updates: | ||
- package-ecosystem: pip | ||
directory: "/" | ||
schedule: | ||
interval: weekly | ||
open-pull-requests-limit: 10 | ||
allow: | ||
- dependency-type: direct | ||
- dependency-type: indirect | ||
- package-ecosystem: github-actions | ||
directory: "/" | ||
schedule: | ||
interval: weekly | ||
open-pull-requests-limit: 10 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
name: Linting | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
pull_request: {} | ||
|
||
jobs: | ||
lint: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Cancel Outdated Runs | ||
uses: styfle/[email protected] | ||
with: | ||
access_token: ${{ github.token }} | ||
- uses: actions/checkout@v2 | ||
- name: Set up Python 3.8 | ||
uses: actions/setup-python@v2 | ||
with: | ||
python-version: 3.8 | ||
- uses: actions/cache@v2 | ||
with: | ||
path: ~/.cache/pip | ||
key: ${{ runner.os }}-pip3-${{ hashFiles('*requirements.txt') }} | ||
- run: pip install wheel | ||
- name: Install dependencies | ||
run: pip install -e .[dev] | ||
- name: Run Flake8 | ||
run: flake8 | ||
- name: Black code style | ||
run: black . --check --target-version py38 --exclude '\.mypy_cache/|\.venv/|env/|(.*/)*snapshots/|.pytype/' | ||
- name: Docstring formatting | ||
run: docformatter -c -r . --wrap-summaries 88 --wrap-descriptions 88 | ||
- name: Check import order with isort | ||
run: isort . --check --diff | ||
- name: PyType type-check | ||
run: pytype -j auto . |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
name: Tests | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
pull_request: {} | ||
|
||
jobs: | ||
unit_test: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Cancel Outdated Runs | ||
uses: styfle/[email protected] | ||
with: | ||
access_token: ${{ github.token }} | ||
- uses: actions/checkout@v2 | ||
- name: Set up Python 3.8 | ||
uses: actions/setup-python@v2 | ||
with: | ||
python-version: 3.8 | ||
- uses: actions/cache@v2 | ||
with: | ||
path: ~/.cache/pip | ||
key: ${{ runner.os }}-pip3-${{ hashFiles('*requirements.txt') }} | ||
- name: Install dependencies | ||
run: pip install -e .[dev] | ||
- name: Check package version conflicts | ||
run: pip check | ||
- name: Run unit tests | ||
run: pytest -vv tests/unit_tests -n auto | ||
|
||
integration_test: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Set up Python 3.8 | ||
uses: actions/setup-python@v2 | ||
with: | ||
python-version: 3.8 | ||
- uses: actions/cache@v2 | ||
with: | ||
path: ~/.cache/pip | ||
key: ${{ runner.os }}-pip3-${{ hashFiles('*requirements.txt') }} | ||
- name: Install dependencies | ||
run: pip install -e .[dev] | ||
- name: Launch test server | ||
working-directory: tests/integration_tests | ||
run: docker-compose up -d && sleep 45 | ||
- name: Print docker info | ||
run: docker ps -a | ||
- name: Run integration tests | ||
working-directory: tests/integration_tests | ||
run: pytest . -vv -n auto |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,4 @@ | ||
**/__pycache__ | ||
*.egg-info | ||
**/*.egg-info | ||
**/*.log | ||
**/*.lock |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
black==20.8b1 | ||
docformatter==1.4 | ||
filelock==3.0.12 | ||
flake8==3.8.4 | ||
isort==5.7.0 | ||
pytest==6.2.1 | ||
pytest-xdist==2.2.0 | ||
pytype==2021.1.28 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
[flake8] | ||
|
||
# Black compatibility. | ||
ignore = E203,E501,W503 | ||
exclude = build,dist,env,venv,.env,.venv,.pytype,**/snapshots,ignored | ||
|
||
|
||
[isort] | ||
|
||
profile = black | ||
# Don't misclassify larq as a first-party import. | ||
known_third_party = larq | ||
skip = | ||
build | ||
dist | ||
venv | ||
.env | ||
.venv | ||
.git | ||
.pytype | ||
ignored | ||
skip_glob = **/snapshots | ||
|
||
|
||
[pytype] | ||
|
||
inputs = . | ||
output = .pytype | ||
exclude = | ||
dist | ||
env | ||
venv | ||
.env | ||
.venv | ||
.pytype | ||
**/snapshots | ||
tests | ||
**/*_test.py | ||
ignored | ||
# Keep going past errors to analyse as many files as possible. | ||
keep_going = True | ||
python_version = 3.8 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
from snaketalk.bot import Bot | ||
from snaketalk.message import Message | ||
from snaketalk.plugins import ExamplePlugin, Function, Plugin, listen_to | ||
from snaketalk.settings import Settings | ||
|
||
__all__ = [ | ||
"Bot", | ||
"Message", | ||
"Function", | ||
"Plugin", | ||
"listen_to", | ||
"ExamplePlugin", | ||
"Settings", | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
from snaketalk.plugins.base import Function, Plugin, listen_to | ||
from snaketalk.plugins.default import DefaultPlugin | ||
from snaketalk.plugins.example import ExamplePlugin | ||
|
||
__all__ = ["Function", "Plugin", "listen_to", "DefaultPlugin"] | ||
__all__ = ["Function", "Plugin", "listen_to", "ExamplePlugin"] |
Oops, something went wrong.