def test_get_config_with_request_timeout(self, client, mocker): TIMEOUT = 5.0 mocker.patch.object(requests, "get") requests.get.return_value = conftest.ResponseMock() client.get_config(timeout=TIMEOUT, headers={"Accept": "application/json"}) requests.get.assert_called_with( client.url, timeout=TIMEOUT, headers={"Accept": "application/json"} )
def test_get_file(self, client, mocker): mocker.patch.object(requests, "get") requests.get.return_value = conftest.ResponseMock(text="some text") content = client.get_file("nginx.conf") requests.get.assert_called_with( f"{client.address}/{client.app_name}/{client.profile}/{client.branch}/nginx.conf" ) assert content == "some text"
def test_decrypt(self, client, mocker): mocker.patch.object(requests, "post") requests.post.return_value = conftest.ResponseMock(text=self.DATA) response = client.decrypt(self.ENCRYPTED_DATA) requests.post.assert_called_with( f"{client.address}/decrypt", data=self.ENCRYPTED_DATA, headers={"Content-Type": "text/plain"}, ) assert response == self.DATA
def client_with_auth(self, monkeypatch, mocker): monkeypatch.setattr(requests, "post", conftest.response_mock_success) mocker.patch.object(requests, "get") requests.get.return_value = conftest.ResponseMock() return ConfigClient( app_name="test_app", oauth2=OAuth2( access_token_uri= "https://p-spring-cloud-services.uaa.sys.example.com/oauth/token", client_id="p-config-server-example-client-id", client_secret="EXAMPLE_SECRET", ), )