Example #1
0
def test_cluster_query_from_term_expression():
    term = QueryTerm('expression', category='type', term='lantipeptide')
    ret = search.cluster_query_from_term(term)
    assert ret.count() == 3

    term.category = 'unknown'
    ret = search.cluster_query_from_term(term)
    assert ret.count() == 3

    term.category = 'type'
    term.term = 'bogus'
    ret = search.cluster_query_from_term(term)
    assert ret.count() == 0

    term.category = 'bogus'
    ret = search.cluster_query_from_term(term)
    assert ret.count() == 0
Example #2
0
def test_cluster_query_from_term_expression():
    term = QueryTerm('expression', category='type', term='lantipeptide')
    ret = search.cluster_query_from_term(term)
    assert ret.count() == 6

    term.category = 'unknown'
    ret = search.cluster_query_from_term(term)
    assert ret.count() == 6

    term.category = 'type'
    term.term = 'bogus'
    ret = search.cluster_query_from_term(term)
    assert ret.count() == 0

    term.category = 'bogus'
    ret = search.cluster_query_from_term(term)
    assert ret.count() == 0
Example #3
0
def test_cluster_query_from_term_operation():
    left = QueryTerm('expression', category='type', term='lantipeptide')
    right = QueryTerm('expression', category='genus', term='Streptomyces')
    term = QueryTerm('operation', operation='and', left=left, right=right)

    ret = search.cluster_query_from_term(term)
    assert ret.count() == 3

    term.operation = 'or'
    ret = search.cluster_query_from_term(term)
    assert ret.count() == 29

    term.operation = 'except'
    ret = search.cluster_query_from_term(term)
    assert ret.count() == 0

    left.category = 'bogus'
    term.operation = 'and'
    ret = search.cluster_query_from_term(term)
    assert ret.count() == 0

    term.operation = 'or'
    ret = search.cluster_query_from_term(term)
    assert ret.count() == 29

    term.operation = 'except'
    ret = search.cluster_query_from_term(term)
    assert ret.count() == 0

    left.category = 'type'
    right.category = 'bogus'
    term.operation = 'and'
    ret = search.cluster_query_from_term(term)
    assert ret.count() == 0

    term.operation = 'or'
    ret = search.cluster_query_from_term(term)
    assert ret.count() == 3

    term.operation = 'except'
    ret = search.cluster_query_from_term(term)
    assert ret.count() == 3
Example #4
0
def test_cluster_query_from_term_operation():
    left = QueryTerm('expression', category='type', term='lantipeptide')
    right = QueryTerm('expression', category='genus', term='Streptomyces')
    term = QueryTerm('operation', operation='and', left=left, right=right)

    ret = search.cluster_query_from_term(term)
    assert ret.count() == 6

    term.operation = 'or'
    ret = search.cluster_query_from_term(term)
    assert ret.count() == 120

    term.operation = 'except'
    ret = search.cluster_query_from_term(term)
    assert ret.count() == 0

    left.category = 'bogus'
    term.operation = 'and'
    ret = search.cluster_query_from_term(term)
    assert ret.count() == 0

    term.operation = 'or'
    ret = search.cluster_query_from_term(term)
    assert ret.count() == 120

    term.operation = 'except'
    ret = search.cluster_query_from_term(term)
    assert ret.count() == 0

    left.category = 'type'
    right.category = 'bogus'
    term.operation = 'and'
    ret = search.cluster_query_from_term(term)
    assert ret.count() == 0

    term.operation = 'or'
    ret = search.cluster_query_from_term(term)
    assert ret.count() == 6

    term.operation = 'except'
    ret = search.cluster_query_from_term(term)
    assert ret.count() == 6