Skip to content

Commit

Permalink
tests/: add a basic unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
james-callahan committed Jun 6, 2019
1 parent 0719270 commit 187102d
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 1 deletion.
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
],
setup_requires=["setuptools_scm"],
use_scm_version=True,
packages=find_packages(),
packages=find_packages(exclude=["tests"]),
zip_safe=True,
install_requires=["aiohttp"],
)
Empty file added tests/__init__.py
Empty file.
20 changes: 20 additions & 0 deletions tests/test_filter.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import unittest
from postgrest.filters import Filter

class TestFilters(unittest.TestCase):
def assertEncoding(self, value, expected, top_level=False):
self.assertEqual(Filter(value).prepare_query(top_level), expected)

def test_encoding(self):
self.assertEncoding(None, "null")
self.assertEncoding(False, "false")
self.assertEncoding(True, "true")
self.assertEncoding("foo", "foo", True)
self.assertEncoding("foo", "%22foo%22")
self.assertEncoding('with"double quote', 'with%22double%20quote', True)
self.assertEncoding('with"double quote', '%22with%5C%22double%20quote%22')
self.assertEncoding('double quote at end"', 'double%20quote%20at%20end%22', True)
self.assertEncoding('double quote at end"', '%22double%20quote%20at%20end%5C%22%22')

if __name__ == '__main__':
unittest.main()

0 comments on commit 187102d

Please sign in to comment.