Skip to content

Commit

Permalink
add pymongo test
Browse files Browse the repository at this point in the history
  • Loading branch information
davidlatwe committed Jan 10, 2018
1 parent 8fae320 commit bfb0055
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 1 deletion.
3 changes: 3 additions & 0 deletions .travis.yml
Expand Up @@ -7,6 +7,9 @@ python:
- "3.5-dev" # 3.5 development branch
- "3.6-dev" # 3.6 development branch

services:
- mongodb

# command to install dependencies
install:
- "pip install pytest -U" #needed for py3.3 testpass
Expand Down
3 changes: 2 additions & 1 deletion setup.py
Expand Up @@ -70,7 +70,8 @@ def run_tests(self):
],
install_requires=[
'tinydb>=3.2.1',
'tinydb_serialization>=1.0.4'
'tinydb_serialization>=1.0.4',
'pymongo>=3.4.0'
],
tests_require=[
'pytest>=3.2.0',
Expand Down
28 changes: 28 additions & 0 deletions tests/test_coverage.py
@@ -0,0 +1,28 @@
import pytest
import pymongo


mongo_client = pymongo.MongoClient("localhost:27017")
mongo_database = mongo_client["test-mongodb"]
mongo_collection = mongo_database["test-collection"]


@pytest.fixture()
def collection(request):
# setup the db, clear if necessary
# todo: the 'drop()' function from pymongo should work in future revisions
mongo_collection.delete_many({})

mongo_collection.insert_one({"Hello": "World"})

def fin():
mongo_client.close()

request.addfinalizer(finalizer=fin)

return mongo_collection


def test_initialize_collection(collection):
c = collection.find({})
assert c.count() == 1

0 comments on commit bfb0055

Please sign in to comment.