# Path: foil/filesys.py
# def file_exists(file_path):
#     """Check if the full file path exists."""
# 
#     try:
#         with open(file_path, 'r'):
#             return True
#     except IOError:
#         raise FileExistsError
# 
# def ensure_file_directory(file_path: str):
#     """Ensure that a directory path exists."""
# 
#     ensure_directory(os.path.dirname(file_path))


import os
import shutil
import unittest
from tempfile import NamedTemporaryFile, mkdtemp
from uuid import uuid4
from foil.filesys import file_exists, ensure_file_directory



class TestFileExists(unittest.TestCase):

    def setUp(self):
        with NamedTemporaryFile(prefix='mocke_', suffix='.txt',
                                delete=False) as tmp:
            with open(tmp.name, 'w') as fp:
                fp.write('121XZTT')

        self.tmp_path = tmp.name

    def test_file_exists(self):
        self.assertTrue(file_exists(self.tmp_path))

    def test_not_exists(self):
        file_name = str(uuid4()) + '.txt'

        with self.assertRaises(FileExistsError):

# Path: foil/filesys.py
# def file_exists(file_path):
#     """Check if the full file path exists."""
# 
#     try:
#         with open(file_path, 'r'):
#             return True
#     except IOError:
#         raise FileExistsError
# 
# def ensure_file_directory(file_path: str):
#     """Ensure that a directory path exists."""
# 
#     ensure_directory(os.path.dirname(file_path))


# Path: tests/test_filesys.py
import os
import shutil
import unittest
from tempfile import NamedTemporaryFile, mkdtemp
from uuid import uuid4
from foil.filesys import file_exists, ensure_file_directory




class TestFileExists(unittest.TestCase):

    def setUp(self):
        with NamedTemporaryFile(prefix='mocke_', suffix='.txt',
                                delete=False) as tmp:
            with open(tmp.name, 'w') as fp:
                fp.write('121XZTT')

        self.tmp_path = tmp.name

    def test_file_exists(self):
        self.assertTrue(file_exists(self.tmp_path))

    def test_not_exists(self):
        file_name = str(uuid4()) + '.txt'

        with self.assertRaises(FileExistsError):

            file_exists(file_name)