# Path: responsebot/models.py
# class Event(object):
#     """
#     Represent a user events (e.g. following, unfollowing, etc.). See more `here <../guides/user_event_handling.html>`_
#     and `here <https://dev.twitter.com/streaming/overview/messages-types#Events_event>`_.
#     """
#     def __init__(self, data):
#         """
#         :param data: Parsed JSON data
#         :type data: dictionary
#         """
#         self.raw_data = data
# 
#         for key, value in data.items():
#             if key == 'target':
#                 setattr(self, key, User(value))
#             elif key == 'source':
#                 setattr(self, key, User(value))
#             elif key == 'created_at':
#                 setattr(self, key, parse(value))
#             else:
#                 setattr(self, key, value)
# 
#         setattr(self, 'target_object', self._parse_target_obj(data))
# 
#     def _parse_target_obj(self, data):
#         # TODO: parse target obj base on event
#         if data['event'] in ['follow', 'unfollow', 'block', 'unblock', 'user_update']:
#             return None
#         elif data['event'] in ['favorite', 'unfavorite', 'quoted_tweet']:
#             return Tweet(data['target_object'])
#         elif data['event'] in ['list_created', 'list_destroyed', 'list_updated', 'list_member_added',
#                 'list_member_removed', 'list_user_subscribed', 'list_user_unsubscribed']:
#             return List(data['target_object'])
#         return data.get('target_object')
# 
# class User(object):
#     """
#     Represents a user. E.g. you can get a user's screen name via it's :code:`screen_name` property
#     (:code:`user.screen_name`). All properties except :code:`status` have the same name as Twitter defined them `here
#     <https://dev.twitter.com/overview/api/users>`_. :code:`status` is renamed to :code:`tweet`.
#     """
#     def __init__(self, data):
#         """
#         :param data: Parsed JSON data
#         :type data: dictionary
#         """
#         self.raw_data = data
# 
#         for key, value in data.items():
#             if key == 'created_at':
#                 setattr(self, key, parse(value))
#             elif key == 'status':
#                 setattr(self, 'tweet', Tweet(value))
#             elif key == 'following':
#                 setattr(self, key, value is True)
#             else:
#                 setattr(self, key, value)
# 
# class Tweet(object):
#     """
#     Represents a tweet. E.g. you can get a tweet's text via it's :code:`text` property (:code:`tweet.text`).
#     All properties except :code:`retweeted_status`, :code:`quoted_status`, :code:`quoted_status_id_str`, :code:`in_reply_to_status_id`
#     and :code:`in_reply_sto_status_id_str` have the same name as Twitter defined them `here <https://dev.twitter.com/overview/api/tweets>`_.
#     :code:`retweeted_status` is renamed to :code:`retweeted_tweet`, similar for other properties above.
#     """
#     def __init__(self, data):
#         """
#         :param data: Parsed JSON data
#         :type data: dictionary
#         """
#         self.raw_data = data
# 
#         # TODO: handle place. source, quoted_status_id_str
#         for key, value in data.items():
#             if key == 'user':
#                 setattr(self, key, User(value))
#             elif key == 'created_at':
#                 setattr(self, key, parse(value))
#             elif key == 'retweeted_status':
#                 setattr(self, 'retweeted_tweet', Tweet(value))
#             elif key == 'quoted_status':
#                 setattr(self, 'quoted_tweet', Tweet(value))
#             elif key == 'quoted_status_id_str':
#                 setattr(self, 'quoted_tweet_id_str', value)
#             elif key == 'in_reply_to_status_id':
#                 setattr(self, 'in_reply_to_tweet_id', value)
#             elif key == 'in_reply_to_status_id_str':
#                 setattr(self, 'in_reply_to_tweet_id_str', value)
#             else:
#                 setattr(self, key, value)
# 
# class List(object):
#     """
#     Represent a user list.
#     """
#     def __init__(self, data):
#         """
#         :param data: Parsed JSON data
#         :type data: dictionary
#         """
#         self.raw_data = data
# 
#         for key, value in data.items():
#             if key == 'user':
#                 setattr(self, key, User(value))
#             elif key == 'created_at':
#                 setattr(self, key, parse(value))
#             else:
#                 setattr(self, key, value)


from unittest.case import TestCase
from dateutil.parser import parse
from responsebot.models import Event, User, Tweet, List
        event = Event(raw)

        expected_created_at = parse(created_at)

        self.assertEqual(event.event, 'some value')
        self.assertEqual(event.created_at, expected_created_at)

        self.assertTrue(isinstance(event.target, User))
        self.assertEqual(event.target.name, 'target')

        self.assertTrue(isinstance(event.source, User))
        self.assertEqual(event.source.name, 'source')

        self.assertIsNone(event.target_object)

    def test_parse_target_object(self):
        for event_type in ['follow', 'unfollow', 'block', 'unblock', 'user_update']:
            raw_event = {
                'event': event_type
            }
            event = Event(raw_event)
            self.assertIsNone(event.target_object)

        for event_type in ['favorite', 'unfavorite', 'quoted_tweet']:
            raw_event = {
                'event': event_type,
                'target_object': {
                    'something': 'some value'
                }
            }

# Path: responsebot/models.py
# class Event(object):
#     """
#     Represent a user events (e.g. following, unfollowing, etc.). See more `here <../guides/user_event_handling.html>`_
#     and `here <https://dev.twitter.com/streaming/overview/messages-types#Events_event>`_.
#     """
#     def __init__(self, data):
#         """
#         :param data: Parsed JSON data
#         :type data: dictionary
#         """
#         self.raw_data = data
# 
#         for key, value in data.items():
#             if key == 'target':
#                 setattr(self, key, User(value))
#             elif key == 'source':
#                 setattr(self, key, User(value))
#             elif key == 'created_at':
#                 setattr(self, key, parse(value))
#             else:
#                 setattr(self, key, value)
# 
#         setattr(self, 'target_object', self._parse_target_obj(data))
# 
#     def _parse_target_obj(self, data):
#         # TODO: parse target obj base on event
#         if data['event'] in ['follow', 'unfollow', 'block', 'unblock', 'user_update']:
#             return None
#         elif data['event'] in ['favorite', 'unfavorite', 'quoted_tweet']:
#             return Tweet(data['target_object'])
#         elif data['event'] in ['list_created', 'list_destroyed', 'list_updated', 'list_member_added',
#                 'list_member_removed', 'list_user_subscribed', 'list_user_unsubscribed']:
#             return List(data['target_object'])
#         return data.get('target_object')
# 
# class User(object):
#     """
#     Represents a user. E.g. you can get a user's screen name via it's :code:`screen_name` property
#     (:code:`user.screen_name`). All properties except :code:`status` have the same name as Twitter defined them `here
#     <https://dev.twitter.com/overview/api/users>`_. :code:`status` is renamed to :code:`tweet`.
#     """
#     def __init__(self, data):
#         """
#         :param data: Parsed JSON data
#         :type data: dictionary
#         """
#         self.raw_data = data
# 
#         for key, value in data.items():
#             if key == 'created_at':
#                 setattr(self, key, parse(value))
#             elif key == 'status':
#                 setattr(self, 'tweet', Tweet(value))
#             elif key == 'following':
#                 setattr(self, key, value is True)
#             else:
#                 setattr(self, key, value)
# 
# class Tweet(object):
#     """
#     Represents a tweet. E.g. you can get a tweet's text via it's :code:`text` property (:code:`tweet.text`).
#     All properties except :code:`retweeted_status`, :code:`quoted_status`, :code:`quoted_status_id_str`, :code:`in_reply_to_status_id`
#     and :code:`in_reply_sto_status_id_str` have the same name as Twitter defined them `here <https://dev.twitter.com/overview/api/tweets>`_.
#     :code:`retweeted_status` is renamed to :code:`retweeted_tweet`, similar for other properties above.
#     """
#     def __init__(self, data):
#         """
#         :param data: Parsed JSON data
#         :type data: dictionary
#         """
#         self.raw_data = data
# 
#         # TODO: handle place. source, quoted_status_id_str
#         for key, value in data.items():
#             if key == 'user':
#                 setattr(self, key, User(value))
#             elif key == 'created_at':
#                 setattr(self, key, parse(value))
#             elif key == 'retweeted_status':
#                 setattr(self, 'retweeted_tweet', Tweet(value))
#             elif key == 'quoted_status':
#                 setattr(self, 'quoted_tweet', Tweet(value))
#             elif key == 'quoted_status_id_str':
#                 setattr(self, 'quoted_tweet_id_str', value)
#             elif key == 'in_reply_to_status_id':
#                 setattr(self, 'in_reply_to_tweet_id', value)
#             elif key == 'in_reply_to_status_id_str':
#                 setattr(self, 'in_reply_to_tweet_id_str', value)
#             else:
#                 setattr(self, key, value)
# 
# class List(object):
#     """
#     Represent a user list.
#     """
#     def __init__(self, data):
#         """
#         :param data: Parsed JSON data
#         :type data: dictionary
#         """
#         self.raw_data = data
# 
#         for key, value in data.items():
#             if key == 'user':
#                 setattr(self, key, User(value))
#             elif key == 'created_at':
#                 setattr(self, key, parse(value))
#             else:
#                 setattr(self, key, value)


# Path: tests/unit_tests/models/test_event_model.py
from unittest.case import TestCase
from dateutil.parser import parse
from responsebot.models import Event, User, Tweet, List

        event = Event(raw)

        expected_created_at = parse(created_at)

        self.assertEqual(event.event, 'some value')
        self.assertEqual(event.created_at, expected_created_at)

        self.assertTrue(isinstance(event.target, User))
        self.assertEqual(event.target.name, 'target')

        self.assertTrue(isinstance(event.source, User))
        self.assertEqual(event.source.name, 'source')

        self.assertIsNone(event.target_object)

    def test_parse_target_object(self):
        for event_type in ['follow', 'unfollow', 'block', 'unblock', 'user_update']:
            raw_event = {
                'event': event_type
            }
            event = Event(raw_event)
            self.assertIsNone(event.target_object)

        for event_type in ['favorite', 'unfavorite', 'quoted_tweet']:
            raw_event = {
                'event': event_type,
                'target_object': {
                    'something': 'some value'
                }
            }

            event = Event(raw_event)