# Path: django_performance_testing/queries.py
# def classify_query(sql):
#     if sql.startswith('QUERY ='):  # django 1.8
#         without_query_prefix = sql.split(' = ')[1]
#     else:
#         without_query_prefix = sql
# 
#     first_token = without_query_prefix.split(' ')[0]
#     pattern = '\''
#     if pattern in first_token:
#         query_type_token = first_token.split(pattern)[1]
#     else:
#         query_type_token = first_token
#     return _query_token_to_classification.get(query_type_token, 'other')


import pytest
from django_performance_testing.queries import classify_query


@pytest.mark.parametrize('sql', [
    'QUERY = u\'SELECT "auth_group"."id", "auth_group"."name" FROM "auth_group"\' - PARAMS = ()',  # noqa
    'QUERY = \'SELECT "auth_group"."id", "auth_group"."name" FROM "auth_group"\' - PARAMS = ()',  # noqa
], ids=['py2', 'py3'])
def test_can_classify_select(sql):

# Path: django_performance_testing/queries.py
# def classify_query(sql):
#     if sql.startswith('QUERY ='):  # django 1.8
#         without_query_prefix = sql.split(' = ')[1]
#     else:
#         without_query_prefix = sql
# 
#     first_token = without_query_prefix.split(' ')[0]
#     pattern = '\''
#     if pattern in first_token:
#         query_type_token = first_token.split(pattern)[1]
#     else:
#         query_type_token = first_token
#     return _query_token_to_classification.get(query_type_token, 'other')


# Path: tests/testapp/tests/test_can_classify_queries_into_read_and_write_other.py
import pytest
from django_performance_testing.queries import classify_query



@pytest.mark.parametrize('sql', [
    'QUERY = u\'SELECT "auth_group"."id", "auth_group"."name" FROM "auth_group"\' - PARAMS = ()',  # noqa
    'QUERY = \'SELECT "auth_group"."id", "auth_group"."name" FROM "auth_group"\' - PARAMS = ()',  # noqa
], ids=['py2', 'py3'])
def test_can_classify_select(sql):

    assert 'read' == classify_query(sql)