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_refresh_status(self):
        self.set_up()
        flr_name = 'testFollower'
        follower = Follower(name=flr_name, user=self.user)
        follower.save()
        qr_account = QrAccount(follower=follower, user_name='quan-zhang-27')
        qr_account.save()

        qr_account_list = [qr_account, ]

        status_list =  QrStatusView.refresh_status(qr_account_list)
        print status_list
 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()
        flr_name = 'testFollower'
        follower = Follower(name=flr_name, user=self.user)
        follower.save()
        qr_account = QrAccount(follower=follower, user_name='quan-zhang-27')
        qr_account.save()

        qr_account_list = [
            qr_account,
        ]

        status_list = QrStatusView.refresh_status(qr_account_list)
        print status_list
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 save_account(follower, **kwargs):
    new_account = QrAccount(follower=follower)
    new_account.user_name = kwargs['user_name']
    new_account.save()
    return True