'1. Test getting JWT token with wrong credentials and getting 401
2. Get JWT token with right credentials
3. Send a sample successful POST request'

def _test_model(self, name, data):

    path = (get_path() if (name == 'event') else get_path(1, (name + 's')))
    response = self._send_login_request('wrong_password')
    self.assertEqual(response.status_code, 401)
    response = self._send_login_request('test')
    self.assertEqual(response.status_code, 200)
    token = json.loads(response.data)['access_token']
    response = self.app.post(path, data=json.dumps(data), headers={'content-type': 'application/json', 'Authorization': ('JWT    %s' % token)})
    self.assertNotEqual(response.status_code, 401)
    self.assertEqual(response.status_code, 201)
    self.assertIn(('Test' + str(name).title()), response.data)
