Repository: sunpy/sunpy

Issue:
HEC still thinks parse_time returns a datetime object.

```
sunpy/net/helio/hec.py in time_query(self, start_time, end_time, table, max_records)
111 start_time = parse_time(start_time)
112 end_time = parse_time(end_time)
--> 113 results = self.hec_client.service.TimeQuery(STARTTIME=start_time.isoformat(),
```

instead of `isoformat()` it should read `.isot`



Discussion:
We should also add tests for this code path, because it clearly dosen't have any at the moment.
Changing `start_time.isoformat()` to `start_time.isot` results in an Error
`TypeError: 'str' object is not callable`

I checked and after parsing `start_time.isot` returns the time without any error.
I'm able to reproduce this bug. Astropy Time object doesn't have any attribute named `isoformat()`, although there are a number of Time attributes/formats available, `isot` is one of them:
```
list(Time.FORMATS)
['jd', 'mjd', 'decimalyear', 'unix', 'cxcsec', 'gps', 'plot_date',
'datetime', 'iso', 'isot', 'yday', 'datetime64', 'fits', 'byear',
'jyear', 'byear_str', 'jyear_str']
```
When I accessed `isot` attribute of Astropy Time object it produced a result like this:
`2005-12-03T00:00:00.000`

I'll need some guidance to write a test for this. 
> Changing `start_time.isoformat()` to `start_time.isot` results in an Error
> `TypeError: 'str' object is not callable`
> 
> I checked and after parsing `start_time.isot` returns the time without any error.

Yes `.isot` only exists on the `astropy.time.Time` object and not the string. 

> I'm able to reproduce this bug. Astropy Time object doesn't have any attribute named `isoformat()`, although there are a number of Time attributes/formats available, `isot` is one of them:
> 
> ```
> list(Time.FORMATS)
> ['jd', 'mjd', 'decimalyear', 'unix', 'cxcsec', 'gps', 'plot_date',
> 'datetime', 'iso', 'isot', 'yday', 'datetime64', 'fits', 'byear',
> 'jyear', 'byear_str', 'jyear_str']
> ```
> When I accessed `isot` attribute of Astropy Time object it produced a result like this:
> `2005-12-03T00:00:00.000`
> 
> I'll need some guidance to write a test for this.

The first test would be just to write some tests for the `hec` code. 


Resolving patch:
diff --git a/sunpy/net/helio/hec.py b/sunpy/net/helio/hec.py
--- a/sunpy/net/helio/hec.py
+++ b/sunpy/net/helio/hec.py
@@ -110,8 +110,8 @@ def time_query(self, start_time, end_time, table=None, max_records=None):
             table = self.make_table_list()
         start_time = parse_time(start_time)
         end_time = parse_time(end_time)
-        results = self.hec_client.service.TimeQuery(STARTTIME=start_time.isoformat(),
-                                                    ENDTIME=end_time.isoformat(),
+        results = self.hec_client.service.TimeQuery(STARTTIME=start_time.isot,
+                                                    ENDTIME=end_time.isot,
                                                     FROM=table,
                                                     MAXRECORDS=max_records)
         results = votable_handler(etree.tostring(results))


Test patch:
diff --git a/sunpy/net/tests/test_helio.py b/sunpy/net/tests/test_helio.py
--- a/sunpy/net/tests/test_helio.py
+++ b/sunpy/net/tests/test_helio.py
@@ -5,6 +5,7 @@
 
 from sunpy.net.helio.parser import (link_test, taverna_parser, wsdl_retriever,
                                     endpoint_parser, webservice_parser)
+from sunpy.net.helio import hec
 
 
 def wsdl_endpoints():
@@ -251,3 +252,13 @@ def test_link_test_on_urlerror(mock_link_test):
     returns `None`
     """
     link_test('') is None
+
+
+@pytest.mark.remote_data
+def test_time_query():
+    hc = hec.HECClient()
+    start = '2005/01/03'
+    end = '2005/12/03'
+    table_name = 'rhessi_hxr_flare'
+    res = hc.time_query(start, end, table=table_name, max_records=10)
+    assert len(res.array) == 10