Ejemplo n.º 1
0
    def setUp(self):
        super(LinksResourceTest, self).setUp()

        create_user_loggedin(self)

        self.conversation = ConversationList.objects.create(name='My Conversation')
        self.conversation.users.add(self.user)

        # Create a message.
        self.date = datetime.now()
        self.message = Message.objects.create(conversation=self.conversation,
            user=self.user, message='Test message', created_at=self.date)

        # Create a link.
        self.link = Links.objects.create(message=self.message, url='http://someurl.com')

        self.url = '/api/v1/links'

        self.url_with_identifier = '/api/v1/links/%i' % 1

        self.post_data = {
            'original_url': 'http://www.example.com',
            'url': 'http://www.example.com',
            'message': {
                'id': 1
            }
        }
Ejemplo n.º 2
0
    def setUp(self):
        super(HistoryResourceTest, self).setUp()

        create_user_loggedin(self)

        self.user2 = User.objects.create_user(username='******', email='*****@*****.**', password='******')
        UserProfile.objects.create(user=self.user2, avatar_url='http://www.howtomaximize.com')

        self.conversation = ConversationList.objects.create(name='My Conversation')
        self.conversation.users.add(self.user)
        self.conversation.users.add(self.user2)

         # Create a message 1 day.
        self.date_1day = datetime.now() - timedelta(days=1)

        self.message_1day = Message.objects.create(conversation=self.conversation, user=self.user,
            message='Test message 1 day ago', created_at=self.date_1day)

        self.notification_1day = Notification.objects.create(
            message=self.message_1day, created_at=self.date_1day,
            user=self.user, delivered=False)

        self.notification_1day_other_user = Notification.objects.create(
            message=self.message_1day, created_at=self.date_1day,
            user=self.user2, delivered=False)

        # Create a message 1 week ago.
        self.date_1week = datetime.now() - timedelta(days=7)

        self.message_1week = Message.objects.create(conversation=self.conversation, user=self.user,
            message='Test message 1 week ago', created_at=self.date_1week)

        self.notification_1week = Notification.objects.create(
            message=self.message_1week, created_at=self.date_1week,
            user=self.user, delivered=True)

        # Create a message 2 week ago.
        self.date_2weeks = datetime.now() - timedelta(days=14)
        self.message_2weeks = Message.objects.create(conversation=self.conversation, user=self.user,
            message='Test message 2 weeks ago', created_at=self.date_2weeks)

        self.notification_2weeks = Notification.objects.create(
            message=self.message_2weeks, created_at=self.date_2weeks,
            user=self.user, delivered=False)

        self.url = '/api/v1/user/notifications'

        self.url_with_identifier = '/api/v1/user/notifications/%i' % self.notification_1day.id

        self.post_data = {
            'original_url': 'http://www.example.com',
            'url': 'http://www.example.com',
            'message': {
                'id': 1
            }
        }
Ejemplo n.º 3
0
    def setUp(self):
        super(ConversationListResourceTest, self).setUp()

        create_user_loggedin(self)

        self.user2 = User.objects.create_user(username='******', email='*****@*****.**', password='******')
        UserProfile.objects.create(user=self.user2, avatar_url='http://www.howtomaximize.com')

        self.conversation = ConversationList.objects.create(name='My Conversation')
        self.conversation.users.add(self.user)

        self.url = '/api/v1/conversation'

        self.url_with_identifier = '/api/v1/conversation/%i' % self.conversation.id
Ejemplo n.º 4
0
    def setUp(self):
        super(MessageResourceTest, self).setUp()

        self.user2 = User.objects.create_user(username='******', email='*****@*****.**', password='******')
        UserProfile.objects.create(user=self.user2, avatar_url='http://www.howtomaximize.com')

        create_user_loggedin(self)

        self.conversation = ConversationList.objects.create(name='My Conversation')
        self.conversation.users.add(self.user)
        self.conversation.users.add(self.user2)

        self.message = Message.objects.create(conversation=self.conversation, message="teste message",
            created_at=datetime.now(), user=self.user)
Ejemplo n.º 5
0
    def setUp(self):
        super(UserProfileResourceTest, self).setUp()

        create_user_loggedin(self)

        self.url = '/api/v1/profiles/'

        self.url_with_identifier = '/api/v1/profiles/%i' % self.user.get_profile().id

        self.post_data = {
            'avatar_url': 'http://www.example.com',
            'user': {
                'id': self.user.id
            }
        }
Ejemplo n.º 6
0
    def setUp(self):
        super(UserProfileResourceTest, self).setUp()

        create_user_loggedin(self)

        self.url = '/api/v1/profiles/'

        self.url_with_identifier = '/api/v1/profiles/%i' % self.user.get_profile(
        ).id

        self.post_data = {
            'avatar_url': 'http://www.example.com',
            'user': {
                'id': self.user.id
            }
        }
Ejemplo n.º 7
0
    def setUp(self):
        super(UserResourceTest, self).setUp()

        create_user_loggedin(self)

        self.url = '/api/v1/user/'

        self.user2 = User.objects.create_user(username='******', email='*****@*****.**', password='******')
        self.user2.first_name = 'Janderson'
        self.user2.last_name = 'Cardoso'
        self.user2.save()

        self.url_with_identifier = '/api/v1/user/%i' % self.user.id

        self.url_with_identifier2 = '/api/v1/user/%i' % self.user2.id

        self.post_data = {
            'first_name': 'Janderson F. Cardoso'
        }
Ejemplo n.º 8
0
 def setUp(self):
     create_user_loggedin(self)
Ejemplo n.º 9
0
    def setUp(self):
        super(HistoryResourceTest, self).setUp()

        create_user_loggedin(self)

        self.user2 = User.objects.create_user(username='******',
                                              email='*****@*****.**',
                                              password='******')
        UserProfile.objects.create(user=self.user2,
                                   avatar_url='http://www.howtomaximize.com')

        self.conversation = ConversationList.objects.create(
            name='My Conversation')
        self.conversation.users.add(self.user)
        self.conversation.users.add(self.user2)

        # Create a message 1 day.
        self.date_1day = datetime.now() - timedelta(days=1)

        self.message_1day = Message.objects.create(
            conversation=self.conversation,
            user=self.user,
            message='Test message 1 day ago',
            created_at=self.date_1day)

        self.notification_1day = Notification.objects.create(
            message=self.message_1day,
            created_at=self.date_1day,
            user=self.user,
            delivered=False)

        self.notification_1day_other_user = Notification.objects.create(
            message=self.message_1day,
            created_at=self.date_1day,
            user=self.user2,
            delivered=False)

        # Create a message 1 week ago.
        self.date_1week = datetime.now() - timedelta(days=7)

        self.message_1week = Message.objects.create(
            conversation=self.conversation,
            user=self.user,
            message='Test message 1 week ago',
            created_at=self.date_1week)

        self.notification_1week = Notification.objects.create(
            message=self.message_1week,
            created_at=self.date_1week,
            user=self.user,
            delivered=True)

        # Create a message 2 week ago.
        self.date_2weeks = datetime.now() - timedelta(days=14)
        self.message_2weeks = Message.objects.create(
            conversation=self.conversation,
            user=self.user,
            message='Test message 2 weeks ago',
            created_at=self.date_2weeks)

        self.notification_2weeks = Notification.objects.create(
            message=self.message_2weeks,
            created_at=self.date_2weeks,
            user=self.user,
            delivered=False)

        self.url = '/api/v1/user/notifications'

        self.url_with_identifier = '/api/v1/user/notifications/%i' % self.notification_1day.id

        self.post_data = {
            'original_url': 'http://www.example.com',
            'url': 'http://www.example.com',
            'message': {
                'id': 1
            }
        }
Ejemplo n.º 10
0
    def setUp(self):
        super(UserLinksResourceTest, self).setUp()

        create_user_loggedin(self)

        self.user2 = User.objects.create_user(username='******',
                                              email='*****@*****.**',
                                              password='******')
        UserProfile.objects.create(user=self.user2,
                                   avatar_url='http://www.howtomaximize.com')

        self.conversation = ConversationList.objects.create(
            name='My Conversation')
        self.conversation.users.add(self.user)
        self.conversation.users.add(self.user2)

        # Create a message.
        self.date = datetime.now()
        self.message = Message.objects.create(conversation=self.conversation,
                                              user=self.user,
                                              message='Test message',
                                              created_at=self.date)

        # Create a link unread.
        self.link_unread = Links.objects.create(message=self.message,
                                                url='http://unread.com')
        self.user_link_unread = UserLinks.objects.create(user=self.user,
                                                         link=self.link_unread,
                                                         favorite=False,
                                                         read=False)

        # Create a link read.
        self.link_read = Links.objects.create(message=self.message,
                                              url='http://read.com')
        self.user_link_read = UserLinks.objects.create(user=self.user,
                                                       link=self.link_read,
                                                       favorite=False,
                                                       read=True)

        # Create a link unfavorite.
        self.link_unfavorite = Links.objects.create(
            message=self.message, url='http://unfavorite.com')
        self.user_link_unfavorite = UserLinks.objects.create(
            user=self.user,
            link=self.link_unfavorite,
            favorite=False,
            read=False)

        # Create a link favorite.
        self.link_favorite = Links.objects.create(
            message=self.message,
            url='http://favorite.com',
            original_url='http://read.com')
        self.user_link_favorite = UserLinks.objects.create(
            user=self.user, link=self.link_favorite, favorite=True, read=True)

        # Create a link search in description.
        self.link_description = Links.objects.create(
            message=self.message,
            url='http://ops.com',
            original_url='http://zica.com',
            description='here have search in text.',
            title='Blabla title')
        self.user_link_description = UserLinks.objects.create(
            user=self.user,
            link=self.link_description,
            favorite=False,
            read=False)

        # Create a link search in title.
        self.link_title = Links.objects.create(
            message=self.message,
            url='http://ops.com',
            description='here do not have blabla in text.',
            title='Search Title ')
        self.user_link_title = UserLinks.objects.create(user=self.user,
                                                        link=self.link_title,
                                                        favorite=True,
                                                        read=False)

        # Create a link search in title for other user.
        self.user_link_title2 = UserLinks.objects.create(user=self.user2,
                                                         link=self.link_title,
                                                         favorite=True,
                                                         read=False)

        self.url = '/api/v1/user/links'

        self.url_with_identifier = '/api/v1/user/links/%i' % self.link_unread.id

        self.post_data = {
            'original_url': 'http://www.example.com',
            'url': 'http://www.example.com',
            'message': {
                'id': 1
            }
        }
Ejemplo n.º 11
0
    def setUp(self):
        super(HistoryResourceTest, self).setUp()

        create_user_loggedin(self)

        self.user2 = User.objects.create_user(username="******", email="*****@*****.**", password="******")
        UserProfile.objects.create(user=self.user2, avatar_url="http://www.howtomaximize.com")

        self.conversation = ConversationList.objects.create(name="My Conversation")
        self.conversation.users.add(self.user)
        self.conversation.users.add(self.user2)

        # Create a message 1 day.
        self.date_1day = datetime.now() - timedelta(days=1)

        self.message_1day = Message.objects.create(
            conversation=self.conversation, user=self.user, message="Test message 1 day ago", created_at=self.date_1day
        )

        self.notification_1day = Notification.objects.create(
            message=self.message_1day, created_at=self.date_1day, user=self.user, delivered=True
        )

        # Create a message 1 week ago.
        self.date_1week = datetime.now() - timedelta(days=7)

        self.message_1week = Message.objects.create(
            conversation=self.conversation,
            user=self.user,
            message="Test message 1 week ago",
            created_at=self.date_1week,
        )

        self.notification_1week = Notification.objects.create(
            message=self.message_1week, created_at=self.date_1week, user=self.user, delivered=True
        )

        # Create a message 2 week ago.
        self.date_2weeks = datetime.now() - timedelta(days=14)
        self.message_2weeks = Message.objects.create(
            conversation=self.conversation,
            user=self.user,
            message="Test message 2 weeks ago",
            created_at=self.date_2weeks,
        )

        self.notification_2weeks = Notification.objects.create(
            message=self.message_2weeks, created_at=self.date_2weeks, user=self.user, delivered=True
        )

        # Create a message 1 month ago.
        self.date_1month = datetime.now() - timedelta(days=30)
        self.message_1month = Message.objects.create(
            conversation=self.conversation,
            user=self.user,
            message="Test message 1 month ago",
            created_at=self.date_1month,
        )

        self.notification_1month = Notification.objects.create(
            message=self.message_1month, created_at=self.date_1month, user=self.user, delivered=True
        )

        self.notification_1month_other_user = Notification.objects.create(
            message=self.message_1month, created_at=self.date_1month, user=self.user2, delivered=False
        )

        # Create a message 3 months ago.
        self.date_3months = datetime.now() - timedelta(days=90)

        self.message_3months = Message.objects.create(
            conversation=self.conversation,
            user=self.user,
            message="Test message 3 months ago",
            created_at=self.date_3months,
        )

        self.notification_3months_other_user = Notification.objects.create(
            message=self.message_3months, created_at=self.date_3months, user=self.user, delivered=True
        )

        self.notification_3months = Notification.objects.create(
            message=self.message_3months, created_at=self.date_3months, user=self.user2, delivered=True
        )

        self.url = "/api/v1/user/history"

        self.url_with_identifier = "/api/v1/user/history/%i" % self.notification_3months.id

        self.post_data = {
            "original_url": "http://www.example.com",
            "url": "http://www.example.com",
            "message": {"id": 1},
        }