Skip to content

Commit

Permalink
:add: unittests
Browse files Browse the repository at this point in the history
  • Loading branch information
linkdd committed Aug 26, 2016
1 parent 4a8cd14 commit 9d3cd05
Show file tree
Hide file tree
Showing 6 changed files with 83 additions and 0 deletions.
13 changes: 13 additions & 0 deletions .coveragerc
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[run]
source = link

[report]
omit = */version.py
exclude_lines =
pragma: no cover
except ImportError:
if __name__ == '__main__':
if PY2:
if PY3:
raise NotImplementedError
pass
12 changes: 12 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
language: python
python:
- "2.7"
- "3.4"
- "3.5"
install:
- pip install coveralls
- python setup.py install
script:
- coverage run setup.py test
after_success:
- coveralls
16 changes: 16 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,22 @@ See documentation_ for more informations.
:target: https://pypi.python.org/pypi/link.fulltext/
:alt: Download format

.. image:: https://travis-ci.org/linkdd/link.fulltext.svg?branch=master&style=flat-square
:target: https://travis-ci.org/linkdd/link.fulltext
:alt: Build status

.. image:: https://coveralls.io/repos/github/linkdd/link.fulltext/badge.png?style=flat-square
:target: https://coveralls.io/r/linkdd/link.fulltext
:alt: Code test coverage

.. image:: https://img.shields.io/pypi/dm/link.fulltext.svg?style=flat-square
:target: https://pypi.python.org/pypi/link.fulltext/
:alt: Downloads

.. image:: https://landscape.io/github/linkdd/link.fulltext/master/landscape.svg?style=flat-square
:target: https://landscape.io/github/linkdd/link.fulltext/master
:alt: Code Health

Installation
------------

Expand Down
1 change: 1 addition & 0 deletions link/fulltext/test/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# -*- coding: utf-8 -*-
34 changes: 34 additions & 0 deletions link/fulltext/test/filter.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# -*- coding: utf-8 -*-

from b3j0f.utils.ut import UTCase
from unittest import main

from link.fulltext.filter import FulltextMatch


class TestMatcher(UTCase):
def test_query(self):
fm = FulltextMatch('a:(foo OR bar) b:(foo OR bar)')

docs = [
{'a': 'foo', 'b': 'foo'},
{'a': 'foo', 'b': 'bar'},
{'a': 'bar', 'b': 'foo'},
{'a': 'bar', 'b': 'bar'}
]

for doc in docs:
self.assertTrue(fm(doc))

docs = [
{'a': 'foo'},
{'b': 'bar'},
{'c': 'baz'}
]

for doc in docs:
self.assertFalse(fm({'a': 'foo'}))


if __name__ == '__main__':
main()
7 changes: 7 additions & 0 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[tox]
envlist=py27,py30,py31,py34,cpython

[testenv]
commands=python setup.py test
usedevelop=True
recreate=True

0 comments on commit 9d3cd05

Please sign in to comment.