def test_requests_http_error(self, monkeypatch, fake): # not confident this is testing what really happens. Could not get the # 'retry' behavior from Celery. This just executes the code path to get # to the exception being re-raised by Celery, which might be enough def bad_post(*a, **kw): raise requests.HTTPError('I suck') monkeypatch.setattr(recurring.requests, 'post', bad_post) with pytest.raises(requests.HTTPError): recurring.callback("{}", 'ceph')
def test_requests_correct_project_url(self, monkeypatch, recorder): r = recorder() monkeypatch.setattr(recurring.requests, 'post', r) recurring.callback("{}", 'ceph') result = r.recorder_calls[0]['args'][0] assert result == os.path.join(conf.callback_url, 'ceph', '')
def test_invalid_json(self): # omg this is so invalid assert recurring.callback({'error': Exception}, 'ceph') is False
def test_missing_key(self): conf.callback_user = '******' assert recurring.callback("{}", 'ceph') is False
def test_missing_user(self): conf.callback_key = 'key' assert recurring.callback("{}", 'ceph') is False
def test_missing_user_and_key(self): assert recurring.callback("{}", 'ceph') is False