示例#1
0
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()]
示例#2
0
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(),
    ]
示例#3
0
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),
    ]
示例#4
0
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"
            },
        },
    }
示例#5
0
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),
    ]
示例#6
0
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"},
        },
    }
示例#7
0
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"}
示例#8
0
def test_extract_id():
    pmap = ProjectMapping(index=pretend.stub())
    assert pmap.extract_id({"name": "test name"}) == "test name"
示例#9
0
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"}
示例#10
0
def test_extract_id():
    pmap = ProjectMapping(index=pretend.stub())
    assert pmap.extract_id({"name": "test name"}) == "test name"