def test_user_sign_has_sign_in(self): """已签到""" data = {'eid': 1, 'phone': 13511001101} r = SignRequests().post(self.url,data) self.result = r.json() self.assertEqual(self.result['status'], 10027) self.assertEqual(self.result['message'], 'user has sign in')
def test_user_sign_phone_error(self): """phone=10100001111 手机号不存在""" data = {'eid': 1, 'phone': 10100001111} r = SignRequests().post(self.url, data) self.result = r.json() self.assertEqual(self.result['status'], 10025) self.assertEqual(self.result['message'], 'user phone null')
def test_user_sign_eid_phone_error(self): """eid=1, phone=13511001102 手机号与发布会不匹配""" data = {'eid': 1, 'phone': 13511001102} r = SignRequests().post(self.url, data) self.result = r.json() self.assertEqual(self.result['status'], 10026) self.assertEqual(self.result['message'], 'user did not participate in the conference')
def test_user_sign_status_close(self): """eid=3 发布会状态关闭""" data = {'eid': 3, 'phone': 13711001100} r = SignRequests().post(self.url, data) self.result = r.json() self.assertEqual(self.result['status'], 10023) self.assertEqual(self.result['message'], 'event status is not available')
def test_user_sign_time_start(self): """eid=4 发布会已开始""" data = {'eid': 4, 'phone': 13711001100} r = SignRequests().post(self.url, data) self.result = r.json() self.assertEqual(self.result['status'], 10024) self.assertEqual(self.result['message'], 'event has started')
def test_user_sign_all_null(self): """参数为空""" data = {'eid': '', 'phone': ''} r = SignRequests().post(self.url, data) self.result = r.json() self.assertEqual(self.result['status'], 10021) self.assertEqual(self.result['message'], 'parameter error')
def test_user_sign_eid_error(self): """eid=901 查询结果不存在""" data = {'eid': 901, 'phone': 13711001100} r = SignRequests().post(self.url, data) self.result = r.json() self.assertEqual(self.result['status'], 10022) self.assertEqual(self.result['message'], 'event id null')
def test_add_guest_success(self): """添加成功""" data = {'eid': 1, 'realname': 'tom', 'phone': 13511001199} r = SignRequests().post(self.url, data) self.result = r.json() self.assertEqual(self.result['status'], 200) self.assertEqual(self.result['message'], 'add guest success')
def test_add_guest_phone_repeat(self): """phone=13800113001 手机号重复""" data = {'eid': 1, 'realname': 'tom', 'phone': 13511001100} r = SignRequests().post(self.url, data) self.result = r.json() self.assertEqual(self.result['status'], 10026) self.assertEqual(self.result['message'], 'the event guest phone number repeat')
def test_add_guest_limit_full(self): """eid=2 发布会人数已满""" data = {'eid': 2, 'realname': 'tom', 'phone': 13711001100} r = SignRequests().post(self.url, data) self.result = r.json() self.assertEqual(self.result['status'], 10024) self.assertEqual(self.result['message'], 'event number is full')
def test_add_guest_status_close(self): """eid=2 状态未开启""" data = {'eid': 3, 'realname': 'tom', 'phone': 13711001100} r = SignRequests().post(self.url, data) self.result = r.json() self.assertEqual(self.result['status'], 10023) self.assertEqual(self.result['message'], 'event status is not available')
def test_user_sign_success(self): """签到成功""" data = {'eid': 1, 'phone': 13511001100} r = SignRequests().post(self.url, data) self.result = r.json() self.assertEqual(self.result['status'], 200) self.assertEqual(self.result['message'], 'sign success')
def test_add_guest_eid_null(self): """eid=901 查询为空""" data = {'eid': 901, 'realname': 'tom', 'phone': 13711001100} r = SignRequests().post(self.url, data) self.result = r.json() self.assertEqual(self.result['status'], 10022) self.assertEqual(self.result['message'], 'event id null')
def test_get_guest_list_eid_null(self): """eid 参数为空""" payload = {'eid': ''} r = SignRequests().get(self.url, payload) self.result = r.json() self.assertEqual(self.result['status'], 10021) self.assertEqual(self.result['message'], 'eid cannot be empty')
def test_get_event_list_nam_result_null(self): """关键字‘abc’查询""" payload = {'name': 'abc'} r = SignRequests().get(self.base_url, payload) self.result = r.json() self.assertEqual(self.result['status'], 10022) self.assertEqual(self.result['message'], 'query result is empty')
def test_get_event_list_eid_error(self): """eid=901 查询结果为空""" payload = {'eid': 901} r = SignRequests().get(self.url, payload) self.result = r.json() self.assertEqual(self.result['status'], 10022) self.assertEqual(self.result['message'], 'query result is empty')
def test_get_event_list_eid_phone_null(self): """根据 eid 和phone 查询结果为空""" payload = {'eid': 1, 'phone': '19500002412'} r = SignRequests().get(self.base_url, payload) self.result = r.json() self.assertEqual(self.result['status'], 10022) self.assertEqual(self.result['message'], 'query result is empty')
def test_get_event_list_name_find(self): """关键字‘发布会’模糊查询""" payload = {'name': '发布会'} r = SignRequests().get(self.base_url, payload) self.result = r.json() self.assertEqual(self.result['status'], 200) self.assertEqual(self.result['message'], 'success') self.assertEqual(self.result['data'][0]['name'], '红米Pro发布会') self.assertEqual(self.result['data'][0]['address'], '北京会展中心')
def test_get_event_list_eid_success(self): """根据 eid 查询结果成功""" payload = {'eid': 1} r = SignRequests().get(self.base_url, payload) self.result = r.json() self.assertEqual(self.result['status'], 200) self.assertEqual(self.result['message'], 'success') self.assertEqual(self.result['data']['name'], '红米Pro发布会') self.assertEqual(self.result['data']['address'], '北京会展中心')
def test_get_event_list_eid_phone_success(self): """根据 eid 和phone 查询结果成功""" payload = {'eid': 1, 'phone': '13511001100'} r = SignRequests().get(self.base_url, payload) self.result = r.json() self.assertEqual(self.result['status'], 200) self.assertEqual(self.result['message'], 'success') self.assertEqual(self.result['data']['realname'], 'alen') self.assertEqual(self.result['data']['phone'], '13511001100')
def test_add_event_success(self): """添加成功""" data = { 'eid': 11, 'name': '一加4手机发布会', 'limit': 2000, 'address': "深圳宝体", 'start_time': '2017-05-10 12:00:00' } r = SignRequests().post(self.url, data) self.result = r.json() self.assertEqual(self.result['status'], 200) self.assertEqual(self.result['message'], 'add event success')
def test_add_event_data_type_error(self): """日期格式错误""" data = { 'eid': 11, 'name': '一加4手机发布会', 'limit': 2000, 'address': "深圳宝体", 'start_time': '2017' } r = SignRequests().post(self.url, data) self.result = r.json() self.assertEqual(self.result['status'], 10024) self.assertIn('start_time format error.', self.result['message'])
def test_add_event_name_exist(self): """名称已经存在""" data = { 'eid': 11, 'name': '红米Pro发布会', 'limit': 2000, 'address': "深圳宝体", 'start_time': '2017' } r = SignRequests().post(self.url, data) self.result = r.json() self.assertEqual(self.result['status'], 10023) self.assertEqual(self.result['message'], 'event name already exists')
def test_add_event_eid_exist(self): """id已经存在""" payload = { 'eid': 1, 'name': '一加4发布会', 'limit': 2000, 'address': "深圳宝体", 'start_time': '2017' } r = SignRequests().post(self.url, data=payload) self.result = r.json() self.assertEqual(self.result['status'], 10022) self.assertEqual(self.result['message'], 'event id already exists')
def test_add_event_all_null(self): """所有参数为空""" data = { 'eid': '', '': '', 'limit': '', 'address': "", 'start_time': '' } r = SignRequests().post(self.url, data) self.result = r.json() self.assertEqual(self.result['status'], 10021) self.assertEqual(self.result['message'], 'parameter error')