class GetApartmentFloorListTest(unittest.TestCase): """ 获取公寓所有楼层信息 """ def setUp(self): print 'start run GetApartmentFloorList test ......connect server' self.ar_con = ARControl() self.ar_con.connect_server() self.account_id = 100861 def tearDown(self): print 'GetApartmentFloorList test complete.....close socket' def test_get_apartment_floor_list_success(self): """ 获取公寓所有楼层信息成功\ 开发:黄良江(900000)\ 测试:林冰晶(791099) """ self.ar_con.login(self.account_id, "im") res = self.ar_con.get_all_apartment() res_data = json.loads(res) apartment_code = res_data[0]["apartment_code"] self.ar_con.apply_apartment(apartment_code) # 有用户入住 res = self.ar_con.get_apartment_floor_list(apartment_code) res_data = json.loads(res) for floor in res_data: assert_that(floor, has_key("user_id"), "no user_id response...") assert_that(floor, has_key("sex"), "no sex response...") assert_that(floor, has_key("apartment_code"), "no apartment_code response...") assert_that(floor["apartment_code"], equal_to(apartment_code), "apartment_code not match...") assert_that(floor, has_key("floor"), "no floor response...") assert_that(floor, has_key("floor_name"), "no floor_name response...") assert_that(floor, has_key("nick_name"), "no nick_name response...") assert_that(floor, has_key("icon_code"), "no icon_code response...") def test_get_apartment_floor_list_notexist(self): """ 获取公寓所有楼层信息失败,不存在的公寓\ 开发:黄良江(900000)\ 测试:林冰晶(791099) """ self.ar_con.login(self.account_id, "im") apartment_code = CoRand.get_rand_int() res = self.ar_con.get_apartment_floor_list(apartment_code) res_data = json.loads(res) assert res_data == []
class UpdateFloorNameTest(unittest.TestCase): """ 重命名玩家楼层名称 """ def setUp(self): print 'start run UpdateFloorName test ......connect server' self.ar_con = ARControl() self.ar_con.connect_server() def tearDown(self): print 'UpdateFloorName test complete.....close socket' def test_update_floor_name_success(self): """ 重命名玩家楼层名称成功\ 开发:黄良江(900000)\ 测试:林冰晶(791099) """ account_id = CoRand.get_rand_int(100001) res = self.ar_con.login(account_id, "im") res_data = json.loads(res) user_id = res_data["user_id"] apartment_code = 1 res = self.ar_con.get_all_apartment() res_data = json.loads(res) for apartment in res_data: if apartment["is_full"] == 1: apartment_code = apartment["apartment_code"] break res = self.ar_con.apply_apartment(apartment_code) res_data = json.loads(res) floor = res_data["floor"] floor_name = u"重命名" res = self.ar_con.update_floor_name(apartment_code, floor_name, floor) res_data = json.loads(res) assert_that(res_data, has_key("code"), "no code response...") assert_that(res_data, has_key("err_msg"), "no err_msg response...") assert_that(res_data["code"], equal_to(EC_SUCCESS["code"]), "response code mismatching...") assert_that(res_data["err_msg"], equal_to(EC_SUCCESS["err_msg"]), "response msg mismatching...") res = self.ar_con.get_apartment_floor_list(apartment_code) res_data = json.loads(res) for user in res_data: if user["user_id"] == user_id: assert_that(user, has_key("floor_name"), "no floor_name response...") assert user[ "floor_name"] == floor_name, "response floor_name mismatching..." break