def test_status_code_error(self): mocker = RequestsMocker() mocker.expect_request( 'post', self.url, data=self.calc_post_data(), headers={'Content-type': 'application/json'}, status_code=500, ) with mocker: handlers.do_http_post(self.team.id, self.url, self.data, {}, '', '') self.check_notification(500, "Response status: 500")
def check_network_error(self, exception, error_message): mocker = RequestsMocker() mocker.expect_request( 'post', self.url, data=self.calc_post_data(), headers={'Content-type': 'application/json'}, error=exception, ) with mocker: handlers.do_http_post(self.team.id, self.url, self.data, {}, '', '') self.check_notification(None, error_message) TeamNotification.objects.all().delete()
def test_http_request(self): mocker = RequestsMocker() mocker.expect_request( 'post', self.url, data=self.calc_post_data(), headers={ 'Content-type': 'application/json', 'extra-header': '123', }, auth=HTTPBasicAuth('alice', '1234'), ) with mocker: handlers.do_http_post(self.team.id, self.url, self.data, {'extra-header': '123'}, 'alice', '1234') self.check_notification(200)