def test_assert_covered_empty(indexed_collection): """ assert_covered should raise an error it's trivially covered (returns no results) """ cur = indexed_collection.find() with pytest.raises(AssertionError): testing.assert_covered(cur)
def test_assert_covered_empty(indexed_collection): """ assert_covered should raise an error it's trivially covered (returns no results) """ cur = indexed_collection.find() with pytest.raises(AssertionError): testing.assert_covered(cur)
def test_assert_covered_null(indexed_collection): """ assert_covered should raise an error it's trivially covered (returns no results) """ indexed_collection.insert({"foo": "bar"}) proj = {'_id': False, 'foo': True} cur = indexed_collection.find({"foo": "baz"}, proj) with pytest.raises(AssertionError): testing.assert_covered(cur)
def test_assert_covered_null(indexed_collection): """ assert_covered should raise an error it's trivially covered (returns no results) """ indexed_collection.insert_one({"foo": "bar"}) proj = {'_id': False, 'foo': True} cur = indexed_collection.find({"foo": "baz"}, proj) with pytest.raises(AssertionError): testing.assert_covered(cur)
def test_records(docs_in_db, mongodb_instance): "Test 100 records are present and query is covered" # load all the numbers to ensure the index is in RAM _hint = 'number_1' _filter = {'number': {'$gt': 0}} _projection = {'number': True, '_id': False} cur = docs_in_db.find(filter=_filter, projection=_projection).hint(_hint) assert_covered(cur) # consume the cursor for good measure docs = list(cur) assert len(docs) == 100
def test_records(docs_in_db, mongodb_instance): "Test 100 records are present and query is covered" # load all the numbers to ensure the index is in RAM _hint = 'number_1' _filter = {'number': {'$gt': 0}} _projection = {'number': True, '_id': False} cur = docs_in_db.find(filter=_filter, projection=_projection).hint(_hint) assert_covered(cur) # consume the cursor for good measure docs = list(cur) assert len(docs) == 100
def test_assert_covered_passes(indexed_collection): indexed_collection.insert({'foo': 'bar'}) proj = {'_id': False, 'foo': True} cur = indexed_collection.find({'foo': 'bar'}, proj) testing.assert_covered(cur)
def test_assert_covered_passes(indexed_collection): indexed_collection.insert_one({'foo': 'bar'}) proj = {'_id': False, 'foo': True} cur = indexed_collection.find({'foo': 'bar'}, proj) testing.assert_covered(cur)