Exemple #1
0
def test_large_negative_list():
    large_list = _large_naics_list("")
    assert NaicsCodes._query_string(
        require=[], exclude=large_list) == " AND ".join([
            NaicsCodes._query_string(require=[], exclude=[f"{i}"])
            for i in range(10, 100, 5)
        ])
Exemple #2
0
def test_three_layer_naics():
    assert (NaicsCodes._query_string(
        require=["11", "112233"],
        exclude=["1122"]) == "((11*) AND (((NOT 1122*) OR (((112233))))))")
Exemple #3
0
def test_primative_negative_naics_filter():
    assert NaicsCodes._query_string(require=[],
                                    exclude=["11"]) == "((NOT 11*))"
Exemple #4
0
def test_duplicate_positive_naics():
    assert NaicsCodes._query_string(require=["11", "11"],
                                    exclude=[]) == "((11*)) OR ((11*))"
Exemple #5
0
def test_duplicate_negative_naics():
    assert NaicsCodes._query_string(
        require=[], exclude=["11", "11"]) == "((NOT 11*)) AND ((NOT 11*))"
Exemple #6
0
def test_positive_uncle_naics():
    assert NaicsCodes._query_string(require=["11", "2211"],
                                    exclude=[]) == "((11*)) OR ((2211*))"
Exemple #7
0
def test_competing_naics():
    assert NaicsCodes._query_string(require=["11"],
                                    exclude=["11"
                                             ]) == "((11*)) AND ((NOT 11*))"
Exemple #8
0
def test_simple_negative_hierarchy():
    assert NaicsCodes._query_string(
        require=[], exclude=["11", "1111"]) == "((NOT 11*) OR (((NOT 1111*))))"
Exemple #9
0
def test_negative_to_positive_cross_hierarchy():
    assert NaicsCodes._query_string(require=["1111"],
                                    exclude=["11"
                                             ]) == "((NOT 11*) OR (((1111*))))"
Exemple #10
0
def test_simple_positive_hierarchy():
    assert NaicsCodes._query_string(require=["11", "1111"],
                                    exclude=[]) == "((11*) AND (((1111*))))"
Exemple #11
0
def test_two_negative_sibling_naics():
    assert NaicsCodes._query_string(
        require=[], exclude=["11", "22"]) == "((NOT 11*)) AND ((NOT 22*))"
Exemple #12
0
def test_two_positive_sibling_naics():
    assert NaicsCodes._query_string(require=["11", "22"],
                                    exclude=[]) == "((11*)) OR ((22*))"
Exemple #13
0
def test_negative_leaf_naics_filter():
    assert NaicsCodes._query_string(require=[],
                                    exclude=["112233"]) == "((NOT 112233))"
Exemple #14
0
def test_bad_exclude_naics():
    with raises(InvalidParameterException):
        NaicsCodes.generate_elasticsearch_query({"exclude": ["111"]}, None)