from pathlib import Path


def test_dir(tmpdir_factory):
    """
    Creates the directory structure in the temporary test directory for the
    various tests

    Args:
        tmpdir_factory (tmpdir_factory): Defined in pytest to make a temporary
            directory

    Returns:
        object: Holds the various paths created as object attributes
    """
    base_path = Path(tmpdir_factory.getbasetemp())

    class TestPaths:
        """
        Holds the paths created as attributes
        """

        class VivadoPaths:
            """
            Vivado paths are used to test the vivado initialization function
            """

            non_existent = base_path.joinpath("DOES_NOT_EXIST")
            no_vivado = base_path.joinpath("Xilinx")
            one_vivado = base_path.joinpath("Xilinx/Xilinx_1")
            many_vivado = base_path.joinpath("Xilinx/Xilinx_2")

        class RepoPaths:
            """
            Used to test creating repositories
            """

            repo_base_path = base_path.joinpath("repos")
            valid = repo_base_path.joinpath("valid")

        class Testbench:
            """
            Testbench tests
            """

            testbench = base_path.joinpath("testbench")
            hello_world = testbench.joinpath("hello_world")
            ethernet = testbench.joinpath("ethernet")

        class Shell:
            """
            Shell tests
            """

            shell = base_path.joinpath("shell")
            hello_world = shell.joinpath("hello_world")
            ethernet = shell.joinpath("ethernet")

        vivado = VivadoPaths()
        repos = RepoPaths()
        testbench = Testbench()
        shell = Shell()
        base = base_path

    one_vivado = TestPaths.vivado.one_vivado.joinpath("Vivado/2017.2")
    two_vivado_0 = TestPaths.vivado.many_vivado.joinpath("Vivado/2017.3")
    two_vivado_1 = TestPaths.vivado.many_vivado.joinpath("Vivado/2018.2")

    one_vivado.mkdir(parents=True)
    two_vivado_0.mkdir(parents=True)
    two_vivado_1.mkdir(parents=True)

    TestPaths.repos.valid.mkdir(parents=True)

    TestPaths.testbench.hello_world.mkdir(parents=True)
    TestPaths.testbench.ethernet.mkdir(parents=True)

    TestPaths.shell.hello_world.mkdir(parents=True)
    TestPaths.shell.ethernet.mkdir(parents=True)

    return TestPaths