Skip to content

Commit

Permalink
Merge pull request #184 from jeremycline/run-all-tests
Browse files Browse the repository at this point in the history
Adjust the test runners to handle the trial tests
  • Loading branch information
jeremycline committed Apr 27, 2017
2 parents 15492f9 + d340357 commit 4859968
Show file tree
Hide file tree
Showing 8 changed files with 130 additions and 55 deletions.
13 changes: 13 additions & 0 deletions .coveragerc
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[run]
branch = True
include =
fmn/*

[report]
precision = 2
exclude_lines =
pragma: no cover
if __name__ == .__main__.:
omit =
fmn/tests/*

5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ build
_trial_temp/*
sse.log
fedmsg.d/fas_credentials.py
htmlcov/
.cache/
.coverage
.tox/
coverage.xml

# Images are generated as part of the docs build process
docs/images/*
Expand Down
31 changes: 21 additions & 10 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,24 +1,35 @@
sudo: required
language: python
python:
- "2.7"
- "3.3"
- "3.4"
- "3.5"

before_install:
- sudo apt-get -qq update
- sudo apt-get install -y swig

install:
- pip install --upgrade setuptools pip
- pip install -r dev-requirements.txt
- pip install -r requirements.txt
- pip install -e .
script: python -m unittest discover
- pip install tox

script:
- tox

after_success:
- source .tox/${TOXENV}/bin/activate && pip install codecov && codecov --env TRAVIS_OS_NAME,TOXENV

env:
global:
- PYTHONWARNINGS=always::DeprecationWarning
matrix:
- TOXENV=lint
- TOXENV=py27
matrix:
include:
- python: "3.4"
env: TOXENV=py34
- python: "3.5"
env: TOXENV=py35
- python: "3.6"
env: TOXENV=py36
allow_failures:
- python: "3.3"
- python: "3.4"
- python: "3.5"
- python: "3.6"
3 changes: 2 additions & 1 deletion dev-requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
flake8
html5lib
mock
nose
pytest
pytest-cov
vcrpy
# Docs requirements
sphinx
Expand Down
1 change: 0 additions & 1 deletion fmn/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +0,0 @@
__import__('pkg_resources').declare_namespace(__name__)
109 changes: 75 additions & 34 deletions fmn/tests/lib/test_lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,30 @@ def test_empty_recipients_list(self):
def test_basic_recipients_list(self):
self.create_user_and_context_data()
self.create_preference_data_empty()
expected_recipients = sorted([
{
'triggered_by_links': True,
'markup_messages': False,
'shorten_links': False,
'irc nick': 'threebean',
'user': 'ralph.id.fedoraproject.org',
'filter_name': 'test filter',
'filter_id': 1,
'filter_oneshot': False,
'verbose': True,
},
{
'triggered_by_links': True,
'markup_messages': False,
'shorten_links': False,
'irc nick': 'abadger1999',
'user': 'toshio.id.fedoraproject.org',
'filter_name': 'test filter 2',
'filter_id': 2,
'filter_oneshot': False,
'verbose': True,
},
])

code_path = "fmn.tests.example_rules:wat_rule"
self.create_preference_data_basic(code_path)
Expand All @@ -167,17 +191,7 @@ def test_basic_recipients_list(self):
preferences = load_preferences()
recipients = get_recipients(
preferences, msg, self.valid_paths, self.config)
self.assertDictEqual(recipients['irc'][0], {
'triggered_by_links': True,
'markup_messages': False,
'shorten_links': False,
'irc nick': 'threebean',
'user': 'ralph.id.fedoraproject.org',
'filter_name': 'test filter',
'filter_id': 1,
'filter_oneshot': False,
'verbose': True,
})
self.assertEqual(expected_recipients, sorted(recipients['irc']))

def test_miss_recipients_list(self):
self.create_user_and_context_data()
Expand Down Expand Up @@ -236,18 +250,31 @@ def test_multiple_identical_filters_hit(self):
preferences = load_preferences()
recipients = get_recipients(
preferences, msg, self.valid_paths, self.config)
expected = {
'triggered_by_links': True,
'markup_messages': False,
'shorten_links': False,
'irc nick': 'threebean',
'user': 'ralph.id.fedoraproject.org',
'filter_name': 'test filter',
'filter_id': 1,
'filter_oneshot': False,
'verbose': True,
}
self.assertDictEqual(recipients['irc'][0], expected)
expected_recipients = sorted([
{
'triggered_by_links': True,
'markup_messages': False,
'shorten_links': False,
'irc nick': 'threebean',
'user': 'ralph.id.fedoraproject.org',
'filter_name': 'test filter',
'filter_id': 1,
'filter_oneshot': False,
'verbose': True,
},
{
'triggered_by_links': True,
'markup_messages': False,
'shorten_links': False,
'irc nick': 'abadger1999',
'user': 'toshio.id.fedoraproject.org',
'filter_name': 'test filter 2',
'filter_id': 2,
'filter_oneshot': False,
'verbose': True,
},
])
self.assertEqual(expected_recipients, sorted(recipients['irc']))

def test_multiple_different_filters_hit(self):
self.create_user_and_context_data()
Expand All @@ -269,17 +296,31 @@ def test_multiple_different_filters_hit(self):
preferences = load_preferences()
recipients = get_recipients(
preferences, msg, self.valid_paths, self.config)
self.assertDictEqual(recipients['irc'][0], {
'triggered_by_links': True,
'markup_messages': False,
'shorten_links': False,
'irc nick': 'threebean',
'user': 'ralph.id.fedoraproject.org',
'filter_name': 'test filter',
'filter_id': 1,
'filter_oneshot': False,
'verbose': True,
})
expected_recipients = sorted([
{
'triggered_by_links': True,
'markup_messages': False,
'shorten_links': False,
'irc nick': 'threebean',
'user': 'ralph.id.fedoraproject.org',
'filter_name': 'test filter',
'filter_id': 1,
'filter_oneshot': False,
'verbose': True,
},
{
'triggered_by_links': True,
'markup_messages': False,
'shorten_links': False,
'irc nick': 'abadger1999',
'user': 'toshio.id.fedoraproject.org',
'filter_name': 'test filter 2',
'filter_id': 2,
'filter_oneshot': False,
'verbose': True,
},
])
self.assertEqual(expected_recipients, sorted(recipients['irc']))


if __name__ == '__main__':
Expand Down
1 change: 0 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ def get_requirements(filename='requirements.txt'):
tests_require=get_requirements('dev-requirements.txt'),
test_suite='fmn.tests',
packages=find_packages(exclude=('fmn.tests', 'fmn.tests.*')),
namespace_packages=['fmn'],
include_package_data=True,
zip_safe=False,
classifiers=[
Expand Down
22 changes: 14 additions & 8 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,28 +1,34 @@
[tox]
envlist =py27,py34,py35,lint,docs
envlist = lint,py27,py34,py35,py36,docs
skip_missing_interpreters = True

[testenv]
passenv = TRAVIS TRAVIS_*
deps =
-rrequirements.txt
-rdev-requirements.txt
whitelist_externals =
rm
commands =
nosetests -v
rm -rf htmlcov coverage.xml
py.test --cov-config .coveragerc --cov=fmn --cov-report term \
--cov-report xml --cov-report html

[testenv:docs]
basepython=python2
changedir = docs
deps =
sphinx
sphinxcontrib-httpdomain
-rrequirements.txt
whitelist_externals =
mkdir
sphinx-build
rm
commands=
rm -rf _build/
mkdir -p _static
mkdir -p images
python2 create_db_schema
sphinx-build -W -b html -d {envtmpdir}/doctrees . _build/html

[testenv:lint]
basepython=python2
deps =
flake8 > 3.0
commands =
Expand All @@ -31,4 +37,4 @@ commands =
[flake8]
show-source = True
max-line-length = 100
exclude = .git,.tox,dist,*egg,docs,alembic,,setup.py
exclude = .git,.tox,dist,*egg,docs,alembic,ansible,setup.py,fmn/lib/,fmn/rules,fmn/web/,fedmsg.d/fmn.py

0 comments on commit 4859968

Please sign in to comment.