# Path: wtframework/wtf/utils/data_utils.py
# def generate_timestamped_string(subject="test", number_of_random_chars=4):
#     """
#     Generate time-stamped string. Format as follows...
# 
#     `2013-01-31_14:12:23_SubjectString_a3Zg`
# 
# 
#     Kwargs:
#         subject (str): String to use as subject.
#         number_of_random_chars (int) : Number of random characters to append.
# 
# 
#     This method is helpful for creating unique names with timestamps in them so 
#     when you have to troubleshoot an issue, the name is easier to find.::
# 
#         self.project_name = generate_timestamped_string("project")
#         new_project_page.create_project(project_name)
# 
#     """
#     random_str = generate_random_string(number_of_random_chars)
#     timestamp = generate_timestamp()
#     return u"{timestamp}_{subject}_{random_str}".format(timestamp=timestamp,
#                                                         subject=subject,
#                                                         random_str=random_str)
# 
# def generate_timestamp(date_format="%Y-%m-%d_%H.%M.%S"):
#     """
#     Returns timestamped string. '2012-03-15_14:42:23
# 
#     Kwargs:
#         format: A date/time format string.  If not specified, the default will be used.
# 
#     """
#     return datetime.now().strftime(date_format)
# 
# def generate_random_string(number_of_random_chars=8, character_set=string.ascii_letters):
#     """
#     Generate a series of random characters.
# 
#     Kwargs:
#         number_of_random_chars (int) : Number of characters long
#         character_set (str): Specify a character set.  Default is ASCII
#     """
#     return u('').join(random.choice(character_set)
#                       for _ in range(number_of_random_chars))


from wtframework.wtf.utils.data_utils import generate_timestamped_string, \
    generate_timestamp, generate_random_string
import re
import unittest2
#    WTFramework is free software: you can redistribute it and/or modify
#    it under the terms of the GNU General Public License as published by
#    the Free Software Foundation, either version 3 of the License, or
#    (at your option) any later version.
#
#    WTFramework is distributed in the hope that it will be useful,
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#    GNU General Public License for more details.
#
#    You should have received a copy of the GNU General Public License
#    along with WTFramework.  If not, see <http://www.gnu.org/licenses/>.
##########################################################################



class TestDataUtils(unittest2.TestCase):

    def test_generateTimeStampedString(self):
        ts_string = generate_timestamped_string("TEST", 5)
        self.assertTrue(
            len(re.findall(r'^\d{4}-\d{2}-\d{2}_\d{2}\.\d{2}\.\d{2}_TEST_.{5}$', ts_string)) == 1)

    def test_generate_timestamp(self):
        ts_string = generate_timestamp()
        self.assertTrue(
            len(re.findall(r'^\d{4}-\d{2}-\d{2}_\d{2}\.\d{2}\.\d{2}$', ts_string)) == 1)

    def test_generate_randome_string(self):
        random = generate_random_string(16)

# Path: wtframework/wtf/utils/data_utils.py
# def generate_timestamped_string(subject="test", number_of_random_chars=4):
#     """
#     Generate time-stamped string. Format as follows...
# 
#     `2013-01-31_14:12:23_SubjectString_a3Zg`
# 
# 
#     Kwargs:
#         subject (str): String to use as subject.
#         number_of_random_chars (int) : Number of random characters to append.
# 
# 
#     This method is helpful for creating unique names with timestamps in them so 
#     when you have to troubleshoot an issue, the name is easier to find.::
# 
#         self.project_name = generate_timestamped_string("project")
#         new_project_page.create_project(project_name)
# 
#     """
#     random_str = generate_random_string(number_of_random_chars)
#     timestamp = generate_timestamp()
#     return u"{timestamp}_{subject}_{random_str}".format(timestamp=timestamp,
#                                                         subject=subject,
#                                                         random_str=random_str)
# 
# def generate_timestamp(date_format="%Y-%m-%d_%H.%M.%S"):
#     """
#     Returns timestamped string. '2012-03-15_14:42:23
# 
#     Kwargs:
#         format: A date/time format string.  If not specified, the default will be used.
# 
#     """
#     return datetime.now().strftime(date_format)
# 
# def generate_random_string(number_of_random_chars=8, character_set=string.ascii_letters):
#     """
#     Generate a series of random characters.
# 
#     Kwargs:
#         number_of_random_chars (int) : Number of characters long
#         character_set (str): Specify a character set.  Default is ASCII
#     """
#     return u('').join(random.choice(character_set)
#                       for _ in range(number_of_random_chars))


# Path: wtframework/wtf/utils/tests/test_data_utils.py
from wtframework.wtf.utils.data_utils import generate_timestamped_string, \
    generate_timestamp, generate_random_string
import re
import unittest2

#    WTFramework is free software: you can redistribute it and/or modify
#    it under the terms of the GNU General Public License as published by
#    the Free Software Foundation, either version 3 of the License, or
#    (at your option) any later version.
#
#    WTFramework is distributed in the hope that it will be useful,
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#    GNU General Public License for more details.
#
#    You should have received a copy of the GNU General Public License
#    along with WTFramework.  If not, see <http://www.gnu.org/licenses/>.
##########################################################################



class TestDataUtils(unittest2.TestCase):

    def test_generateTimeStampedString(self):
        ts_string = generate_timestamped_string("TEST", 5)
        self.assertTrue(
            len(re.findall(r'^\d{4}-\d{2}-\d{2}_\d{2}\.\d{2}\.\d{2}_TEST_.{5}$', ts_string)) == 1)

    def test_generate_timestamp(self):
        ts_string = generate_timestamp()
        self.assertTrue(
            len(re.findall(r'^\d{4}-\d{2}-\d{2}_\d{2}\.\d{2}\.\d{2}$', ts_string)) == 1)

    def test_generate_randome_string(self):
        random = generate_random_string(16)

        self.assertEqual(16, len(random))