Ejemplo n.º 1
0
def test_make_url_trailing_slash_unchanged():
    """Tests for catpy.client.make_url
    """
    url1 = client.make_url('foo', 'bar')
    assert url1 == 'foo/bar', 'Should not add trailing slash'
    url2 = client.make_url('foo', 'bar/')
    assert url2 == 'foo/bar/', 'Should not remove trailing slash'
Ejemplo n.º 2
0
def test_fetch_uses_session(response_mock):
    url = make_url(BASE_URL, "relative")
    with mock.patch.object(requests.Session, "get", return_value=response_mock) as get:
        c = CatmaidClient(BASE_URL)
        c.fetch("relative", "GET")

    get.assert_called_with(url, params={})

    with mock.patch.object(
        requests.Session, "post", return_value=response_mock
    ) as post:
        c = CatmaidClient(BASE_URL)
        c.fetch("relative", "POST")

    post.assert_called_with(url, data={})
Ejemplo n.º 3
0
def test_fetch_uses_session(response_mock):
    url = make_url(BASE_URL, 'relative')
    with mock.patch.object(requests.Session, 'get',
                           return_value=response_mock) as get:
        c = CatmaidClient(BASE_URL)
        c.fetch('relative', 'GET')

    get.assert_called_with(url, params={})

    with mock.patch.object(requests.Session,
                           'post',
                           return_value=response_mock) as post:
        c = CatmaidClient(BASE_URL)
        c.fetch('relative', 'POST')

    post.assert_called_with(url, data={})
Ejemplo n.º 4
0
def test_make_url_no_slash():
    """Tests for catpy.client.make_url
    """
    url = client.make_url('foo', 'bar')
    assert url == 'foo/bar', 'Elements should be joined with a slash'
Ejemplo n.º 5
0
def test_make_url_double_slash():
    """Tests for catpy.client.make_url
    """
    url = client.make_url('foo/', '/bar')
    assert url == 'foo/bar', 'Duplicate slashes should be removed'
Ejemplo n.º 6
0
def make_tile_url_template(image_base):
    """
    May not be correct for all bases
    """
    return make_url(image_base, "{z_index}/0/{y_index}_{x_index}.jpg")