Skip to content

Commit

Permalink
Increase coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
davidlatwe committed May 29, 2018
1 parent 9a15b5f commit 9e89ddc
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 10 deletions.
10 changes: 5 additions & 5 deletions montydb/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ def __init__(self, options, storage_wconcern=None):
@property
def _options(self):
"""The original options used to create this ClientOptions."""
return self.__options
return self.__options # pragma: no cover

@property
def codec_options(self):
Expand All @@ -215,13 +215,13 @@ class BaseObject(object):
def __init__(self, codec_options, write_concern):

if not isinstance(codec_options, CodecOptions):
raise TypeError("codec_options must be an instance of "
"bson.codec_options.CodecOptions")
raise TypeError("codec_options must be an " # pragma: no cover
"instance of bson.codec_options.CodecOptions")
self.__codec_options = codec_options

if not isinstance(write_concern, WriteConcern):
raise TypeError("write_concern must be an instance of "
"montydb.base.WriteConcern")
raise TypeError("write_concern must be an " # pragma: no cover
"instance of montydb.base.WriteConcern")
self.__write_concern = write_concern

@property
Expand Down
4 changes: 2 additions & 2 deletions montydb/cursor.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from .engine.queries import QueryFilter, ordering
from .engine.project import Projector
from .base import (
validate_boolean,
validate_is_mapping,
_fields_list_to_dict,
_index_list,
Expand Down Expand Up @@ -372,8 +373,7 @@ def comment(self, comment):
raise NotImplementedError

def count(self, with_limit_and_skip=False):
if not isinstance(with_limit_and_skip, bool):
raise TypeError("with_limit_and_skip must be True or False")
validate_boolean("with_limit_and_skip", with_limit_and_skip)
if self._id is None:
# (NOTE) this might need improve
self.__query()
Expand Down
7 changes: 6 additions & 1 deletion tests/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def test_client_eq_other_type(monty_client):

def test_client_ne(monty_client, tmp_monty_repo):
other_client = montydb.MontyClient(tmp_monty_repo + "/other_address")
assert not monty_client == other_client
assert monty_client != other_client


def test_client_getattr(monty_client):
Expand Down Expand Up @@ -99,3 +99,8 @@ def test_client_get_database_non_windows_faild(monty_client, monkeypatch):
def test_client_context(monty_client, tmp_monty_repo):
with montydb.MontyClient(tmp_monty_repo + "/address"):
pass


def test_client_wtimeout_type_error(monty_client):
with pytest.raises(TypeError):
montydb.MontyClient(monty_client.address, wtimeout=0.5)
5 changes: 5 additions & 0 deletions tests/test_cursor.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ def test_cursor_collection(monty_collection):
assert cur.collection == monty_collection


def test_cursor_filter_type_error(monty_collection):
with pytest.raises(TypeError):
monty_collection.find([])


def test_cursor_skip(monty_collection):
cur = monty_collection.find({}, skip=5)
assert next(cur)["doc"] == 5
Expand Down
2 changes: 1 addition & 1 deletion tests/test_database.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def test_database_eq_other_type(monty_database):

def test_database_ne(monty_database, monty_client):
other_database = monty_client.get_database("other_db")
assert not monty_database == other_database
assert monty_database != other_database


def test_database_getitem(monty_database):
Expand Down
2 changes: 1 addition & 1 deletion tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@


def test_utils_monty_dump(tmp_monty_repo):
tmp_dump = os.path.join(tmp_monty_repo, "dumped.json")
tmp_dump = os.path.join(tmp_monty_repo, "test_mkdirs", "dumped.json")
monty_dump(tmp_dump, DOCUMENTS)

with open(tmp_dump, "r") as dump:
Expand Down

0 comments on commit 9e89ddc

Please sign in to comment.