Пример #1
0
def test_resource_create_error():
        with requests_mock.Mocker() as mock:
                mock.register_uri(
                        'POST', __SIGNALFX_API_ENDPOINT__ + '/', status_code=500
                )

                resource = Resource().with_api_token('test')
                resource.options = {'opt': 'val'}

                with pytest.raises(RuntimeError):
                        resource.create()
Пример #2
0
def test_resource_create_happy_path():
        with requests_mock.Mocker() as mock:
                expected = {'foo': 'bar'}

                mock.register_uri(
                        'POST', __SIGNALFX_API_ENDPOINT__ + '/', json=expected
                )

                resource = Resource().with_api_token('test')
                resource.options = {'opt': 'val'}

                response = resource.create()
                assert response == expected