# Path: baobab/utils/mock.py
# class MockSN(SocialNetworkBase):
#     name = 'MockSN'
# 
#     def __init__(self):
#         self._msg = []
# 
#     @classmethod
#     def is_configured(cls):
#         True
# 
#     @classmethod
#     def get_max_char(cls, default):
#         return 42
# 
#     def publish(self, msg, url):
#         self._msg.append((msg, url))
#         return len(self._msg)
# 
#     def __enter__(self):
#         return self
# 
#     def __exit__(self, exc_type, exc_val, exc_tb):
#         pass
# 
# class MockLOG(object):
# 
#     def __init__(self):
#         self._info = []
#         self._error = []
# 
#     def info(self, msg, *args):
#         self._info.append(msg % args)
# 
#     def error(self, msg, *args):
#         self._error.append(msg % args)


from mock import patch
from django.test import TestCase as DjangoTestCase
from tastypie.test import ResourceTestCase as TastypieResourceTestCase
from baobab.utils.mock import MockSN, MockLOG

    def setUp(self, *args, **kwargs):
        super(TestCase, self).setUp(*args, **kwargs)
        self._mock = []

        cls_path = 'baobab.socialnetwork.base.LOG'
        self._mock.append(patch(cls_path, new_callable=MockLOG))
        self.log = self._mock[0].start()

        cls_path = 'baobab.socialnetwork.base.SocialNetworkBase.__subclasses__'
        self._mock.append(patch(cls_path, return_value=[MockSN, ]))
        self._mock[1].start()

    def tearDown(self, *args, **kwargs):
        super(TestCase, self).tearDown(*args, **kwargs)
        for mock in self._mock:
            mock.stop()


class ResourceTestCase(TastypieResourceTestCase):

    def setUp(self, *args, **kwargs):
        super(ResourceTestCase, self).setUp(*args, **kwargs)
        self._mock = []

        cls_path = 'baobab.socialnetwork.base.LOG'
        self._mock.append(patch(cls_path, new_callable=MockLOG))
        self.log = self._mock[0].start()

        cls_path = 'baobab.socialnetwork.base.SocialNetworkBase.__subclasses__'

# Path: baobab/utils/mock.py
# class MockSN(SocialNetworkBase):
#     name = 'MockSN'
# 
#     def __init__(self):
#         self._msg = []
# 
#     @classmethod
#     def is_configured(cls):
#         True
# 
#     @classmethod
#     def get_max_char(cls, default):
#         return 42
# 
#     def publish(self, msg, url):
#         self._msg.append((msg, url))
#         return len(self._msg)
# 
#     def __enter__(self):
#         return self
# 
#     def __exit__(self, exc_type, exc_val, exc_tb):
#         pass
# 
# class MockLOG(object):
# 
#     def __init__(self):
#         self._info = []
#         self._error = []
# 
#     def info(self, msg, *args):
#         self._info.append(msg % args)
# 
#     def error(self, msg, *args):
#         self._error.append(msg % args)


# Path: baobab/utils/test.py
from mock import patch
from django.test import TestCase as DjangoTestCase
from tastypie.test import ResourceTestCase as TastypieResourceTestCase
from baobab.utils.mock import MockSN, MockLOG


    def setUp(self, *args, **kwargs):
        super(TestCase, self).setUp(*args, **kwargs)
        self._mock = []

        cls_path = 'baobab.socialnetwork.base.LOG'
        self._mock.append(patch(cls_path, new_callable=MockLOG))
        self.log = self._mock[0].start()

        cls_path = 'baobab.socialnetwork.base.SocialNetworkBase.__subclasses__'
        self._mock.append(patch(cls_path, return_value=[MockSN, ]))
        self._mock[1].start()

    def tearDown(self, *args, **kwargs):
        super(TestCase, self).tearDown(*args, **kwargs)
        for mock in self._mock:
            mock.stop()


class ResourceTestCase(TastypieResourceTestCase):

    def setUp(self, *args, **kwargs):
        super(ResourceTestCase, self).setUp(*args, **kwargs)
        self._mock = []

        cls_path = 'baobab.socialnetwork.base.LOG'
        self._mock.append(patch(cls_path, new_callable=MockLOG))
        self.log = self._mock[0].start()

        cls_path = 'baobab.socialnetwork.base.SocialNetworkBase.__subclasses__'

        self._mock.append(patch(cls_path, return_value=[MockSN, ]))