Пример #1
0
 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')
Пример #2
0
    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')
Пример #3
0
 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', '')
Пример #4
0
 def test_invalid_json(self):
     # omg this is so invalid
     assert recurring.callback({'error': Exception}, 'ceph') is False
Пример #5
0
 def test_missing_key(self):
     conf.callback_user = '******'
     assert recurring.callback("{}", 'ceph') is False
Пример #6
0
 def test_missing_user(self):
     conf.callback_key = 'key'
     assert recurring.callback("{}", 'ceph') is False
Пример #7
0
 def test_missing_user_and_key(self):
     assert recurring.callback("{}", 'ceph') is False
Пример #8
0
 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', '')
Пример #9
0
 def test_invalid_json(self):
     # omg this is so invalid
     assert recurring.callback({'error': Exception}, 'ceph') is False
Пример #10
0
 def test_missing_key(self):
     conf.callback_user = '******'
     assert recurring.callback("{}", 'ceph') is False
Пример #11
0
 def test_missing_user(self):
     conf.callback_key = 'key'
     assert recurring.callback("{}", 'ceph') is False
Пример #12
0
 def test_missing_user_and_key(self):
     assert recurring.callback("{}", 'ceph') is False