# Path: contentful/utils.py
#     class NullHandler(logging.Handler):
# class ConfigurationException(Exception):
# class NotSupportedException(Exception):
# class retry_request(object):
#         def emit(self, record):
# def unicode_class():
# def string_class():
# def json_error_class():
# def snake_case(a_string):
# def is_link(value):
# def is_link_array(value):
# def unresolvable(item, errors):
# def resource_for_link(link, includes, resources=None, locale=None):
#     def __init__(self, client):
#     def __call__(self, http_call):
#         def wrapper(url, query=None):


from unittest import TestCase
from contentful import utils


class UtilsTest(TestCase):
    def test_snake_case(self):
        self.assertEqual(utils.snake_case('foo'), 'foo')
        self.assertEqual(utils.snake_case('foo_bar'), 'foo_bar')
        self.assertEqual(utils.snake_case('Foo'), 'foo')
        self.assertEqual(utils.snake_case('FooBar'), 'foo_bar')
        self.assertEqual(utils.snake_case('fooBar'), 'foo_bar')

    def test_is_link(self):
        self.assertFalse(utils.is_link('foo'))
        self.assertFalse(utils.is_link([1, 2, 3]))
        self.assertFalse(utils.is_link({'foo': 'bar'}))
        self.assertFalse(utils.is_link({'sys': {'type': 'Space'}, 'id': 'foo'}))

        self.assertTrue(utils.is_link({'sys': {'type': 'Link'}, 'id': 'foo'}))

    def test_is_link_array(self):
        self.assertFalse(utils.is_link_array('foo'))

# Path: contentful/utils.py
#     class NullHandler(logging.Handler):
# class ConfigurationException(Exception):
# class NotSupportedException(Exception):
# class retry_request(object):
#         def emit(self, record):
# def unicode_class():
# def string_class():
# def json_error_class():
# def snake_case(a_string):
# def is_link(value):
# def is_link_array(value):
# def unresolvable(item, errors):
# def resource_for_link(link, includes, resources=None, locale=None):
#     def __init__(self, client):
#     def __call__(self, http_call):
#         def wrapper(url, query=None):


# Path: tests/utils_test.py
from unittest import TestCase
from contentful import utils



class UtilsTest(TestCase):
    def test_snake_case(self):
        self.assertEqual(utils.snake_case('foo'), 'foo')
        self.assertEqual(utils.snake_case('foo_bar'), 'foo_bar')
        self.assertEqual(utils.snake_case('Foo'), 'foo')
        self.assertEqual(utils.snake_case('FooBar'), 'foo_bar')
        self.assertEqual(utils.snake_case('fooBar'), 'foo_bar')

    def test_is_link(self):
        self.assertFalse(utils.is_link('foo'))
        self.assertFalse(utils.is_link([1, 2, 3]))
        self.assertFalse(utils.is_link({'foo': 'bar'}))
        self.assertFalse(utils.is_link({'sys': {'type': 'Space'}, 'id': 'foo'}))

        self.assertTrue(utils.is_link({'sys': {'type': 'Link'}, 'id': 'foo'}))

    def test_is_link_array(self):
        self.assertFalse(utils.is_link_array('foo'))

        self.assertFalse(utils.is_link_array([1, 2, 3]))