def test_add_following_anchor_id_null(self):
     """
     测试请求加关注接口主播ID为空
     :return:
     """
     add_following_api = AddFollowingApi(self.login_name)
     add_following_api.get({'anchor_id': ''})
     self.assertEqual(add_following_api.get_code(), 402005)
     self.assertEqual(add_following_api.get_response_message(), u'主播ID不能为空')
 def test_add_following_anchor_id_error(self):
     """
     测试请求加关注接口主播ID不存在
     :return:
     """
     add_following_api = AddFollowingApi(self.login_name)
     add_following_api.get({'anchor_id': str(self.anchor_id) + '1'})
     self.assertEqual(add_following_api.get_code(), 402008)
     self.assertEqual(add_following_api.get_response_message(), u'主播信息不存在')
示例#3
0
    def test_buy_sun_following_success(self):
        """
        测试关注主播情况下购买太阳成功
        :return:
        """
        follow_api = AddFollowingApi(self.user_mobile)
        follow_api.get({'anchor_id': self.anchor_id})
        self.assertEqual(follow_api.get_code(), 0)

        live_api = LiveApi(self.user_mobile)
        response = live_api.get({'room_id': self.room_id})
        self.assertEqual(live_api.get_code(), 0)

        identity_obj = json.loads(response.content)['result']['identity_obj']
        self.assertEqual(identity_obj['user_experience'], 0)
        intimacy_obj = identity_obj['intimacy_obj']
        self.assertEqual(intimacy_obj['intimacy_experience'], 0)

        sun_num = json.loads(response.content)['result']['room_obj']['sun_num']

        MysqlOperation(user_id=self.user_id).fix_user_account(gold_num=2000)
        RedisHold().clean_redis_user_detail(self.user_id)
        time.sleep(0.5)

        buy_sun_api = BuySunApi(self.user_mobile)
        response = buy_sun_api.get({'room_id': self.room_id})
        self.assertEqual(buy_sun_api.get_code(), 0)

        identity_obj = json.loads(response.content)['result']['identity_obj']
        self.assertEqual(identity_obj['gold'], 0)  # 校验用户剩余金币
        self.assertEqual(identity_obj['sun_num'], 0)  # 校验用户剩余太阳数量不变
        self.assertEqual(identity_obj['user_experience'], 2000)  # 校验用户经验值增加

        intimacy_obj = identity_obj['intimacy_obj']
        self.assertEqual(intimacy_obj['intimacy_experience'], 200)  # 校验用户亲密度增加

        after_sun_num = json.loads(
            response.content)['result']['room_obj']['sun_num']
        self.assertEqual(after_sun_num - sun_num, 20)  # 校验主播获得的太阳数量增加

        consum_api = ConsumptionApi(self.user_mobile)
        response = consum_api.get()
        self.assertEqual(consum_api.get_code(), 0)
        consume_list = json.loads(response.content)['result']['consume_list']
        # 校验消费记录
        self.assertEqual(len(consume_list), 1)
        self.assertEqual(consume_list[0]['user_id'], self.user_id)
        self.assertEqual(consume_list[0]['type'], u'5')
        self.assertEqual(consume_list[0]['gold'], 2000)
        self.assertEqual(consume_list[0]['corresponding_id'], 0)
        self.assertEqual(consume_list[0]['corresponding_name'], u'太阳')
        self.assertEqual(consume_list[0]['corresponding_num'], 1)
        self.assertEqual(consume_list[0]['room_id'], self.room_id)
        self.assertEqual(consume_list[0]['status'], 1)
        self.assertEqual(consume_list[0]['behavior_desc'], u'购买太阳')
        self.assertEqual(consume_list[0]['consumption_type'], u'2000金币')
示例#4
0
    def test_send_package_gift_success(self):
        """
        测试送出为你伴舞礼物
        :return:
        """
        add_following_api = AddFollowingApi(self.login_name)
        add_following_api.get({'anchor_id': self.anchor_id})
        self.assertEqual(add_following_api.get_code(), 0)
        self.assertEqual(add_following_api.get_response_message(), u'操作成功')

        live_api = LiveApi(self.login_name)
        response = live_api.get({'room_id': self.room_id})
        self.assertEqual(live_api.get_code(), 0)
        room_hot_num = json.loads(
            response.content)['result']['room_obj']['curr_hot_num']

        RedisHold().add_user_package_gift(self.user_id,
                                          gift_id=self.package_gift_id,
                                          gift_num=1)
        time.sleep(self.time_sleep)

        send_gift_api = SendGiftApi(self.login_name)
        response = send_gift_api.get({
            'room_id': self.room_id,
            'gift_id': self.package_gift_id,
            'gift_count': 1,
            'currency': 'bag'
        })

        self.assertEqual(send_gift_api.get_code(), 0)
        self.assertEqual(
            json.loads(response.content)['result']['identity_obj']['gold'], 0)
        identity_obj = json.loads(response.content)['result']['identity_obj']
        self.assertEqual(identity_obj['gold'], 0)
        self.assertEqual(identity_obj['user_rank'], 3)
        self.assertEqual(identity_obj['user_experience'], 0)
        intimacy_obj = identity_obj['intimacy_obj']
        self.assertEqual(intimacy_obj['intimacy_rank'], 4)
        self.assertEqual(intimacy_obj['intimacy_experience'], 0)
        intimacy_level_obj = intimacy_obj['intimacy_level_obj']
        self.assertEqual(intimacy_level_obj['level'], 1)

        anchor_obj = json.loads(
            response.content)['result']['room_obj']['anchor_obj']
        self.assertEqual(anchor_obj['anchor_rank'], 2)
        self.assertEqual(anchor_obj['anchor_experience'], 50000)

        time.sleep(self.time_sleep)

        live_api = LiveApi(self.login_name)
        response = live_api.get({'room_id': self.room_id})
        self.assertEqual(live_api.get_code(), 0)
        room_hot_num_after_send = json.loads(
            response.content)['result']['room_obj']['curr_hot_num']

        self.assertEqual(room_hot_num_after_send - room_hot_num, 100000)
    def test_add_following_successful(self):
        """
        测试关注主播成功/我的关注列表/取消关注成功
        :return:
        """
        # 关注主播
        add_following_api = AddFollowingApi(self.login_name)
        response = add_following_api.get({'anchor_id': self.anchor_id})
        self.assertEqual(add_following_api.get_code(), 0)
        self.assertEqual(add_following_api.get_response_message(), u'操作成功')
        self.assertEqual(json.loads(response.content)['result']['identity_obj']['has_followed'],1)

        add_following_again = AddFollowingApi(self.login_name)
        add_following_again.get({'anchor_id': self.anchor_id})
        self.assertEqual(add_following_again.get_code(),402007)
        self.assertEqual(add_following_again.get_response_message(),u'当前主播已经添加到我的关注')

        my_follow_list = MyFollowListApi(self.login_name)
        response = my_follow_list.get()
        self.assertEqual(my_follow_list.get_code(),0)
        room_list = json.loads(response.content)['result']['room_list']
        self.assertEqual(len(room_list),1)
        self.assertEqual(room_list[0]['to_user_id'],(self.anchor_id))
        self.assertEqual(room_list[0]['room_obj']['id'],(settings.YULE_TEST_ROOM))

        # 校验取消关注
        relieve_following_api = RelieveFollowingApi(self.login_name)
        response = relieve_following_api.get({'anchor_id': self.anchor_id})
        self.assertEqual(relieve_following_api.get_code(),0)
        self.assertEqual(relieve_following_api.get_response_message(),u'操作成功')
        self.assertEqual(json.loads(response.content)['result']['identity_obj']['has_followed'],0)

        my_follow_list = MyFollowListApi(self.login_name)
        response = my_follow_list.get()
        self.assertEqual(my_follow_list.get_code(), 0)
        room_list = json.loads(response.content)['result']['room_list']
        self.assertEqual(len(room_list), 0)
示例#6
0
    def action(self, **kwargs):
        guard_price = 0
        guard_id = kwargs['guard_id']
        user_rank = kwargs['user_rank']
        sun_max_num = kwargs['sun_max_num']
        anchor_rank = kwargs['anchor_rank']
        following = kwargs['following']
        expire_time_num = None
        guard_rank = None

        if guard_id == 1:
            guard_price = 588000
        elif guard_id == 2:
            guard_price = 1176000
        elif guard_id == 3:
            guard_price = 1764000
        elif guard_id == 6:
            guard_price = 3528000
        elif guard_id == 12:
            guard_price = 7056000
        elif guard_id == 13:
            guard_price = 14112000
        mysql_operation = MysqlOperation(user_id=self.user_id)
        mysql_operation.fix_user_account(gold_num=guard_price)
        RedisHold().clean_redis_user_detail(self.user_id)
        time.sleep(self.time_sleep)

        live_api = LiveApi(self.login_name)
        response = live_api.get({'room_id': self.room_id})
        self.assertEqual(live_api.get_code(), 0)
        room_hot_num = json.loads(
            response.content)['result']['room_obj']['curr_hot_num']

        if following:
            add_following_api = AddFollowingApi(self.login_name)
            response = add_following_api.get({'anchor_id': self.anchor_id})
            self.assertEqual(add_following_api.get_code(), 0)
            self.assertEqual(add_following_api.get_response_message(), u'操作成功')
            self.assertEqual(
                json.loads(response.content)['result']['identity_obj']
                ['has_followed'], 1)

        buy_guard_api = BuyGuardApi(self.login_name)
        response = buy_guard_api.get({
            'room_id': self.room_id,
            'guard_id': guard_id,
            'currency': 'gold'
        })

        self.assertEqual(buy_guard_api.get_code(), 0)

        guard_list = json.loads(response.content)['result']['guard_list']
        self.assertEqual(len(guard_list), 1)
        self.assertEqual(guard_list[0]['user_rank'], user_rank)
        self.assertEqual(guard_list[0]['user_experience_all'], guard_price)
        self.assertEqual(guard_list[0]['sun_resumed_time'], 180)
        self.assertEqual(guard_list[0]['sun_max_num'], sun_max_num)

        user_guard_obj = guard_list[0]['user_guard_obj']
        self.assertEqual(user_guard_obj['user_id'], (self.user_id))

        def assert_guard_obj(obj, guard_id):
            if guard_id == 1:
                guard_rank = 1
                expire_time_num = range(28, 32)
                self.assertEqual(user_guard_obj['guard_rank'], guard_rank)
                self.assertIn(user_guard_obj['rest_time_int'], expire_time_num)
                expire_time_num_format = []
                for x in expire_time_num:
                    expire_time_num_format.append(u'{0}天'.format(x))
                self.assertIn(user_guard_obj['rest_time_str'],
                              expire_time_num_format)

            elif guard_id == 2:
                guard_rank = 2
                expire_time_num = range(59, 63)
                self.assertEqual(user_guard_obj['guard_rank'], guard_rank)
                self.assertIn(user_guard_obj['rest_time_int'], expire_time_num)
                expire_time_num_format = []
                for x in expire_time_num:
                    expire_time_num_format.append(u'{0}天'.format(x))
                self.assertIn(user_guard_obj['rest_time_str'],
                              expire_time_num_format)
            elif guard_id in [3, 6]:
                guard_rank = 3
                self.assertEqual(user_guard_obj['guard_rank'], guard_rank)
                if guard_id == 3:
                    expire_time_num = range(89, 94)
                    self.assertIn(user_guard_obj['rest_time_int'],
                                  expire_time_num)
                    expire_time_num_format = []
                    for x in expire_time_num:
                        expire_time_num_format.append(u'{0}天'.format(x))
                    self.assertIn(user_guard_obj['rest_time_str'],
                                  expire_time_num_format)
                elif guard_id == 6:
                    expire_time_num = range(183, 187)
                    self.assertIn(user_guard_obj['rest_time_int'],
                                  expire_time_num)
                    expire_time_num_format = []
                    for x in expire_time_num:
                        expire_time_num_format.append(u'{0}天'.format(x))
                    self.assertIn(user_guard_obj['rest_time_str'],
                                  expire_time_num_format)
            elif guard_id in [12, 13]:
                guard_rank = 4
                self.assertEqual(user_guard_obj['guard_rank'], guard_rank)
                if guard_id == 12:
                    expire_time_num = range(369, 373)
                    self.assertIn(user_guard_obj['rest_time_int'],
                                  expire_time_num)
                    expire_time_num_format = []
                    for x in expire_time_num:
                        expire_time_num_format.append(u'{0}天'.format(x))
                    self.assertIn(user_guard_obj['rest_time_str'],
                                  expire_time_num_format)
                elif guard_id == 13:
                    expire_time_num = range(739, 745)
                    self.assertIn(user_guard_obj['rest_time_int'],
                                  expire_time_num)
                    expire_time_num_format = []
                    for x in expire_time_num:
                        expire_time_num_format.append(u'{0}天'.format(x))
                    self.assertIn(user_guard_obj['rest_time_str'],
                                  expire_time_num_format)

        assert_guard_obj(obj=user_guard_obj, guard_id=guard_id)

        intimacy_obj = guard_list[0]['intimacy_obj']

        def assert_intimacy(obj, following, guard_id, identity=False):
            inti_dic = {}
            if guard_id == 1:
                inti_dic = {
                    'intimacy_experience': 113000,
                    'intimacy_rank': 7,
                    'level': 1,
                    'level_name': u'喜爱'
                }
            elif guard_id == 2:
                inti_dic = {
                    'intimacy_experience': 76000,
                    'intimacy_rank': 10,
                    'level': 1,
                    'level_name': u'喜爱'
                }
            elif guard_id == 3:
                inti_dic = {
                    'intimacy_experience': 264000,
                    'intimacy_rank': 11,
                    'level': 1,
                    'level_name': u'喜爱'
                }
            elif guard_id == 6:
                inti_dic = {
                    'intimacy_experience': 528000,
                    'intimacy_rank': 13,
                    'level': 1,
                    'level_name': u'喜爱'
                }
            elif guard_id == 12:
                inti_dic = {
                    'intimacy_experience': 56000,
                    'intimacy_rank': 15,
                    'level': 1,
                    'level_name': u'喜爱'
                }
            elif guard_id == 13:
                inti_dic = {
                    'intimacy_experience': 112000,
                    'intimacy_rank': 17,
                    'level': 2,
                    'level_name': u'真爱'
                }

            if following:
                self.assertEqual(obj['intimacy_experience'],
                                 inti_dic['intimacy_experience'])
                self.assertEqual(obj['intimacy_rank'],
                                 inti_dic['intimacy_rank'])
                intimacy_level_obj = obj['intimacy_level_obj']
                self.assertEqual(intimacy_level_obj['level'],
                                 inti_dic['level'])
                self.assertEqual(intimacy_level_obj['level_name'],
                                 inti_dic['level_name'])
                if guard_id == 13:
                    self.assertEqual(intimacy_level_obj['rank_start'], 16)
                    self.assertEqual(intimacy_level_obj['rank_end'], 30)
                else:
                    self.assertEqual(intimacy_level_obj['rank_start'], 1)
                    self.assertEqual(intimacy_level_obj['rank_end'], 15)
            else:
                if identity:
                    self.assertEqual(obj['intimacy_experience'], 0)
                    self.assertEqual(obj['intimacy_rank'], 1)
                    self.assertEqual(obj['intimacy_next_experience'], 10000)
                    self.assertEqual(obj['intimacy_level_obj']['level'], 1)
                    self.assertEqual(obj['intimacy_level_obj']['level_name'],
                                     u'喜爱')
                    self.assertEqual(obj['intimacy_level_obj']['rank_start'],
                                     1)
                    self.assertEqual(obj['intimacy_level_obj']['rank_end'], 15)
                else:
                    self.assertEqual(obj['intimacy_experience'], 0)
                    self.assertEqual(obj['intimacy_rank'], 0)
                    self.assertEqual(obj['intimacy_next_experience'], 0)
                    self.assertIsNone(obj['intimacy_level_obj'])

        assert_intimacy(intimacy_obj, following, guard_id)

        identity_obj = json.loads(response.content)['result']['identity_obj']
        identity_user_guard_obj = identity_obj['user_guard_obj']
        self.assertEqual(identity_user_guard_obj['user_id'], (self.user_id))
        assert_guard_obj(obj=identity_user_guard_obj, guard_id=guard_id)

        identity_intimacy_obj = json.loads(
            response.content)['result']['identity_obj']['intimacy_obj']
        assert_intimacy(identity_intimacy_obj,
                        following,
                        guard_id,
                        identity=True)

        if following:
            self.assertEqual(identity_obj['has_followed'], 1)
        else:
            self.assertEqual(identity_obj['has_followed'], 0)

        anchor_obj = json.loads(
            response.content)['result']['room_obj']['anchor_obj']
        self.assertEqual(anchor_obj['id'], self.anchor_id)
        self.assertEqual(anchor_obj['anchor_rank'], anchor_rank)
        self.assertEqual(anchor_obj['sun_resumed_time'], 180)
        self.assertEqual(anchor_obj['sun_max_num'], 50)

        live_api = LiveApi(self.login_name)
        response = live_api.get({'room_id': self.room_id})
        self.assertEqual(live_api.get_code(), 0)
        room_hot_num_after_buy = json.loads(
            response.content)['result']['room_obj']['curr_hot_num']

        self.assertEqual(room_hot_num_after_buy - room_hot_num, guard_price)

        consumption_api = ConsumptionApi(self.login_name)
        response = consumption_api.get()
        self.assertEqual(consumption_api.get_code(), 0)
        self.assertEqual(
            len(json.loads(response.content)['result']['consume_list']), 1)
        consume_list = json.loads(
            response.content)['result']['consume_list'][0]
        self.assertEqual(consume_list['user_id'], self.user_id)
        self.assertEqual(consume_list['type'], u'3')
        self.assertEqual(consume_list['gold'], guard_price)
        self.assertEqual(consume_list['corresponding_id'], guard_id)
        self.assertEqual(consume_list['corresponding_name'], u'守护')
        self.assertEqual(consume_list['corresponding_num'], 1)
        self.assertEqual(consume_list['room_id'], self.room_id)
        self.assertEqual(consume_list['status'], 1)
        self.assertEqual(consume_list['behavior_desc'], u'购买守护')
        self.assertEqual(
            consume_list['room_title'],
            MysqlOperation(room_id=self.room_id).get_room_details()['title'])
        self.assertEqual(consume_list['consumption_type'],
                         u'%s金币' % guard_price)

        my_guard_api = MyGuardApi(self.login_name)
        response = my_guard_api.get()

        self.assertEqual(my_guard_api.get_code(), 0)
        guard_list = json.loads(response.content)['result']['guard_list']
        self.assertEqual(len(guard_list), 1)
        self.assertEqual(guard_list[0]['anchor_id'], self.anchor_id)
        if guard_id == 1:
            guard_rank = 1
            expire_time_num = 31
        elif guard_id == 2:
            guard_rank = 2
            expire_time_num = 62
        elif guard_id in [3, 6]:
            guard_rank = 3
            if guard_id == 3:
                expire_time_num = 93
            elif guard_id == 6:
                expire_time_num = 186
        elif guard_id in [12, 13]:
            guard_rank = 4
            if guard_id == 12:
                expire_time_num = 372
            elif guard_id == 13:
                expire_time_num = 744
        expire_time = (
            datetime.datetime.now() +
            datetime.timedelta(days=+expire_time_num)).strftime("%Y-%m-%d")
        self.assertIn(expire_time, guard_list[0]['expire_time'])
        self.assertEqual(guard_list[0]['guard_rank'], guard_rank)

        room_obj = guard_list[0]['room_obj']
        self.assertEqual(room_obj['id'], self.room_id)
        self.assertEqual(room_obj['room_type'], 1)
        self.assertEqual(room_obj['room_style'], 1)
        self.assertEqual(room_obj['room_style_extend'], 0)
        guard_list_anchor_obj = room_obj['anchor_obj']
        self.assertEqual(guard_list_anchor_obj['id'], self.anchor_id)
        self.assertEqual(guard_list_anchor_obj['anchor_rank'], anchor_rank)
        if guard_id in [1, 2, 3, 12]:

            enter_room_api = EnterRoomApi(self.login_name)
            response = enter_room_api.get({'room_id': self.room_id})
            self.assertEqual(enter_room_api.get_code(), 0)

            ani_obj = json.loads(
                response.content
            )['result']['enter_room_message']['msg']['obj']['ani_obj']
            self.assertEqual(ani_obj['ani_type'], u'entry_guard')
            if guard_id == 1:
                self.assertEqual(ani_obj['ani_id'], 1)
            elif guard_id == 2:
                self.assertEqual(ani_obj['ani_id'], 2)
            elif guard_id == 3:
                self.assertEqual(ani_obj['ani_id'], 3)
            elif guard_id == 12:
                self.assertEqual(ani_obj['ani_id'], 4)
            self.assertEqual(ani_obj['ani_num'], 0)
            self.assertIsNone(ani_obj['category_type'])
示例#7
0
    def send_gift_action(self, **kwargs):
        gift_gold = kwargs['gift_gold']
        gift_diamond = kwargs['gift_diamond']
        gift_id = kwargs['gift_id']
        gift_num = kwargs['gift_num']
        is_following = kwargs['is_following']
        if gift_gold > 0:
            currency = 'gold'
        elif gift_diamond > 0:
            currency = 'diamond'
        else:
            currency = 'bag'

        if is_following:
            add_following_api = AddFollowingApi(self.login_name)
            response = add_following_api.get({'anchor_id': self.anchor_id})
            self.assertEqual(add_following_api.get_code(), 0)
            self.assertEqual(add_following_api.get_response_message(), u'操作成功')
            self.assertEqual(
                json.loads(response.content)['result']['identity_obj']
                ['has_followed'], 1)

        live_api = LiveApi(self.login_name)
        response = live_api.get({'room_id': self.room_id})
        self.assertEqual(live_api.get_code(), 0)
        room_hot_num = json.loads(
            response.content)['result']['room_obj']['curr_hot_num']
        while self.count < self.max_count:
            mysql_operation = MysqlOperation(user_id=self.user_id)
            mysql_operation.fix_user_account(gold_num=gift_gold * gift_num,
                                             diamond_num=gift_diamond *
                                             gift_num)
            RedisHold().clean_redis_user_detail(self.user_id)
            time.sleep(self.time_sleep)
            send_gift_api = SendGiftApi(self.login_name)
            response = send_gift_api.get({
                'room_id': self.room_id,
                'gift_id': gift_id,
                'gift_count': gift_num,
                'currency': currency
            })
            if send_gift_api.get_code() == 100032:
                time.sleep(self.time_sleep)
                self.count += 1
            else:

                self.assertEqual(send_gift_api.get_code(), 0)
                break
        self.assertLess(self.count, self.max_count)

        gift_details = MysqlOperation().get_gift_details(gift_id=gift_id)
        identity_obj = json.loads(response.content)['result']['identity_obj']
        self.assertEqual(identity_obj['gold'], 0)
        self.assertEqual(identity_obj['diamond'], u'0')

        user_exp = self.get_user_exp_and_rank(
            gift_details['add_user_experience'] * gift_num)

        self.assertEqual(identity_obj['user_experience'], user_exp['exp'])
        self.assertEqual(identity_obj['user_rank'], user_exp['rank'])

        def assert_intimacy(obj, following, gift_num):
            inti_dic = {}
            if gift_num == 1:
                inti_dic = {
                    'intimacy_experience': 1000,
                    'intimacy_rank': 1,
                    'level': 1,
                    'level_name': u'喜爱'
                }
            elif gift_num == 10:
                inti_dic = {
                    'intimacy_experience': 0,
                    'intimacy_rank': 2,
                    'level': 1,
                    'level_name': u'喜爱'
                }
            elif gift_num == 66:
                inti_dic = {
                    'intimacy_experience': 16000,
                    'intimacy_rank': 3,
                    'level': 1,
                    'level_name': u'喜爱'
                }
            elif gift_num == 99:
                inti_dic = {
                    'intimacy_experience': 49000,
                    'intimacy_rank': 3,
                    'level': 1,
                    'level_name': u'喜爱'
                }
            elif gift_num == 188:
                inti_dic = {
                    'intimacy_experience': 88000,
                    'intimacy_rank': 4,
                    'level': 1,
                    'level_name': u'喜爱'
                }
            elif gift_num == 520:
                inti_dic = {
                    'intimacy_experience': 45000,
                    'intimacy_rank': 7,
                    'level': 1,
                    'level_name': u'喜爱'
                }
            elif gift_num == 1314:
                inti_dic = {
                    'intimacy_experience': 214000,
                    'intimacy_rank': 10,
                    'level': 1,
                    'level_name': u'喜爱'
                }

            if following:
                self.assertEqual(obj['intimacy_experience'],
                                 inti_dic['intimacy_experience'])
                self.assertEqual(obj['intimacy_rank'],
                                 inti_dic['intimacy_rank'])
                intimacy_level_obj = obj['intimacy_level_obj']
                self.assertEqual(intimacy_level_obj['level'],
                                 inti_dic['level'])
                self.assertEqual(intimacy_level_obj['level_name'],
                                 inti_dic['level_name'])
                self.assertEqual(intimacy_level_obj['rank_start'], 1)
                self.assertEqual(intimacy_level_obj['rank_end'], 15)
            else:
                for x in [
                        obj['intimacy_experience'], obj['intimacy_rank'],
                        obj['intimacy_next_experience']
                ]:
                    self.assertEqual(x, 0)
                self.assertIsNone(obj['intimacy_level_obj'])

        intimacy_obj = identity_obj['intimacy_obj']
        assert_intimacy(intimacy_obj, is_following, gift_num)

        anchor_obj = json.loads(
            response.content)['result']['room_obj']['anchor_obj']
        anchor_exp = self.get_anchor_exp_and_rank(
            gift_details['add_anchor_experience'] * gift_num)
        self.assertEqual(anchor_obj['anchor_experience'], anchor_exp['exp'])
        self.assertEqual(anchor_obj['anchor_rank'], anchor_exp['rank'])

        live_api = LiveApi(self.login_name)
        response = live_api.get({'room_id': self.room_id})
        self.assertEqual(live_api.get_code(), 0)
        room_hot_num_after = json.loads(
            response.content)['result']['room_obj']['curr_hot_num']
        if gift_gold > 0:
            self.assertEqual(
                int(room_hot_num_after) - int(room_hot_num),
                gift_gold * gift_num)
        if gift_diamond > 0:
            self.assertEqual(
                int(room_hot_num_after) - int(room_hot_num),
                gift_diamond / 10 * gift_num)

        consumption_api = ConsumptionApi(self.login_name)
        response = consumption_api.get()
        self.assertEqual(consumption_api.get_code(), 0)
        consume_list = json.loads(
            response.content)['result']['consume_list'][0]
        self.assertEqual(consume_list['user_id'], self.user_id)
        self.assertEqual(consume_list['type'], u'1')
        self.assertEqual(consume_list['gold'], (gift_gold * gift_num))
        self.assertEqual(consume_list['corresponding_id'], gift_id)
        self.assertEqual(consume_list['corresponding_name'],
                         MysqlOperation().get_gift_details(gift_id)['name'])
        self.assertEqual(consume_list['corresponding_num'], gift_num)
        self.assertEqual(consume_list['room_id'], self.room_id)
        self.assertEqual(consume_list['status'], 1)
        self.assertEqual(consume_list['behavior_desc'], u'送礼')
        self.assertEqual(
            consume_list['room_title'],
            MysqlOperation(room_id=self.room_id).get_room_details()['title'])
        self.assertEqual(consume_list['consumption_type'],
                         u'%s金币' % (gift_gold * gift_num))