# Path: birdy/client/converters.py
# class BaseConverter(object):  # noqa: D101
# class GenericConverter(BaseConverter):  # noqa: D101
# class TextConverter(BaseConverter):  # noqa: D101
# class JSONConverter(BaseConverter):  # noqa: D101
# class GeoJSONConverter(BaseConverter):  # noqa: D101
# class MetalinkConverter(BaseConverter):  # noqa: D101
# class Netcdf4Converter(BaseConverter):  # noqa: D101
# class XarrayConverter(BaseConverter):  # noqa: D101
# class ShpFionaConverter(BaseConverter):  # noqa: D101
# class ShpOgrConverter(BaseConverter):  # noqa: D101
# class ImageConverter(BaseConverter):  # noqa: D101
# class GeotiffRioxarrayConverter(BaseConverter):  # noqa: D101
# class GeotiffRasterioConverter(BaseConverter):  # noqa: D101
# class GeotiffGdalConverter(BaseConverter):  # noqa: D101
# class ZipConverter(BaseConverter):  # noqa: D101
#     def __init__(self, output=None, path=None, verify=True):
#     def file(self):
#     def data(self):
#     def check_dependencies(self):  # noqa: D102
#     def _check_import(self, name, package=None):
#     def convert(self):
#     def convert(self):
#     def convert(self):
#     def convert(self):  # noqa: D102
#     def check_dependencies(self):  # noqa: D102
#     def convert(self):  # noqa: D102
#     def check_dependencies(self):  # noqa: D102
#     def convert(self):  # noqa: D102
#     def check_dependencies(self):  # noqa: D102
#     def convert(self):  # noqa: D102
#     def check_dependencies(self):  # noqa: D102
#     def convert(self):  # noqa: D102
#     def check_dependencies(self):  # noqa: D102
#     def convert(self):  # noqa: D102
#     def check_dependencies(self):  # noqa: D102
#     def convert(self):  # noqa: D102
#     def check_dependencies(self):  # noqa: D102
#     def convert(self):  # noqa: D102
#     def check_dependencies(self):  # noqa: D102
#     def convert(self):  # noqa: D102
#     def check_dependencies(self):  # noqa: D102
#     def convert(self):  # noqa: D102
#     def check_dependencies(self):  # noqa: D102
#     def convert(self):  # noqa: D102
#     def convert(self):  # noqa: D102
# def _find_converter(mimetype=None, extension=None, converters=()):
# def find_converter(obj, converters):
# def convert(
#     output: Union[Output, Path, str],
#     path: Union[str, Path],
#     converters: Sequence[BaseConverter] = None,
#     verify: bool = True,
# ):
# def all_subclasses(cls):


import json
import os
import tempfile
import pytest
    import zipfile
from birdy.client import converters
def test_zipconverter():  # noqa: D103

    f = tempfile.mktemp(suffix=".zip")
    zf = zipfile.ZipFile(f, mode="w")

    a = tempfile.NamedTemporaryFile(mode="w", suffix=".json")
    a.write(json.dumps({"a": 1}))
    a.seek(0)

    b = tempfile.NamedTemporaryFile(mode="w", suffix=".csv")
    b.write("a, b, c\n1, 2, 3")
    b.seek(0)

    zf.write(a.name, arcname=os.path.split(a.name)[1])
    zf.write(b.name, arcname=os.path.split(b.name)[1])
    zf.close()

    [oa, ob] = converters.convert(f, path="/tmp", converters=[converters.ZipConverter])
    assert oa == {"a": 1}
    assert len(ob.splitlines()) == 2


def test_jpeg_imageconverter():  # noqa: D103
    # Note: Since the format is not supported, bytes will be returned
    fn = tempfile.mktemp(suffix=".jpeg")
    with open(fn, "w") as f:
        f.write(
            "jpeg.jpg JPEG 1x1 1x1+0+0 8-bit Grayscale Gray 256c 107B 0.000u 0:00.000"
        )


# Path: birdy/client/converters.py
# class BaseConverter(object):  # noqa: D101
# class GenericConverter(BaseConverter):  # noqa: D101
# class TextConverter(BaseConverter):  # noqa: D101
# class JSONConverter(BaseConverter):  # noqa: D101
# class GeoJSONConverter(BaseConverter):  # noqa: D101
# class MetalinkConverter(BaseConverter):  # noqa: D101
# class Netcdf4Converter(BaseConverter):  # noqa: D101
# class XarrayConverter(BaseConverter):  # noqa: D101
# class ShpFionaConverter(BaseConverter):  # noqa: D101
# class ShpOgrConverter(BaseConverter):  # noqa: D101
# class ImageConverter(BaseConverter):  # noqa: D101
# class GeotiffRioxarrayConverter(BaseConverter):  # noqa: D101
# class GeotiffRasterioConverter(BaseConverter):  # noqa: D101
# class GeotiffGdalConverter(BaseConverter):  # noqa: D101
# class ZipConverter(BaseConverter):  # noqa: D101
#     def __init__(self, output=None, path=None, verify=True):
#     def file(self):
#     def data(self):
#     def check_dependencies(self):  # noqa: D102
#     def _check_import(self, name, package=None):
#     def convert(self):
#     def convert(self):
#     def convert(self):
#     def convert(self):  # noqa: D102
#     def check_dependencies(self):  # noqa: D102
#     def convert(self):  # noqa: D102
#     def check_dependencies(self):  # noqa: D102
#     def convert(self):  # noqa: D102
#     def check_dependencies(self):  # noqa: D102
#     def convert(self):  # noqa: D102
#     def check_dependencies(self):  # noqa: D102
#     def convert(self):  # noqa: D102
#     def check_dependencies(self):  # noqa: D102
#     def convert(self):  # noqa: D102
#     def check_dependencies(self):  # noqa: D102
#     def convert(self):  # noqa: D102
#     def check_dependencies(self):  # noqa: D102
#     def convert(self):  # noqa: D102
#     def check_dependencies(self):  # noqa: D102
#     def convert(self):  # noqa: D102
#     def check_dependencies(self):  # noqa: D102
#     def convert(self):  # noqa: D102
#     def check_dependencies(self):  # noqa: D102
#     def convert(self):  # noqa: D102
#     def convert(self):  # noqa: D102
# def _find_converter(mimetype=None, extension=None, converters=()):
# def find_converter(obj, converters):
# def convert(
#     output: Union[Output, Path, str],
#     path: Union[str, Path],
#     converters: Sequence[BaseConverter] = None,
#     verify: bool = True,
# ):
# def all_subclasses(cls):


# Path: tests/test_converters.py
import json
import os
import tempfile
import pytest
    import zipfile
from birdy.client import converters

def test_zipconverter():  # noqa: D103

    f = tempfile.mktemp(suffix=".zip")
    zf = zipfile.ZipFile(f, mode="w")

    a = tempfile.NamedTemporaryFile(mode="w", suffix=".json")
    a.write(json.dumps({"a": 1}))
    a.seek(0)

    b = tempfile.NamedTemporaryFile(mode="w", suffix=".csv")
    b.write("a, b, c\n1, 2, 3")
    b.seek(0)

    zf.write(a.name, arcname=os.path.split(a.name)[1])
    zf.write(b.name, arcname=os.path.split(b.name)[1])
    zf.close()

    [oa, ob] = converters.convert(f, path="/tmp", converters=[converters.ZipConverter])
    assert oa == {"a": 1}
    assert len(ob.splitlines()) == 2


def test_jpeg_imageconverter():  # noqa: D103
    # Note: Since the format is not supported, bytes will be returned
    fn = tempfile.mktemp(suffix=".jpeg")
    with open(fn, "w") as f:
        f.write(
            "jpeg.jpg JPEG 1x1 1x1+0+0 8-bit Grayscale Gray 256c 107B 0.000u 0:00.000"
        )


    b = converters.convert(fn, path="/tmp")