def test_add_user(self): count = AppUser.query.count() res = self.client.post('/api/v1/user/add', data=dict(email='*****@*****.**', username='******', password='******')) self.assertEqual(len(AppUser.get_all()), count + 1)
def test_get_user_posts(self): user = AppUser.get_all()[0] res = self.client.post('/api/v1/user/{0}/posts'.format(user.id)) posts = json.loads(res.get_data()) self.assertEqual(posts, map(lambda x: x.to_json(), user.posts.all()))
def test_add_user(self): count = AppUser.query.count() res = self.client.post('/api/v1/user/add',data=dict(email='*****@*****.**',username='******',password='******')) self.assertEqual(len(AppUser.get_all()),count+1)
def test_get_user_posts(self): user = AppUser.get_all()[0] res = self.client.post('/api/v1/user/{0}/posts'.format(user.id)) posts = json.loads(res.get_data()) self.assertEqual(posts,map(lambda x: x.to_json(),user.posts.all()))