# Path: qpanel/convert.py
# def convert_time_when_param(value, splitter=','):
#     """ Convert string value to dict for time config for reset stats
#     value = daily,00:10:50 -> return {'when': 'daily', 'hour': '00:10:50'}
#     """
#     var = value.split(splitter)
#     hour = '00:00:00'
#     if len(var) > 1:
#         hour = var[1].strip()
#     try:
#         hour = time.strptime(hour, "%H:%M:%S")
#     except ValueError:
#         hour = time.strptime('00:00:00', "%H:%M:%S")
#     hour = time.strftime('%H:%M:%S', hour)
#     return {'when': var[0], 'hour': hour}


import unittest
from qpanel.convert import convert_time_when_param


class ConvertTestClass(unittest.TestCase):

    def test_convert_time_when_param(self):
        value = 'test1,00:00:00'
        self.assertEqual(convert_time_when_param(value),
                         {'when': 'test1', 'hour': '00:00:00'})

    def test_convert_time_without_hour(self):
        """ Should return a default hour in 00:00:00"""
        value = 'test1'
        self.assertEqual(convert_time_when_param(value),
                         {'when': 'test1', 'hour': '00:00:00'})

    def test_convert_time_first_second_hour(self):
        """ Should return a default hour in 00:00:01"""
        value = 'test1, 00:00:01'
        self.assertEqual(convert_time_when_param(value),
                         {'when': 'test1', 'hour': '00:00:01'})

    def test_convert_time_wrong_value_time(self):
        """ Should return a default hour"""
        value = 'test1, string_wrong'

# Path: qpanel/convert.py
# def convert_time_when_param(value, splitter=','):
#     """ Convert string value to dict for time config for reset stats
#     value = daily,00:10:50 -> return {'when': 'daily', 'hour': '00:10:50'}
#     """
#     var = value.split(splitter)
#     hour = '00:00:00'
#     if len(var) > 1:
#         hour = var[1].strip()
#     try:
#         hour = time.strptime(hour, "%H:%M:%S")
#     except ValueError:
#         hour = time.strptime('00:00:00', "%H:%M:%S")
#     hour = time.strftime('%H:%M:%S', hour)
#     return {'when': var[0], 'hour': hour}


# Path: tests/test_convert.py
import unittest
from qpanel.convert import convert_time_when_param



class ConvertTestClass(unittest.TestCase):

    def test_convert_time_when_param(self):
        value = 'test1,00:00:00'
        self.assertEqual(convert_time_when_param(value),
                         {'when': 'test1', 'hour': '00:00:00'})

    def test_convert_time_without_hour(self):
        """ Should return a default hour in 00:00:00"""
        value = 'test1'
        self.assertEqual(convert_time_when_param(value),
                         {'when': 'test1', 'hour': '00:00:00'})

    def test_convert_time_first_second_hour(self):
        """ Should return a default hour in 00:00:01"""
        value = 'test1, 00:00:01'
        self.assertEqual(convert_time_when_param(value),
                         {'when': 'test1', 'hour': '00:00:01'})

    def test_convert_time_wrong_value_time(self):
        """ Should return a default hour"""
        value = 'test1, string_wrong'

        self.assertEqual(convert_time_when_param(value),