Repository: sunpy/sunpy

Issue:
Skip remote tests for HELIO if server is unreachable
<!--
We know asking good questions takes effort, and we appreciate your time.
Thank you.

Please be aware that everyone has to follow our code of conduct:
https://github.com/sunpy/sunpy/blob/master/CODE_OF_CONDUCT.rst

Also that these comments are hidden when you submit this github issue.

Please have a search on our GitHub repository to see if a similar issue has already been posted.
If a similar issue is closed, have a quick look to see if you are satisfied by the resolution.
If not please go ahead and open an issue!
-->

### Description
<!--
Provide a general description of the feature you would like.
If you prefer, you can also suggest a draft design or API.
This way we have a deeper discussion on the feature.
-->
There should be a way to skip all remote tests in helio after checking if server is reachable or not.

### Additional context
<!--
Add any other context or screenshots
This part is optional.
Delete this section heading if you do not use it.
-->
This is useful https://docs.pytest.org/en/latest/skipping.html#id1 . We can prior check the server state and use `@pytest.skipif(condition)`



Discussion:
As I mentioned elsewhere, I'm uneasy with this approach.

I think I'd feel more comfortable if the tests were marked with `xfail` with a condition (see https://docs.pytest.org/en/latest/skipping.html#condition-parameter) instead of `skipif`.
yeah xfail makes more sense here I think :+1: 
hi, @nabobalis  @abhijeetmanhas @ayshih  I am taking this up suggestions are welcome if any

@abhijeetmanhas can you please let me know what are the files and functions are in effect, and what test failures it shows


Hi @mridullpandey, can you please not @ people unless you need to talk to them specifically. 

The code lives in the `sunpy/net/helio` folder. The tests were failing when the server was broken and we want to make these tests xfail instead of fail when the server is down.
@abhijeetmanhas what all addresses and ports are to be checked can you detail it out...
I am not sure why you would need ports or addresses. The client itself has a list of urls in its parser.

Resolving patch:
diff --git a/sunpy/net/helio/parser.py b/sunpy/net/helio/parser.py
--- a/sunpy/net/helio/parser.py
+++ b/sunpy/net/helio/parser.py
@@ -215,7 +215,8 @@ def wsdl_retriever(service='HEC'):
         this function to take a while to return. Timeout duration can be
         controlled through the LINK_TIMEOUT value
     """
-    def fail(): raise ValueError("No online HELIO servers can be found.")
+    def fail():
+        raise ValueError("No online HELIO servers can be found.")
     service_links = webservice_parser(service=service)
     wsdl = None
     wsdl_links = None


Test patch:
diff --git a/sunpy/net/helio/tests/test_helio.py b/sunpy/net/helio/tests/test_helio.py
--- a/sunpy/net/helio/tests/test_helio.py
+++ b/sunpy/net/helio/tests/test_helio.py
@@ -266,9 +266,12 @@ def test_link_test_on_urlerror(mock_link_test):
 @pytest.mark.remote_data
 @pytest.fixture(scope="session")
 def client():
-    working_links = list(filter(link_test, webservice_parser()))
-    taverna_link = taverna_parser(working_links[0])[0]
-    return HECClient(taverna_link)
+    try:
+        client = HECClient()
+        return client
+    # If no links are found, the client should raise a ValueError
+    except ValueError:
+        pytest.xfail("No HELIO working links found.")
 
 
 @pytest.mark.remote_data
@@ -298,3 +301,10 @@ def test_time_query(client):
     table_name = b'rhessi_hxr_flare'
     res = client.time_query(start, end, table=table_name, max_records=10)
     assert len(res.array) == 10
+
+
+def test_client_mock_fail(client):
+    """
+    This test will xfail on the offline tests.
+    It just passes if the client is working.
+    """