コード例 #1
0
def test_build_url(monkeypatch):
    def patched_authenticate(self):
        self.storage_url = 'https://example.com/'
        self.update_expires(100500)

    auth = selectel.Auth(requests=None, config={'CONTAINER': 'bucket'})
    monkeypatch.setattr(selectel.Auth, 'authenticate', patched_authenticate)

    auth.renew_if_need()
    assert (auth.build_url('index.html') ==
            'https://example.com/bucket/index.html')
コード例 #2
0
def test_auth_renew_if_expired(delta, expected, monkeypatch):
    def patched_authenticate(self):
        raise SystemError()

    monkeypatch.setattr(selectel.Auth, 'authenticate', patched_authenticate)

    auth = selectel.Auth(requests=None, config=None)
    auth.update_expires(delta)

    if expected:
        with pytest.raises(SystemError):
            auth.renew_if_need()
    else:
        auth.renew_if_need()
コード例 #3
0
def test_auth_is_expired(delta, expected):
    auth = selectel.Auth(requests=None, config=None)
    auth.update_expires(delta)
    assert auth.is_expired() is expected