def test_deploy_revision(self): with mock.patch('requests.post') as requests_post: ab = Airbrake(project_id=1234, api_key='fake', environment='test') ab.deploy('test', 'user1', 'https://github.com/airbrake/airbrake', None, 'v2.0') data = json.loads(requests_post.call_args[1]['data']) version = airbrake.utils.get_local_git_revision() self.assertEqual(version, data['revision'])
def test_deploy_payload(self): with mock.patch('requests.post') as requests_post: ab = Airbrake(project_id=1234, api_key='fake', environment='test') ab.deploy('test', 'user1', 'https://github.com/airbrake/airbrake', '38748467ea579e7ae64f7815452307c9d05e05c5', 'v2.0') expected_call_args = mock.call( 'https://airbrake.io/api/v4/projects/1234/deploys', data='{"environment": "test",' ' "repository": "https://github.com/airbrake/airbrake",' ' "revision": "38748467ea579e7ae64f7815452307c9d05e05c5",' ' "username": "******",' ' "version": "v2.0"}', headers={'Content-Type': 'application/json'}, params={'key': 'fake'}, timeout=Airbrake.AIRBRAKE_TIMEOUT_DEFAULT) self.assertEqual(expected_call_args, requests_post.call_args)
def check_timeout(self, timeout=None, expected_timeout=None): ab = Airbrake(project_id=1234, api_key='fake', environment='test', timeout=timeout) if not timeout: ab = Airbrake(project_id=1234, api_key='fake', environment='test') with mock.patch('requests.post') as requests_post: ab.deploy('test', 'user1') timeout = requests_post.call_args[1]['timeout'] self.assertEqual(expected_timeout, timeout) with mock.patch('requests.post') as requests_post: notice = ab.build_notice("This is a test") ab.notify(notice) timeout = requests_post.call_args[1]['timeout'] self.assertEqual(expected_timeout, timeout)