class StatusViewTest(TestCase):
    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()

    def test_refresh_status(self):
        self.set_up()

        ajax_dict = {'site_type': 'quora'}
        response = Utils.ajax_post_json(self.client, url_refresh_status_site,
                                        ajax_dict)
        status_list = json.loads(response.content)['status_list']
        self.assertEqual(10, len(status_list))
        for status in status_list:
            print status

        # since_id = status_list[0]["id"]
        # ajax_dict = {'site_type': 'twitter',
        #              'since_id': since_id}
        # response = Utils.ajax_post_json(self.client, url_refresh_status_site, ajax_dict)
        # status_list = json.loads(response.content)['status_list']
        # self.assertEqual(0, len(status_list))

    def test_refresh_status_flr(self):
        self.set_up()

        ajax_dict = {'flr_name': self.follower.name}
        response = Utils.ajax_post_json(self.client, url_refresh_status_flr,
                                        ajax_dict)
        status_list = json.loads(response.content)['status_list']
        # for status in status_list:
        #     print "%s\t" % status['act_type']
        #     print status.get('time_stamp', None)
        #     print "\n"
        ajax_dict = {
            'flr_name': self.follower.name,
            'lt_st_time': '2015-12-02 03:49:00'
        }
        response = Utils.ajax_post_json(self.client, url_refresh_status_flr,
                                        ajax_dict)
        status_list = json.loads(response.content)['status_list']
        for status in status_list:
            print "%s\t" % status['act_type']
            print status.get('time_stamp', None)
            print "\n"
 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()
    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)
class StatusViewTest(TestCase):
    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()

    def test_refresh_status(self):
        self.set_up()

        ajax_dict = {'site_type': 'quora'}
        response = Utils.ajax_post_json(self.client, url_refresh_status_site, ajax_dict)
        status_list = json.loads(response.content)['status_list']
        self.assertEqual(10, len(status_list))
        for status in status_list:
            print status

        # since_id = status_list[0]["id"]
        # ajax_dict = {'site_type': 'twitter',
        #              'since_id': since_id}
        # response = Utils.ajax_post_json(self.client, url_refresh_status_site, ajax_dict)
        # status_list = json.loads(response.content)['status_list']
        # self.assertEqual(0, len(status_list))

    def test_refresh_status_flr(self):
        self.set_up()

        ajax_dict = {'flr_name': self.follower.name}
        response = Utils.ajax_post_json(self.client, url_refresh_status_flr, ajax_dict)
        status_list = json.loads(response.content)['status_list']
        # for status in status_list:
        #     print "%s\t" % status['act_type']
        #     print status.get('time_stamp', None)
        #     print "\n"
        ajax_dict = {'flr_name': self.follower.name,
                     'lt_st_time': '2015-12-02 03:49:00'}
        response = Utils.ajax_post_json(self.client, url_refresh_status_flr, ajax_dict)
        status_list = json.loads(response.content)['status_list']
        for status in status_list:
            print "%s\t" % status['act_type']
            print status.get('time_stamp', None)
            print "\n"
 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())
    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. 7
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 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()
    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. 10
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())