# Path: snakemakelib/stat.py
# def is_installed(prog):
#     if not shutil.which(prog) is None:
#         return True
#     if os.path.exists(prog):
#         return True
#     return False
# 
# Path: snakemakelib/utils.py
# def isoformat(s=None):
#     """Return isoformat date from string"""
#     if s is None:
#         return
#     # Assume YYMMDD format
#     if len(s) == 6:
#         (YY, MM, DD) = (s[0:2], s[2:4], s[4:6])
#         return date(int("20{YY}".format(YY=YY)), int(MM.lstrip("0")), int(DD)).isoformat()


import unittest
from snakemakelib.stat import is_installed
from snakemakelib.utils import isoformat
# Copyright (C) 2014 by Per Unneberg
# pylint: disable=R0904, C0301, C0103

class TestUtils(unittest.TestCase):
    """Test snakemakelib.utils functions"""
    def test_isoformat(self):
        """Test isoformatting function"""
        s = "120924"
        self.assertEqual(isoformat(s), "2012-09-24")

class TestStat(unittest.TestCase):
    """Test snakemakelib.stat functions"""
    def test_is_installed(self):
        """Test function for checking that program is installed or that path exists"""
        self.assertTrue (is_installed("ls"))
        self.assertTrue(is_installed("/bin/ls"))

# Path: snakemakelib/stat.py
# def is_installed(prog):
#     if not shutil.which(prog) is None:
#         return True
#     if os.path.exists(prog):
#         return True
#     return False
# 
# Path: snakemakelib/utils.py
# def isoformat(s=None):
#     """Return isoformat date from string"""
#     if s is None:
#         return
#     # Assume YYMMDD format
#     if len(s) == 6:
#         (YY, MM, DD) = (s[0:2], s[2:4], s[4:6])
#         return date(int("20{YY}".format(YY=YY)), int(MM.lstrip("0")), int(DD)).isoformat()


# Path: snakemakelib/tests/test_utils.py
import unittest
from snakemakelib.stat import is_installed
from snakemakelib.utils import isoformat

# Copyright (C) 2014 by Per Unneberg
# pylint: disable=R0904, C0301, C0103

class TestUtils(unittest.TestCase):
    """Test snakemakelib.utils functions"""
    def test_isoformat(self):
        """Test isoformatting function"""
        s = "120924"
        self.assertEqual(isoformat(s), "2012-09-24")

class TestStat(unittest.TestCase):
    """Test snakemakelib.stat functions"""
    def test_is_installed(self):
        """Test function for checking that program is installed or that path exists"""
        self.assertTrue (is_installed("ls"))
        self.assertTrue(is_installed("/bin/ls"))

        self.assertTrue(is_installed("/bin"))