# Path: qpanel/utils.py
# def clean_str_to_div_id(value):
#     """ Clean String for a div name.
#         Convert character like @ / and . for more easy use in JQuery
#         Parameter: value = string
#     """
#     v = value.replace('/', '-')
#     v = v.replace('.', '_')
#     return v.replace('@', '_')
# 
# def underscore_to_camelcase(word):
#     """
#         Convert word to camelcase format
#     """
#     return ''.join(x.capitalize() or '_' for x in word.split('_'))
# 
# def timedelta_from_field_dict(field, dic, current_timestamp=None,
#                               is_seconds_ago=False):
#     seconds_ago = 0
#     if not current_timestamp:
#         current_timestamp = time.time()
#     if field in dic:
#         if int(dic[field]) > 0:
#             if is_seconds_ago:
#                 seconds_ago = int(dic[field])
#             else:
#                 seconds_ago = int(current_timestamp) - int(dic[field])
# 
#     return timedelta(seconds=seconds_ago)


import unittest
import time
import datetime
from qpanel.utils import clean_str_to_div_id, underscore_to_camelcase, \
    timedelta_from_field_dict


class UtilsTestClass(unittest.TestCase):

    def test_clean_str_to_div(self):
        div = 'ro/.d. i _@l_k/d_@'
        self.assertEqual(clean_str_to_div_id(div), 'ro-_d_ i __l_k-d__')

    def test_underscore_to_camelcase(self):
        a = 'rodrigoRamirez'
        self.assertEqual(underscore_to_camelcase(a), 'Rodrigoramirez')
        a = 'rodrigo_Ramirez'

# Path: qpanel/utils.py
# def clean_str_to_div_id(value):
#     """ Clean String for a div name.
#         Convert character like @ / and . for more easy use in JQuery
#         Parameter: value = string
#     """
#     v = value.replace('/', '-')
#     v = v.replace('.', '_')
#     return v.replace('@', '_')
# 
# def underscore_to_camelcase(word):
#     """
#         Convert word to camelcase format
#     """
#     return ''.join(x.capitalize() or '_' for x in word.split('_'))
# 
# def timedelta_from_field_dict(field, dic, current_timestamp=None,
#                               is_seconds_ago=False):
#     seconds_ago = 0
#     if not current_timestamp:
#         current_timestamp = time.time()
#     if field in dic:
#         if int(dic[field]) > 0:
#             if is_seconds_ago:
#                 seconds_ago = int(dic[field])
#             else:
#                 seconds_ago = int(current_timestamp) - int(dic[field])
# 
#     return timedelta(seconds=seconds_ago)


# Path: tests/test_utils.py
import unittest
import time
import datetime
from qpanel.utils import clean_str_to_div_id, underscore_to_camelcase, \
    timedelta_from_field_dict



class UtilsTestClass(unittest.TestCase):

    def test_clean_str_to_div(self):
        div = 'ro/.d. i _@l_k/d_@'
        self.assertEqual(clean_str_to_div_id(div), 'ro-_d_ i __l_k-d__')

    def test_underscore_to_camelcase(self):
        a = 'rodrigoRamirez'
        self.assertEqual(underscore_to_camelcase(a), 'Rodrigoramirez')
        a = 'rodrigo_Ramirez'

        self.assertEqual(underscore_to_camelcase(a), 'RodrigoRamirez')