Changeset View
Changeset View
Standalone View
Standalone View
contrib/buildbot/test/test_endpoint_land.py
Show First 20 Lines • Show All 50 Lines • ▼ Show 20 Lines | def test_land_happyPath(self): | ||||
'value': 'user@bitcoinabc.org', | 'value': 'user@bitcoinabc.org', | ||||
}, { | }, { | ||||
'name': 'env.harborMasterTargetPHID', | 'name': 'env.harborMasterTargetPHID', | ||||
'value': 'UNRESOLVED', | 'value': 'UNRESOLVED', | ||||
}], | }], | ||||
}, | }, | ||||
}), | }), | ||||
})) | })) | ||||
assert response.status_code == 200 | self.assertEqual(response.status_code, 200) | ||||
assert response.get_json() == json.loads(triggerBuildResponse.content) | self.assertEqual( | ||||
response.get_json(), json.loads( | |||||
triggerBuildResponse.content)) | |||||
def test_land_invalid_json(self): | def test_land_invalid_json(self): | ||||
data = "not: a valid json" | data = "not: a valid json" | ||||
response = self.app.post('/land', headers=self.headers, data=data) | response = self.app.post('/land', headers=self.headers, data=data) | ||||
self.assertEqual(response.status_code, 415) | self.assertEqual(response.status_code, 415) | ||||
def test_land_missingArguments(self): | def test_land_missingArguments(self): | ||||
# Test otherwise valid requests with each required argument missing. | # Test otherwise valid requests with each required argument missing. | ||||
# All of them should fail with status code 400. | # All of them should fail with status code 400. | ||||
requiredArgs = [ | requiredArgs = [ | ||||
'revision', | 'revision', | ||||
'conduitToken', | 'conduitToken', | ||||
'committerName', | 'committerName', | ||||
'committerEmail', | 'committerEmail', | ||||
] | ] | ||||
for arg in requiredArgs: | for arg in requiredArgs: | ||||
data = landRequestData() | data = landRequestData() | ||||
setattr(data, arg, '') | setattr(data, arg, '') | ||||
response = self.app.post('/land', headers=self.headers, json=data) | response = self.app.post('/land', headers=self.headers, json=data) | ||||
assert response.status_code == 400 | self.assertEqual(response.status_code, 400) | ||||
if __name__ == '__main__': | if __name__ == '__main__': | ||||
unittest.main() | unittest.main() |