def test_commit_data_from_post(self): self.make_user('josh', email='*****@*****.**') body = { "name": "Josh Marshall", "email": "*****@*****.**", "message": "Working on Tornado stuff!", "url": "https://github.com/project/commitID", "timestamp": 5430604985.0, "hash": "6a87af2a7eb3de1e17ac1cce41e060516b38c0e9" } body_json = json.dumps(body) resp = self.app.post('/api/v1/commits', body_json, headers={"Authorization": make_digest('josh')}) resp_body = json.loads(resp.body) # try to get the commit from the api resp = self.app.get('/api/v1/commits/%s' % resp_body['commits'][0]) commit = json.loads(resp.body) self.assertEqual(commit['name'], "Josh Marshall") self.assertEqual(commit['message'], "Working on Tornado stuff!") self.assertEqual(commit['url'], "https://github.com/project/commitID") self.assertEqual(commit['timestamp'], 5430604985) self.assertEqual(commit['hash'], "6a87af2a7eb3de1e17ac1cce41e060516b38c0e9")
def test_create_new_project(self): self.make_user('josh', email='*****@*****.**') body_json = json.dumps({'url': 'http://github.com/user/project'}) resp = self.app.post('/api/v1/projects', body_json, headers={"Authorization": make_digest('josh')}) self.assertEqual(resp.status_code, 201)
def test_create_new_project(self): self.make_user('josh', email='*****@*****.**') body_json = json.dumps({'url': 'http://github.com/user/project'}) resp = self.app.post('/api/v1/projects', body_json, headers={"Authorization": make_digest('josh')} ) self.assertEqual(resp.status_code, 201)
def test_malformed_post(self): self.make_user('josh', email='*****@*****.**') # post missing required field body = { "name": "Josh Marshall"} body_json = json.dumps(body) resp = self.app.post('/api/v1/commits', body_json, headers={"Authorization": make_digest('josh')}, status=400) self.assertEqual(resp.status_code, 400)
def test_bad_user(self): body = {"message": "Josh Marshall"} body_json = json.dumps(body) resp = self.app.post('/api/v1/commits', body_json, headers={"Authorization": make_digest('josh')}, status=403) self.assertEqual(resp.status_code, 403)
def test_malformed_post(self): self.make_user('josh', email='*****@*****.**') body_json = json.dumps({'bad': 'http://github.com/user/project'}) resp = self.app.post('/api/v1/projects', body_json, headers={"Authorization": make_digest('josh')}, status=400) resp_body = json.loads(resp.body) self.assertEqual(resp_body['url'], ["This field is required."])
def test_error_response(self): self.make_user('josh', email='*****@*****.**') # post missing required field body = { "name": "Josh Marshall"} body_json = json.dumps(body) resp = self.app.post('/api/v1/commits', body_json, headers={"Authorization": make_digest('josh')}, status=400) resp_body = json.loads(resp.body) self.assertEqual(resp_body['message'], ['This field is required.'])
def test_malformed_post(self): self.make_user('josh', email='*****@*****.**') # post missing required field body = {"name": "Josh Marshall"} body_json = json.dumps(body) resp = self.app.post('/api/v1/commits', body_json, headers={"Authorization": make_digest('josh')}, status=400) self.assertEqual(resp.status_code, 400)
def test_error_response(self): self.make_user('josh', email='*****@*****.**') # post missing required field body = {"name": "Josh Marshall"} body_json = json.dumps(body) resp = self.app.post('/api/v1/commits', body_json, headers={"Authorization": make_digest('josh')}, status=400) resp_body = json.loads(resp.body) self.assertEqual(resp_body['message'], ['This field is required.'])
def test_commit_post(self): self.make_user('josh', email='*****@*****.**') body = { "name": "Josh Marshall", "email": "*****@*****.**", "message": "Working on Tornado stuff!", "url": "https://github.com/project/commitID", "timestamp": 5430604985.0, "hash": "6a87af2a7eb3de1e17ac1cce41e060516b38c0e9"} body_json = json.dumps(body) resp = self.app.post('/api/v1/commits', body_json, headers={"Authorization": make_digest('josh')}) self.assertEqual(resp.status_code, 201)
def test_commit_post(self): self.make_user('josh', email='*****@*****.**') body = { "name": "Josh Marshall", "email": "*****@*****.**", "message": "Working on Tornado stuff!", "url": "https://github.com/project/commitID", "timestamp": 5430604985.0, "hash": "6a87af2a7eb3de1e17ac1cce41e060516b38c0e9" } body_json = json.dumps(body) resp = self.app.post('/api/v1/commits', body_json, headers={"Authorization": make_digest('josh')}) self.assertEqual(resp.status_code, 201)
def test_commit_data_from_post(self): self.make_user('josh', email='*****@*****.**') body = { "name": "Josh Marshall", "email": "*****@*****.**", "message": "Working on Tornado stuff!", "url": "https://github.com/project/commitID", "timestamp": 5430604985.0, "hash": "6a87af2a7eb3de1e17ac1cce41e060516b38c0e9"} body_json = json.dumps(body) resp = self.app.post('/api/v1/commits', body_json, headers={"Authorization": make_digest('josh')}) resp_body = json.loads(resp.body) # try to get the commit from the api resp = self.app.get('/api/v1/commits/%s' % resp_body['commits'][0]) commit = json.loads(resp.body) self.assertEqual(commit['name'], "Josh Marshall") self.assertEqual(commit['message'], "Working on Tornado stuff!") self.assertEqual(commit['url'], "https://github.com/project/commitID") self.assertEqual(commit['timestamp'], 5430604985) self.assertEqual(commit['hash'], "6a87af2a7eb3de1e17ac1cce41e060516b38c0e9")
def test_bad_user(self): body = { "message": "Josh Marshall"} body_json = json.dumps(body) resp = self.app.post('/api/v1/commits', body_json, headers={"Authorization": make_digest('josh')}, status=403) self.assertEqual(resp.status_code, 403)