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')
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()
def test_auth_is_expired(delta, expected): auth = selectel.Auth(requests=None, config=None) auth.update_expires(delta) assert auth.is_expired() is expected