"""
Unit tests for module `homework_1.tasks.task_3`.
"""

from tempfile import NamedTemporaryFile
from typing import Tuple

import pytest

from homework_1.tasks.task_3 import find_maximum_and_minimum


@pytest.mark.parametrize(
    ["file_content", "expected_result"],
    [
        pytest.param(
            "0\n",
            (0, 0),
            id="'0\n', result is (0, 0).",
        ),
        pytest.param(
            "1\n2\n3\n4\n5\n",
            (1, 5),
            id="'1\n2\n3\n4\n5\n', result is (1, 5).",
        ),
        pytest.param(
            "1\n-2\n3\n-4\n5\n-6\n7\n-8\n9\n-10\n11\n-12\n",
            (-12, 11),
            id="'1\n-2\n3\n-4\n5\n-6\n7\n-8\n9\n-10\n11\n-12\n', result: (11,-12).",
        ),
        pytest.param(
            "11\n-12\n3\n-4\n5\n-6\n7\n-8\n9\n-10\n1\n-2\n",
            (-12, 11),
            id="'11\n-12\n3\n-4\n5\n-6\n7\n-8\n9\n-10\n1\n-2\n', result: (11,-12).",
        ),
        pytest.param(
            "\n".join(str(num) for num in range(0, 667000)),
            (0, 666999),
            id="Integers from 0 to 666999 delimited by '\n'.",
        ),
    ],
)
def test_find_maximum_and_minimum(file_content: str, expected_result: Tuple[int, int]):
    """
    Mocks file using `NamedTemporaryFile` instance with writed
    `file_content` inside, where `file_name` == `file.name`.

    Passes test if `find_maximum_and_minimum`(`file.name`)
    is equal to `expected_result`.
    """
    with NamedTemporaryFile(mode="wt") as file:
        file.write(file_content)
        file.seek(0)
        assert find_maximum_and_minimum(file.name) == expected_result

[((1456, 1485), 'tempfile.NamedTemporaryFile', 'NamedTemporaryFile', ([], {'mode': '"""wt"""'}), "(mode='wt')\n", (1474, 1485), False, 'from tempfile import NamedTemporaryFile\n'), ((283, 344), 'pytest.param', 'pytest.param', (['"""0\n"""', '(0, 0)'], {'id': '"""\'0\n\', result is (0, 0)."""'}), '(\'0\\n\', (0, 0), id="""\'0\n\', result is (0, 0).""")\n', (295, 344), False, 'import pytest\n'), ((398, 484), 'pytest.param', 'pytest.param', (['"""1\n2\n3\n4\n5\n"""', '(1, 5)'], {'id': '"""\'1\n2\n3\n4\n5\n\', result is (1, 5)."""'}), '(\'1\\n2\\n3\\n4\\n5\\n\', (1, 5), id=\n    """\'1\n2\n3\n4\n5\n\', result is (1, 5).""")\n', (410, 484), False, 'import pytest\n'), ((537, 671), 'pytest.param', 'pytest.param', (['"""1\n-2\n3\n-4\n5\n-6\n7\n-8\n9\n-10\n11\n-12\n"""', '(-12, 11)'], {'id': '"""\'1\n-2\n3\n-4\n5\n-6\n7\n-8\n9\n-10\n11\n-12\n\', result: (11,-12)."""'}), '("""1\n-2\n3\n-4\n5\n-6\n7\n-8\n9\n-10\n11\n-12\n""", (-12, 11), id=\n    """\'1\n-2\n3\n-4\n5\n-6\n7\n-8\n9\n-10\n11\n-12\n\', result: (11,-12).""")\n', (549, 671), False, 'import pytest\n'), ((739, 873), 'pytest.param', 'pytest.param', (['"""11\n-12\n3\n-4\n5\n-6\n7\n-8\n9\n-10\n1\n-2\n"""', '(-12, 11)'], {'id': '"""\'11\n-12\n3\n-4\n5\n-6\n7\n-8\n9\n-10\n1\n-2\n\', result: (11,-12)."""'}), '("""11\n-12\n3\n-4\n5\n-6\n7\n-8\n9\n-10\n1\n-2\n""", (-12, 11), id=\n    """\'11\n-12\n3\n-4\n5\n-6\n7\n-8\n9\n-10\n1\n-2\n\', result: (11,-12).""")\n', (751, 873), False, 'import pytest\n'), ((1564, 1599), 'homework_1.tasks.task_3.find_maximum_and_minimum', 'find_maximum_and_minimum', (['file.name'], {}), '(file.name)\n', (1588, 1599), False, 'from homework_1.tasks.task_3 import find_maximum_and_minimum\n')]