Changeset View
Changeset View
Standalone View
Standalone View
contrib/buildbot/test/test_endpoint_backportcheck.py
Show All 16 Lines | def test_backportCheck_happyPath(self): | ||||
'id': '1234', | 'id': '1234', | ||||
'fields': { | 'fields': { | ||||
'summary': 'This is a test summary' | 'summary': 'This is a test summary' | ||||
}, | }, | ||||
}]) | }]) | ||||
response = self.post_json_with_hmac( | response = self.post_json_with_hmac( | ||||
'/backportCheck', self.headers, {'object': {'phid': '1234'}}) | '/backportCheck', self.headers, {'object': {'phid': '1234'}}) | ||||
assert response.status_code == 200 | self.assertEqual(response.status_code, 200) | ||||
self.phab.differential.revision.search.assert_called_with( | self.phab.differential.revision.search.assert_called_with( | ||||
constraints={"phids": ['1234']}) | constraints={"phids": ['1234']}) | ||||
self.phab.differential.revision.edit.assert_not_called() | self.phab.differential.revision.edit.assert_not_called() | ||||
def test_backportCheck_invalid_json(self): | def test_backportCheck_invalid_json(self): | ||||
response = self.post_data_with_hmac( | response = self.post_data_with_hmac( | ||||
'/backportCheck', self.headers, "not: a valid json") | '/backportCheck', self.headers, "not: a valid json") | ||||
self.assertEqual(response.status_code, 415) | self.assertEqual(response.status_code, 415) | ||||
Show All 19 Lines | def test_backportCheck_hasNoPRs(self): | ||||
" Ignore this indented secp256k1 PR456" | " Ignore this indented secp256k1 PR456" | ||||
"Ignore long numbered PRs for secp256k1: PR1234" | "Ignore long numbered PRs for secp256k1: PR1234" | ||||
"Ignore short numbered PRs for secp256k1: PR1", | "Ignore short numbered PRs for secp256k1: PR1", | ||||
}, | }, | ||||
}]) | }]) | ||||
response = self.post_json_with_hmac( | response = self.post_json_with_hmac( | ||||
'/backportCheck', self.headers, {'object': {'phid': '1234'}}) | '/backportCheck', self.headers, {'object': {'phid': '1234'}}) | ||||
assert response.status_code == 200 | self.assertEqual(response.status_code, 200) | ||||
self.phab.differential.revision.search.assert_called_with( | self.phab.differential.revision.search.assert_called_with( | ||||
constraints={'phids': ['1234']}) | constraints={'phids': ['1234']}) | ||||
self.phab.differential.revision.edit.assert_not_called() | self.phab.differential.revision.edit.assert_not_called() | ||||
def test_backportCheck_hasPRs(self): | def test_backportCheck_hasPRs(self): | ||||
self.phab.differential.revision.search.return_value = test.mocks.phabricator.Result([{ | self.phab.differential.revision.search.return_value = test.mocks.phabricator.Result([{ | ||||
'id': '1234', | 'id': '1234', | ||||
'fields': { | 'fields': { | ||||
Show All 14 Lines | def test_backportCheck_hasPRs(self): | ||||
"```\nsecp256k1 PR456 in a multi-line code block\n```\n" | "```\nsecp256k1 PR456 in a multi-line code block\n```\n" | ||||
" secp256k1 PR456 in a code block using indentation\n" | " secp256k1 PR456 in a code block using indentation\n" | ||||
"Another secp backport PR567", | "Another secp backport PR567", | ||||
}, | }, | ||||
}]) | }]) | ||||
response = self.post_json_with_hmac( | response = self.post_json_with_hmac( | ||||
'/backportCheck', self.headers, {'object': {'phid': '1234'}}) | '/backportCheck', self.headers, {'object': {'phid': '1234'}}) | ||||
assert response.status_code == 200 | self.assertEqual(response.status_code, 200) | ||||
self.phab.differential.revision.search.assert_called_with( | self.phab.differential.revision.search.assert_called_with( | ||||
constraints={'phids': ['1234']}) | constraints={'phids': ['1234']}) | ||||
calls = [mock.call(transactions=[{ | calls = [mock.call(transactions=[{ | ||||
"type": "summary", | "type": "summary", | ||||
"value": "This is a test summary\n" | "value": "This is a test summary\n" | ||||
# Bitcoin Core links | # Bitcoin Core links | ||||
"Backport of Core [[https://github.com/bitcoin/bitcoin/pull/2345 | PR2345]] and " | "Backport of Core [[https://github.com/bitcoin/bitcoin/pull/2345 | PR2345]] and " | ||||
"[[https://github.com/bitcoin/bitcoin/pull/34567 | PR34567]]\n" | "[[https://github.com/bitcoin/bitcoin/pull/34567 | PR34567]]\n" | ||||
Show All 26 Lines |