forked from DonDebonair/slack-machine
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1bccd4a
commit a323250
Showing
10 changed files
with
171 additions
and
11 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,19 @@ | ||
sudo: false | ||
language: python | ||
python: | ||
- "3.6" | ||
env: | ||
matrix: | ||
- TOX_ENV=py33 | ||
- TOX_ENV=py34 | ||
- TOX_ENV=py35 | ||
- TOX_ENV=py36 | ||
- TOX_ENV=flake8 | ||
cache: pip | ||
install: | ||
- "travis_retry pip install setuptools --upgrade" | ||
- "travis_retry pip install tox" | ||
script: | ||
- tox -e $TOX_ENV | ||
after_script: | ||
- cat .tox/$TOX_ENV/log/*.log |
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,3 +1,8 @@ | ||
-r requirements.txt | ||
check-manifest==0.35 | ||
pyroma==2.2 | ||
check-manifest~=0.35 | ||
pyroma~=2.2 | ||
pytest~=3.2 | ||
tox~=2.7 | ||
detox~=0.11 | ||
flake8~=3.4 | ||
twine~=1.5 |
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 +1 @@ | ||
slackclient==1.0.7 | ||
slackclient~=1.0 |
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 |
---|---|---|
|
@@ -5,5 +5,7 @@ universal = 1 | |
exclude = | ||
.git, | ||
__pycache__, | ||
dist | ||
dist, | ||
build, | ||
tests | ||
max-line-length=100 |
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
Empty file.
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,73 @@ | ||
import re | ||
import pytest | ||
from machine.plugins.decorators import process, listen_to, respond_to | ||
|
||
|
||
@pytest.fixture | ||
def process_f(): | ||
@process(event_type='test_event') | ||
def f(event): | ||
pass | ||
|
||
return f | ||
|
||
|
||
@pytest.fixture | ||
def listen_to_f(): | ||
@listen_to(r'hello', re.IGNORECASE) | ||
def f(msg): | ||
pass | ||
|
||
return f | ||
|
||
|
||
@pytest.fixture | ||
def respond_to_f(): | ||
@respond_to(r'hello', re.IGNORECASE) | ||
def f(msg): | ||
pass | ||
|
||
return f | ||
|
||
|
||
@pytest.fixture | ||
def multi_decorator_f(): | ||
@respond_to(r'hello', re.IGNORECASE) | ||
@listen_to(r'hello', re.IGNORECASE) | ||
def f(msg): | ||
pass | ||
|
||
return f | ||
|
||
|
||
def test_process(process_f): | ||
assert hasattr(process_f, 'metadata') | ||
assert 'plugin_actions' in process_f.metadata | ||
assert 'process' in process_f.metadata['plugin_actions'] | ||
assert 'event_type' in process_f.metadata['plugin_actions']['process'] | ||
assert process_f.metadata['plugin_actions']['process']['event_type'] == 'test_event' | ||
|
||
|
||
def test_listen_to(listen_to_f): | ||
assert hasattr(listen_to_f, 'metadata') | ||
assert 'plugin_actions' in listen_to_f.metadata | ||
assert 'listen_to' in listen_to_f.metadata['plugin_actions'] | ||
assert 'regex' in listen_to_f.metadata['plugin_actions']['listen_to'] | ||
assert listen_to_f.metadata['plugin_actions']['listen_to']['regex'] == re.compile(r'hello', | ||
re.IGNORECASE) | ||
|
||
|
||
def test_respond_to(respond_to_f): | ||
assert hasattr(respond_to_f, 'metadata') | ||
assert 'plugin_actions' in respond_to_f.metadata | ||
assert 'respond_to' in respond_to_f.metadata['plugin_actions'] | ||
assert 'regex' in respond_to_f.metadata['plugin_actions']['respond_to'] | ||
assert respond_to_f.metadata['plugin_actions']['respond_to']['regex'] == re.compile(r'hello', re.IGNORECASE) | ||
|
||
|
||
def test_mulitple_decorators(multi_decorator_f): | ||
assert hasattr(multi_decorator_f, 'metadata') | ||
assert 'plugin_actions' in multi_decorator_f.metadata | ||
assert 'respond_to' in multi_decorator_f.metadata['plugin_actions'] | ||
assert 'listen_to' in multi_decorator_f.metadata['plugin_actions'] | ||
assert 'process' not in multi_decorator_f.metadata['plugin_actions'] |
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,10 @@ | ||
[tox] | ||
envlist = py33,py34,py35,py36,flake8 | ||
|
||
[testenv] | ||
commands = pytest | ||
deps =-r{toxinidir}/requirements-dev.txt | ||
|
||
[testenv:flake8] | ||
deps = flake8 | ||
commands = flake8 machine/ setup.py |