# Path: lepo/apidef/doc.py
# class Swagger2APIDefinition(APIDefinition):
#     version = SWAGGER_2
#     operation_class = Swagger2Operation
# 
# Path: lepo/parameter_utils.py
# def cast_primitive_value(type, format, value):
#     if type == 'boolean':
#         return (force_str(value).lower() in ('1', 'yes', 'true'))
#     if type == 'integer' or format in ('integer', 'long'):
#         return int(value)
#     if type == 'number' or format in ('float', 'double'):
#         return float(value)
#     if format == 'byte':  # base64 encoded characters
#         return base64.b64decode(value)
#     if format == 'binary':  # any sequence of octets
#         return force_bytes(value)
#     if format == 'date':  # ISO8601 date
#         return iso8601.parse_date(value).date()
#     if format == 'dateTime':  # ISO8601 datetime
#         return iso8601.parse_date(value)
#     if type == 'string':
#         return force_str(value)
#     return value
# 
# Path: lepo_tests/tests/utils.py
# TESTS_DIR = os.path.dirname(__file__)
# DOC_VERSIONS = ['swagger2', 'openapi3']
# def get_router(fixture_name):
# def get_data_from_response(response, status=200):
# def cast_parameter_value(apidoc, parameter, value):
# def get_apidoc_from_version(version, content={}):
# def make_request_for_operation(operation, method='GET', query_string=''):


from collections import namedtuple
from datetime import date, datetime
from iso8601 import UTC
from lepo.apidef.doc import Swagger2APIDefinition
from lepo.parameter_utils import cast_primitive_value
from lepo_tests.tests.utils import (
    cast_parameter_value,
    doc_versions,
    get_apidoc_from_version,
)
import pytest
@pytest.mark.parametrize('case', DATA_EXAMPLES)
def test_data(case):
    spec = case['spec']
    type = spec.get('type')
    format = spec.get('format')
    parsed = cast_primitive_value(type, format, case['input'])
    assert parsed == case['output']


Case = namedtuple('Case', 'swagger2_schema openapi3_schema input expected')

collection_format_cases = [
    Case(
        {'type': 'array', 'collectionFormat': 'tsv', 'items': {'type': 'boolean'}},
        None,  # TSV does not exist in OpenAPI 3
        'true\ttrue\tfalse',
        [True, True, False],
    ),
    Case(
        {'type': 'array', 'collectionFormat': 'ssv', 'items': {'type': 'string'}},
        None,
        'what it do',
        ['what', 'it', 'do'],
    ),
    Case(
        {
            'type': 'array',
            'collectionFormat': 'pipes',
            'items': {
                'type': 'array',

# Path: lepo/apidef/doc.py
# class Swagger2APIDefinition(APIDefinition):
#     version = SWAGGER_2
#     operation_class = Swagger2Operation
# 
# Path: lepo/parameter_utils.py
# def cast_primitive_value(type, format, value):
#     if type == 'boolean':
#         return (force_str(value).lower() in ('1', 'yes', 'true'))
#     if type == 'integer' or format in ('integer', 'long'):
#         return int(value)
#     if type == 'number' or format in ('float', 'double'):
#         return float(value)
#     if format == 'byte':  # base64 encoded characters
#         return base64.b64decode(value)
#     if format == 'binary':  # any sequence of octets
#         return force_bytes(value)
#     if format == 'date':  # ISO8601 date
#         return iso8601.parse_date(value).date()
#     if format == 'dateTime':  # ISO8601 datetime
#         return iso8601.parse_date(value)
#     if type == 'string':
#         return force_str(value)
#     return value
# 
# Path: lepo_tests/tests/utils.py
# TESTS_DIR = os.path.dirname(__file__)
# DOC_VERSIONS = ['swagger2', 'openapi3']
# def get_router(fixture_name):
# def get_data_from_response(response, status=200):
# def cast_parameter_value(apidoc, parameter, value):
# def get_apidoc_from_version(version, content={}):
# def make_request_for_operation(operation, method='GET', query_string=''):


# Path: lepo_tests/tests/test_datatypes.py
from collections import namedtuple
from datetime import date, datetime
from iso8601 import UTC
from lepo.apidef.doc import Swagger2APIDefinition
from lepo.parameter_utils import cast_primitive_value
from lepo_tests.tests.utils import (
    cast_parameter_value,
    doc_versions,
    get_apidoc_from_version,
)
import pytest

@pytest.mark.parametrize('case', DATA_EXAMPLES)
def test_data(case):
    spec = case['spec']
    type = spec.get('type')
    format = spec.get('format')
    parsed = cast_primitive_value(type, format, case['input'])
    assert parsed == case['output']


Case = namedtuple('Case', 'swagger2_schema openapi3_schema input expected')

collection_format_cases = [
    Case(
        {'type': 'array', 'collectionFormat': 'tsv', 'items': {'type': 'boolean'}},
        None,  # TSV does not exist in OpenAPI 3
        'true\ttrue\tfalse',
        [True, True, False],
    ),
    Case(
        {'type': 'array', 'collectionFormat': 'ssv', 'items': {'type': 'string'}},
        None,
        'what it do',
        ['what', 'it', 'do'],
    ),
    Case(
        {
            'type': 'array',
            'collectionFormat': 'pipes',
            'items': {
                'type': 'array',

                'items': {