from pathlib import Path

import pytest

from batch_relpath import __author__, __email__, __license__, __version__
from batch_relpath.relpath import BatchRelpath


def test_version() -> None:
    """Test the version number."""
    assert __version__ == "1.1.3"


def test_author() -> None:
    """Test the author."""
    assert __author__ == "<NAME>"


def test_email() -> None:
    """Test the email."""
    assert __email__ == "<EMAIL>"


def test_license() -> None:
    """Test the license."""
    assert __license__ == "MIT"


class TestBatchRelpath:
    def test_unknown_path(self, tmp_path: Path) -> None:
        """Test to see if BatchRelpath will recognize a path which doesn't
        exist and throw an appropriate exception.

        Args:
            tmp_path (Path): A temporary directory.
        """
        path = tmp_path.joinpath("does_not_exist")

        with pytest.raises(IOError):
            BatchRelpath([path], tmp_path)

    def test_same_dir(self, tmp_path: Path) -> None:
        """Test handling of same directory paths. The output should be
        the same as other Linux tools which use "." to represent same
        directory paths.

        Args:
            tmp_path (Path): A temporary directory.
        """
        result = BatchRelpath([tmp_path], tmp_path)

        assert str(result) == "."

    def test_start(self, tmp_path: Path) -> None:
        """Test for correct relative path to multiple paths from a
        starting position, as well as returning the correct number of
        results.
        """
        path_1 = tmp_path.joinpath("one/")
        path_2 = tmp_path.joinpath("two/")
        path_3 = tmp_path.joinpath("three/")

        paths = [path_1, path_2, path_3]
        for p in paths:
            p.mkdir()

        result = BatchRelpath(paths, tmp_path)

        assert str(result) == "one\ntwo\nthree"
        assert len(str(result).splitlines()) == 3

    def test_file_path(self, tmp_path: Path) -> None:
        """Test handling of file path as an argument for both the given
        path and the start.

        Args:
            tmp_path (Path): A temporary directory.
        """
        new_file = tmp_path.joinpath("file.txt")
        with open(new_file, "w") as f:
            f.write("\n")

        result = BatchRelpath([new_file], tmp_path)

        assert str(result) == "file.txt"

        result = BatchRelpath([tmp_path], new_file)

        assert str(result) == "."

from pathlib import Path

import pytest

from batch_relpath import __author__, __email__, __license__, __version__
from batch_relpath.relpath import BatchRelpath


def test_version() -> None:
    """Test the version number."""
    assert __version__ == "1.1.3"


def test_author() -> None:
    """Test the author."""
    assert __author__ == "<NAME>"


def test_email() -> None:
    """Test the email."""
    assert __email__ == "<EMAIL>"


def test_license() -> None:
    """Test the license."""
    assert __license__ == "MIT"


class TestBatchRelpath:
    def test_unknown_path(self, tmp_path: Path) -> None:
        """Test to see if BatchRelpath will recognize a path which doesn't
        exist and throw an appropriate exception.

        Args:
            tmp_path (Path): A temporary directory.
        """
        path = tmp_path.joinpath("does_not_exist")

        with pytest.raises(IOError):
            BatchRelpath([path], tmp_path)

    def test_same_dir(self, tmp_path: Path) -> None:
        """Test handling of same directory paths. The output should be
        the same as other Linux tools which use "." to represent same
        directory paths.

        Args:
            tmp_path (Path): A temporary directory.
        """
        result = BatchRelpath([tmp_path], tmp_path)

        assert str(result) == "."

    def test_start(self, tmp_path: Path) -> None:
        """Test for correct relative path to multiple paths from a
        starting position, as well as returning the correct number of
        results.
        """
        path_1 = tmp_path.joinpath("one/")
        path_2 = tmp_path.joinpath("two/")
        path_3 = tmp_path.joinpath("three/")

        paths = [path_1, path_2, path_3]
        for p in paths:
            p.mkdir()

        result = BatchRelpath(paths, tmp_path)

        assert str(result) == "one\ntwo\nthree"
        assert len(str(result).splitlines()) == 3

    def test_file_path(self, tmp_path: Path) -> None:
        """Test handling of file path as an argument for both the given
        path and the start.

        Args:
            tmp_path (Path): A temporary directory.
        """
        new_file = tmp_path.joinpath("file.txt")
        with open(new_file, "w") as f:
            f.write("\n")

        result = BatchRelpath([new_file], tmp_path)

        assert str(result) == "file.txt"

        result = BatchRelpath([tmp_path], new_file)

        assert str(result) == "."

Test the version number. Test the author. Test the email. Test the license. Test to see if BatchRelpath will recognize a path which doesn't         exist and throw an appropriate exception.          Args:             tmp_path (Path): A temporary directory. Test handling of same directory paths. The output should be         the same as other Linux tools which use "." to represent same         directory paths.          Args:             tmp_path (Path): A temporary directory. Test for correct relative path to multiple paths from a         starting position, as well as returning the correct number of         results. Test handling of file path as an argument for both the given         path and the start.          Args:             tmp_path (Path): A temporary directory.