def test_parse_set_query():
    # Dict of tuples of (query: expected_result)
    set_tests = {
        'foo=bar': [
            ('intersection', 'foo', 'bar'),
        ],
        'foo=bar owner=jathan': [
            ('intersection', 'foo', 'bar'),
            ('intersection', 'owner', 'jathan'),
        ],
        '-owner=gary': [
            ('difference', 'owner', 'gary'),
        ],
        'cluster +foo=baz': [
            ('intersection', 'cluster', ''),
            ('union', 'foo', 'baz'),
        ],
        # Extra white space
        'cluster=lax   +foo=baz': [
            ('intersection', 'cluster', 'lax'),
            ('union', 'foo', 'baz'),
        ],
        # Single-quoted value w/ a space in it
        "usage='Internal Network'": [
            ('intersection', 'usage', 'Internal Network'),
        ],
        # Double-quoted value w/ a space in it
        'usage="Internal Network"': [
            ('intersection', 'usage', 'Internal Network'),
        ],
    }

    # Make sure that result matches expected_result
    for query, expected_result in set_tests.iteritems():
        result = parse_set_query(query)
        assert result == expected_result

    # Test bogus stuff
    with pytest.raises(TypeError):
        parse_set_query(None)

    # Test a bad string
    with pytest.raises(ValueError):
        parse_set_query('foo="bar')  # Unbalanced quotes
Parse a bunch of set queries and make sure that the expected result
dataset/ETHPy150Open dropbox/nsot/tests/api_tests/test_util.py/test_parse_set_query