def test_createNoHouse(self): deleteResult = postAllAction.DeleteAllPost(self.mobile) if deleteResult: postData = self.post.createPost(readCsv.getPostData(1)) self.assertEquals(postData.json()['status'], '200', '创建无房的帖子失败') else: self.assertEquals(False, True, '删除房源失败')
def test_postValid(self): #先清除数据 deleteResult = postAllAction.DeleteAllPost(self.mobile) if deleteResult: createPost = self.post.createPost(readCsv.getPostData(1)) self.assertEquals(createPost.json()['status'], '200', '创建失败') else: return 'error'
def test_replyDataValid(self): deleteResult = postAllAction.DeleteAllPost(self.mobile) if deleteResult: createParam = readCsv.getPostData(3) createPostid = postAllAction.createPostAndReturn(self, createParam) replyData = self.post.postReplayList( testData.getReplyListData(createPostid)) self.assertEquals(replyData.json()['status'], '200', '帖子回复列表status非200')
def test_createVsDetail(self): deleteResult = postAllAction.DeleteAllPost(self.mobile) if deleteResult: createParam = readCsv.getPostData(2) createPostid = postAllAction.createPostAndReturn(self, createParam) postData = self.post.postDetail(testData.getPostId(createPostid)) compareResult = postAllAction.compareJSON(createParam, postData.json()) self.assertEquals(compareResult, True, '创建时和详情中的数据不一致')
def test_deleteByNotOwner(self): deleteResult = postAllAction.DeleteAllPost(self.mobile) self.assertEquals(deleteResult, True, '删除失败') createParam = readCsv.getPostData(3) createPost = self.post.createPost(createParam) self.assertEquals(createPost.json()['status'], '200', '创建帖子失败') another = HZAppAPI(self.anotherMobile) createId = createPost.json()['data']['post_id'] anotherDelete = another.singelDeletePost({"post_id": createId}) self.assertEquals(anotherDelete.json()['status'], '204', '可以删除其他人的帖子')
def test_replyDataVsReply(self): deleteResult = postAllAction.DeleteAllPost(self.mobile) if deleteResult: createParam = readCsv.getPostData(3) createPostid = postAllAction.createPostAndReturn(self, createParam) replyData = testData.getReplyData(createPostid, self.UserId) reply = self.post.postReplay(replyData) self.assertEquals(reply.json()['status'], '200', '回复失败') replyData = self.post.postReplayList( testData.getReplyListData(createPostid)) self.assertEquals(len(replyData.json()['data']), 1, '帖子回复获取数据与回复数不一致')
def test_detailVsDatabase(self): deleteResult = postAllAction.DeleteAllPost(self.mobile) if deleteResult: createParam = readCsv.getPostData(3) createPostid = postAllAction.createPostAndReturn(self, createParam) detailData = self.post.postDetail(testData.getPostId(createPostid)) db = GetTestData(self.mobile) dbResult = db.getPostDetailInfo( createParam['title'].decode('utf-8')) dbTest = postAllAction.compareDataBase(dbResult, detailData.json()['data']) self.assertEquals(dbTest, True, '创建时的数据和房源详情不一致')
def test_onlyCreate3(self): deleteResult = postAllAction.DeleteAllPost(self.mobile) if deleteResult: for i in range(1, 5): self.post.createPost(readCsv.getPostData(i)) if i == 4: postData = self.post.createPost(readCsv.getPostData(i)) print postData.text self.assertEquals(postData.json()['message'], u"该城市下最多发布3个帖子", '创建了超过3条帖子数') else: self.assertEquals(False, True, '删除房源失败')
def test_deletePost(self): deleteResult = postAllAction.DeleteAllPost(self.mobile) self.assertEquals(deleteResult, True, '删除接口失败')