def test_get_indexable(): index = pretend.stub( db=pretend.stub(packaging=pretend.stub(get_full_latest_releases=pretend.call_recorder(lambda: []))) ) pmap = ProjectMapping(index=index) pmap.get_indexable() assert index.db.packaging.get_full_latest_releases.calls == [pretend.call()]
def test_get_indexable(): index = pretend.stub(models=pretend.stub(packaging=pretend.stub( get_full_latest_releases=pretend.call_recorder(lambda: []), ), ), ) pmap = ProjectMapping(index=index) pmap.get_indexable() assert index.models.packaging.get_full_latest_releases.calls == [ pretend.call(), ]
def test_search(query, body): index = pretend.stub( _index="warehouse", es=pretend.stub(search=pretend.call_recorder(lambda **kw: []), ), ) pmap = ProjectMapping(index=index) pmap.search(query) assert index.es.search.calls == [ pretend.call(index="warehouse", doc_type="project", body=body), ]
def test_get_mapping(): pmap = ProjectMapping(index=pretend.stub()) assert pmap.get_mapping() == { "properties": { "name": { "type": "string" }, "name_keyword": { "type": "string", "index": "not_analyzed" }, "version": { "type": "string" }, "author": { "type": "string" }, "author_email": { "type": "string" }, "maintainer": { "type": "string" }, "maintainer_email": { "type": "string" }, "home_page": { "type": "string" }, "license": { "type": "string" }, "summary": { "type": "string" }, "description": { "type": "string" }, "keywords": { "type": "string" }, "platform": { "type": "string" }, "download_url": { "type": "string" }, "created": { "type": "string" }, }, }
def test_search(query, body): index = pretend.stub( _index="warehouse", es=pretend.stub( search=pretend.call_recorder(lambda **kw: []), ), ) pmap = ProjectMapping(index=index) pmap.search(query) assert index.es.search.calls == [ pretend.call(index="warehouse", doc_type="project", body=body), ]
def test_get_mapping(): pmap = ProjectMapping(index=pretend.stub()) assert pmap.get_mapping() == { "properties": { "name": {"type": "string"}, "name_keyword": {"type": "string", "index": "not_analyzed"}, "version": {"type": "string"}, "author": {"type": "string"}, "author_email": {"type": "string"}, "maintainer": {"type": "string"}, "maintainer_email": {"type": "string"}, "home_page": {"type": "string"}, "license": {"type": "string"}, "summary": {"type": "string"}, "description": {"type": "string"}, "keywords": {"type": "string"}, "platform": {"type": "string"}, "download_url": {"type": "string"}, "created": {"type": "string"}, }, }
def test_extract_document(): pmap = ProjectMapping(index=pretend.stub()) document = pmap.extract_document({"name": "Test Name"}) assert document == {"name": "Test Name", "name_keyword": "test name"}
def test_extract_id(): pmap = ProjectMapping(index=pretend.stub()) assert pmap.extract_id({"name": "test name"}) == "test name"