Exemple #1
0
    def test_http_save_fake_account_with_exist_account(self):
        self.set_up()
        '''Since this user already has a twitter account, then no matter the new twitter account is fake or real,
        http_save_account() would return a false indicate that this user already has a twitter account
        (notice, in this case currently we CANNOT distinguish non-exist follower from already exist account
        since both cases will return False)'''

        flr_name = 'testFollower'
        follower = Follower(name=flr_name, user=self.user)
        follower.save()
        ajax_dict = {
            'flr_name': flr_name,
            'act_type': 'twitter',
            'act_id': None,
            'screen_name': 'charleszhuochen'
        }
        Utils.ajax_post_json(self.client, url_save_account, ajax_dict)
        ajax_dict = {
            'flr_name': flr_name,
            'act_type': 'twitter',
            'act_id': None,
            'screen_name': 'fakeuserfakeuserthisisfakeuseribek'
        }
        response = Utils.ajax_post_json(self.client, url_save_account,
                                        ajax_dict)
        self.assertEqual('False', response.content)
 def test_delete_follower(self):
     flr_name = self.test_add_follower()
     ajax_dict = {'flr_name': flr_name}
     response = Utils.ajax_post_json(self.client, url_delete_follower, ajax_dict)
     self.assertEqual('True', response.content)
     self.assertEqual(False, Follower.objects.filter(name=flr_name).exists())
     self.assertEqual(False, TwAccount.objects.filter(follower__name=flr_name).exists())
Exemple #3
0
 def test_delete_non_exsit_follower(self):
     self.set_up()
     flr_name = 'notExistFollower'
     ajax_dict = {'flr_name': flr_name}
     response = Utils.ajax_post_json(self.client, url_delete_follower,
                                     ajax_dict)
     self.assertEqual('False', response.content)
 def test_add_follower(self):
     self.set_up()
     flr_name = 'testFollower'
     ajax_dict = {'flr_name': flr_name}
     response = Utils.ajax_post_json(self.client, url_add_follower, ajax_dict)
     response_data = json.loads(response.content)
     self.assertEqual(True, 'flr_id' in response_data)
     if response.content != 'False':
         ajax_dict = {'flr_name': 'testFollower',
                      'act_type': 'twitter',
                      'act_id': None,
                      'screen_name': 'charleszhuochen'}
         response = Utils.ajax_post_json(self.client, url_save_account, ajax_dict)
         self.assertEqual('True', response.content)
         self.assertEqual(True, TwAccount.objects.filter(follower__name=flr_name).exists())
     self.assertEqual(True, Follower.objects.filter(name=flr_name).exists())
     return flr_name
    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
    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_save_account_with_exist_account(self):
        self.set_up()
        '''Since this user already has a twitter account after first save, then the second save would get a False'''

        flr_name = 'testFollower'
        follower = Follower(name=flr_name, user=self.user)
        follower.save()
        ajax_dict = {'flr_name': flr_name,
                     'act_type': 'twitter',
                     'act_id': None,
                     'screen_name': 'charleszhuochen'}
        Utils.ajax_post_json(self.client, url_save_account, ajax_dict)
        ajax_dict = {'flr_name': flr_name,
                     'act_type': 'twitter',
                     'act_id': None,
                     'screen_name': '_QuanZhang_'}
        response = Utils.ajax_post_json(self.client, url_save_account, ajax_dict)
        self.assertEqual('False', response.content)
    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
 def test_verify_non_exist_account(self):
     self.set_up()
     '''an un-exist account would failed verification
     and would get '404' indicate that can not find this account'''
     ajax_dict = {'act_type': 'twitter',
               'flr_name': None,
               'act_id': None,
               'screen_name': 'thisisnotauseribelievenooneusethisasaccountname'}
     response = Utils.ajax_post_json(self.client, url_verify_account, ajax_dict)
     self.assertEqual('404', response.content)
Exemple #10
0
 def test_delete_follower(self):
     flr_name = self.test_add_follower()
     ajax_dict = {'flr_name': flr_name}
     response = Utils.ajax_post_json(self.client, url_delete_follower,
                                     ajax_dict)
     self.assertEqual('True', response.content)
     self.assertEqual(False,
                      Follower.objects.filter(name=flr_name).exists())
     self.assertEqual(
         False,
         TwAccount.objects.filter(follower__name=flr_name).exists())
 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_http_save_account_with_non_exist_follower(self):
        self.set_up()
        '''if try to save an account to a non-exist follower, then will get a False'''

        flr_name = 'testFollower'
        ajax_dict = {'flr_name': flr_name,
                     'act_type': 'twitter',
                     'act_id': None,
                     'screen_name': 'charleszhuochen'}
        '''if post an un-existed flr_name, save_account would return False'''
        response = Utils.ajax_post_json(self.client, url_save_account, ajax_dict)
        self.assertEqual('False', response.content)
    def test_http_save_fake_account_with_exist_account(self):
        self.set_up()
        '''Since this user already has a twitter account, then no matter the new twitter account is fake or real,
        http_save_account() would return a false indicate that this user already has a twitter account
        (notice, in this case currently we CANNOT distinguish non-exist follower from already exist account
        since both cases will return False)'''

        flr_name = 'testFollower'
        follower = Follower(name=flr_name, user=self.user)
        follower.save()
        ajax_dict = {'flr_name': flr_name,
                     'act_type': 'twitter',
                     'act_id': None,
                     'screen_name': 'charleszhuochen'}
        Utils.ajax_post_json(self.client, url_save_account, ajax_dict)
        ajax_dict = {'flr_name': flr_name,
                     'act_type': 'twitter',
                     'act_id': None,
                     'screen_name': 'fakeuserfakeuserthisisfakeuseribek'}
        response = Utils.ajax_post_json(self.client, url_save_account, ajax_dict)
        self.assertEqual('False', response.content)
 def test_http_save_account(self):
     self.set_up()
     '''normal case: an exist follower save a new account, the account would save in to database and return True'''
     flr_name = 'testFollower'
     follower = Follower(name=flr_name, user=self.user)
     follower.save()
     ajax_dict = {'flr_name': flr_name,
                  'act_type': 'twitter',
                  # 'act_id': None,
                  'screen_name': 'charleszhuochen'}
     '''save_account would return True'''
     response = Utils.ajax_post_json(self.client, url_save_account, ajax_dict)
     self.assertEqual('True', response.content)
Exemple #15
0
 def test_verify_non_exist_account(self):
     self.set_up()
     '''an un-exist account would failed verification
     and would get '404' indicate that can not find this account'''
     ajax_dict = {
         'act_type': 'twitter',
         'flr_name': None,
         'act_id': None,
         'screen_name': 'thisisnotauseribelievenooneusethisasaccountname'
     }
     response = Utils.ajax_post_json(self.client, url_verify_account,
                                     ajax_dict)
     self.assertEqual('404', response.content)
    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"
Exemple #17
0
    def test_http_save_account_with_exist_account(self):
        self.set_up()
        '''Since this user already has a twitter account after first save, then the second save would get a False'''

        flr_name = 'testFollower'
        follower = Follower(name=flr_name, user=self.user)
        follower.save()
        ajax_dict = {
            'flr_name': flr_name,
            'act_type': 'twitter',
            'act_id': None,
            'screen_name': 'charleszhuochen'
        }
        Utils.ajax_post_json(self.client, url_save_account, ajax_dict)
        ajax_dict = {
            'flr_name': flr_name,
            'act_type': 'twitter',
            'act_id': None,
            'screen_name': '_QuanZhang_'
        }
        response = Utils.ajax_post_json(self.client, url_save_account,
                                        ajax_dict)
        self.assertEqual('False', response.content)
    def test_http_save_fake_account(self):
        self.set_up()
        ''' if an user try to save a fake account, then the verifycation module would return '404' indicates that
        this account could not pass verification since could not find it on that social website '''

        flr_name = 'testFollower'
        follower = Follower(name=flr_name, user=self.user)
        follower.save()
        ajax_dict = {'flr_name': flr_name,
                     'act_type': 'twitter',
                     'act_id': None,
                     'screen_name': 'fakeuserfakeuserthisisfakeuseribek'}
        response = Utils.ajax_post_json(self.client, url_save_account, ajax_dict)
        self.assertEqual('404', response.content)
    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)
Exemple #20
0
 def test_add_follower(self):
     self.set_up()
     flr_name = 'testFollower'
     ajax_dict = {'flr_name': flr_name}
     response = Utils.ajax_post_json(self.client, url_add_follower,
                                     ajax_dict)
     response_data = json.loads(response.content)
     self.assertEqual(True, 'flr_id' in response_data)
     if response.content != 'False':
         ajax_dict = {
             'flr_name': 'testFollower',
             'act_type': 'twitter',
             'act_id': None,
             'screen_name': 'charleszhuochen'
         }
         response = Utils.ajax_post_json(self.client, url_save_account,
                                         ajax_dict)
         self.assertEqual('True', response.content)
         self.assertEqual(
             True,
             TwAccount.objects.filter(follower__name=flr_name).exists())
     self.assertEqual(True, Follower.objects.filter(name=flr_name).exists())
     return flr_name
 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()
Exemple #22
0
    def test_http_save_account_with_non_exist_follower(self):
        self.set_up()
        '''if try to save an account to a non-exist follower, then will get a False'''

        flr_name = 'testFollower'
        ajax_dict = {
            'flr_name': flr_name,
            'act_type': 'twitter',
            'act_id': None,
            'screen_name': 'charleszhuochen'
        }
        '''if post an un-existed flr_name, save_account would return False'''
        response = Utils.ajax_post_json(self.client, url_save_account,
                                        ajax_dict)
        self.assertEqual('False', response.content)
 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())
Exemple #24
0
 def test_http_save_account(self):
     self.set_up()
     '''normal case: an exist follower save a new account, the account would save in to database and return True'''
     flr_name = 'testFollower'
     follower = Follower(name=flr_name, user=self.user)
     follower.save()
     ajax_dict = {
         'flr_name': flr_name,
         'act_type': 'twitter',
         # 'act_id': None,
         'screen_name': 'charleszhuochen'
     }
     '''save_account would return True'''
     response = Utils.ajax_post_json(self.client, url_save_account,
                                     ajax_dict)
     self.assertEqual('True', response.content)
Exemple #25
0
    def test_http_save_fake_account(self):
        self.set_up()
        ''' if an user try to save a fake account, then the verifycation module would return '404' indicates that
        this account could not pass verification since could not find it on that social website '''

        flr_name = 'testFollower'
        follower = Follower(name=flr_name, user=self.user)
        follower.save()
        ajax_dict = {
            'flr_name': flr_name,
            'act_type': 'twitter',
            'act_id': None,
            'screen_name': 'fakeuserfakeuserthisisfakeuseribek'
        }
        response = Utils.ajax_post_json(self.client, url_save_account,
                                        ajax_dict)
        self.assertEqual('404', response.content)
Exemple #26
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)
Exemple #27
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())
 def set_up(self):
     setup_dict = Utils.set_up()
     self.client = setup_dict['client']
     self.user = setup_dict['user']
 def test_delete_non_exsit_follower(self):
     self.set_up()
     flr_name = 'notExistFollower'
     ajax_dict = {'flr_name': flr_name}
     response = Utils.ajax_post_json(self.client, url_delete_follower, 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']