def set_up(self):
     setup_dict = Utils.set_up()
     self.client = setup_dict['client']
     self.user = setup_dict['user']
     flr_name = 'testFollower'
     self.follower = Follower(name=flr_name, user=self.user)
     self.follower.save()
     self.tw_account = TwAccount(follower=self.follower,
                                 act_id='3991423984',
                                 screen_name='charleszhuochen')
     self.tw_account.save()
     self.qr_account = QrAccount(follower=self.follower,
                                 user_name='quan-zhang-27')
     self.qr_account.save()
Esempio n. 2
0
    def test_verify_exist_account(self):
        self.set_up()
        '''verify a new account while the follower already have one will return False'''
        follower = Follower(name='testFollower', user=self.user)
        follower.save()
        tw_account = TwAccount(follower=follower,
                               act_id='3991423984',
                               screen_name='charleszhuochen')
        tw_account.save()

        ajax_dict = {
            'act_type': 'twitter',
            'flr_name': 'testFollower',
            'act_id': None,
            'screen_name': '_QuanZhang_'
        }
        response = Utils.ajax_post_json(self.client, url_verify_account,
                                        ajax_dict)
        self.assertEqual('False', response.content)
    def test_refresh_status(self):
        self.set_up()
        follower = Follower(name='testFollower', user=self.user)
        follower.save()
        tw_account = TwAccount(follower=follower,
                               act_id='3991423984',
                               screen_name='charleszhuochen')
        tw_account.save()

        tw_account_list = [
            tw_account,
        ]
        since_id = None
        status_list = TwStatusView.refresh_status(tw_account_list, since_id)
        print(status_list[0]['created_at'])
        latest_status = TwStatus.objects.get(id=status_list[0]['id'])
        print(latest_status.created_at)
        self.assertEqual(10, len(status_list))
        since_id = int(status_list[0]['id'])
        status_list = TwStatusView.refresh_status(tw_account_list, since_id)
        self.assertEqual(0, len(status_list))
Esempio n. 4
0
 def test_http_delete_account(self):
     self.set_up()
     '''normal case: delete an exist account would return True'''
     flr_name = 'testFollower'
     follower = Follower(name=flr_name, user=self.user)
     follower.save()
     tw_account = TwAccount(follower=follower,
                            act_id='3991423984',
                            screen_name='charleszhuochen')
     tw_account.save()
     '''before delete, TwAccount has this account'''
     self.assertEqual(
         True,
         TwAccount.objects.filter(follower__name=flr_name).exists())
     ajax_dict = {'flr_name': 'testFollower', 'act_type': 'twitter'}
     response = Utils.ajax_post_json(self.client, url_delete_account,
                                     ajax_dict)
     '''after delete, TwAccount does not has this account anymore'''
     self.assertEqual('True', response.content)
     self.assertEqual(
         False,
         TwAccount.objects.filter(follower__name=flr_name).exists())