Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into html_link_convert…
Browse files Browse the repository at this point in the history
…er_slack
  • Loading branch information
chillipeper committed Nov 25, 2019
2 parents b2081fb + 43eaf29 commit 9b27032
Show file tree
Hide file tree
Showing 6 changed files with 363 additions and 3 deletions.
4 changes: 3 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,12 @@


tests_require = [
'mock',
'pytest==4.6.6',
'pytest-cov',
'pytest-runner',
'mock'
'pytest-mock',
'freezegun'
]

setup_requires = []
Expand Down
5 changes: 5 additions & 0 deletions will/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,11 @@ def schedule_say(self, content, when, message=None, room=None, channel=None, ser
elif room:
channel = room

# This does not look like testable code, or something that will ever
# happen. If we have a required "content" positional argument, if
# a "content" key commes in kwargs, python will fail with a:
# TypeError: schedule_say() got multiple values for keyword argument
# 'content'
if "content" in kwargs:
if content:
del kwargs["content"]
Expand Down
2 changes: 2 additions & 0 deletions will/requirements/dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,5 @@ yappi
tox
pytest==4.6.6
pytest-cov
pytest-mock
freezegun
50 changes: 48 additions & 2 deletions will/tests/conftest.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,51 @@
import datetime

import pytest

from will.abstractions import Message, Person
from will.abstractions import Event, Message, Person

# Any fixtures defined in this file will be automatically imported into
# discovered tests.
# https://docs.pytest.org/en/latest/fixture.html#conftest-py-sharing-fixture-functions


IO_BACKENDS = [
"will.backends.io_adapters.slack",
"will.backends.io_adapters.rocketchat",
"will.backends.io_adapters.shell"
]

ANALYZE_BACKENDS = [
"will.backends.analysis.nothing",
"will.backends.analysis.history"
]


@pytest.fixture()
def all_io_backends():
return IO_BACKENDS


@pytest.fixture(params=IO_BACKENDS)
def io_backend(request):
"""Parametrized fixture of available io backends"""

return request.param


@pytest.fixture(params=ANALYZE_BACKENDS)
def analysis(request):
"""Parametrized fixture of available analysis backends"""

return request.param


@pytest.fixture()
def person():
"""Mimic person abstraction"""
def _person(fields):
required_fields = {
"id": "TDB",
"id": "TBD",
"mention_handle": "TBD",
"source": "TBD",
"handle": "TBD",
Expand Down Expand Up @@ -45,4 +78,17 @@ def _message(fields):
required_fields.update(fields)

return Message(**required_fields)

return _message


@pytest.fixture()
def event():
"""Mimic event abstraction"""
def _event(fields):
required_fields = {"type": "TBD", "version": 1}
required_fields.update(fields)

return Event(**required_fields)

return _event
4 changes: 4 additions & 0 deletions will/tests/const.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
"""Contain constants to be used for tests"""

# Used to freeze_time
WILLS_BIRTHDAY = "2013-12-04 01:11:00"
Loading

0 comments on commit 9b27032

Please sign in to comment.