Repository: astropy/pyvo
Pull request #199 (2019-12-17 15:10:27)

Add default for UWS version - Issue #198

codecov[bot]: # [Codecov](https://codecov.io/gh/astropy/pyvo/pull/199?src=pr&el=h1) Report
> Merging [#199](https://codecov.io/gh/astropy/pyvo/pull/199?src=pr&el=desc) into [master](https://codecov.io/gh/astropy/pyvo/commit/78e3d52c41c114d01a30579caa62f2af4ef61c53?src=pr&el=desc) will **not change** coverage.
> The diff coverage is `100%`.

[![Impacted file tree graph](https://codecov.io/gh/astropy/pyvo/pull/199/graphs/tree.svg?width=650&token=Mynyo9xoPZ&height=150&src=pr)](https://codecov.io/gh/astropy/pyvo/pull/199?src=pr&el=tree)

```diff
@@           Coverage Diff           @@
##           master     #199   +/-   ##
=======================================
  Coverage   70.81%   70.81%           
=======================================
  Files          37       37           
  Lines        3910     3910           
=======================================
  Hits         2769     2769           
  Misses       1141     1141
```


| [Impacted Files](https://codecov.io/gh/astropy/pyvo/pull/199?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [pyvo/io/uws/endpoint.py](https://codecov.io/gh/astropy/pyvo/pull/199/diff?src=pr&el=tree#diff-cHl2by9pby91d3MvZW5kcG9pbnQucHk=) | `100% <100%> (ø)` | :arrow_up: |

------

[Continue to review full report at Codecov](https://codecov.io/gh/astropy/pyvo/pull/199?src=pr&el=continue).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/astropy/pyvo/pull/199?src=pr&el=footer). Last update [78e3d52...09129f0](https://codecov.io/gh/astropy/pyvo/pull/199?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).


Patch:
diff --git a/CHANGES.rst b/CHANGES.rst
index 98d902c..54eb7cd 100644
--- a/CHANGES.rst
+++ b/CHANGES.rst
@@ -1,6 +1,8 @@
 1.1 (unreleased)
 ================
 
+- Add default for UWS version. [#199]
+
 
 1.0 (2019-09-20)
 ================
diff --git a/pyvo/io/uws/endpoint.py b/pyvo/io/uws/endpoint.py
index 30ad0b7..5d2067f 100644
--- a/pyvo/io/uws/endpoint.py
+++ b/pyvo/io/uws/endpoint.py
@@ -108,7 +108,8 @@ class JobFile(JobSummary):
             if start and tag == 'xml':
                 pass
             elif start and tag == 'job':
-                self._version = data.get('version')
+                # version was not required in v1.0, so default to that.
+                self._version = data.get('version', '1.0')
                 break
 
         return super().parse(iterator, config)


Test patch:
diff --git a/pyvo/io/uws/tests/data/job-implicit-v1.0.xml b/pyvo/io/uws/tests/data/job-implicit-v1.0.xml
new file mode 100644
index 0000000..3f886cd
--- /dev/null
+++ b/pyvo/io/uws/tests/data/job-implicit-v1.0.xml
@@ -0,0 +1,22 @@
+<?xml version="1.0" ?>
+<job xmlns="http://www.ivoa.net/xml/UWS/v1.0" xmlns:xlink="http://www.w3.org/1999/xlink"
+	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.ivoa.net/xml/UWS/v1.0 http://www.ivoa.net/xml/UWS/v1.0">
+	<jobId>1576511540079_32840</jobId>
+	<ownerId/>
+	<phase>COMPLETED</phase>
+	<startTime>2019-12-16T10:52:20</startTime>
+	<endTime>2019-12-17T10:52:20</endTime>
+	<executionDuration>600</executionDuration>
+	<destruction>2019-12-17T10:52:20</destruction>
+	<parameters>
+		<parameter id="lang">ADQL-2.0</parameter>
+		<parameter id="serviceType">tap</parameter>
+		<parameter id="request">doQuery</parameter>
+		<parameter id="query">
+SELECT ra, dec FROM table
+</parameter>
+	</parameters>
+	<results>
+		<result id="resultsTable" xlink:href="http://example.com/tap/async/1234/results/result"/>
+	</results>
+</job>
diff --git a/pyvo/io/uws/tests/test_job.py b/pyvo/io/uws/tests/test_job.py
index 3168188..2571101 100644
--- a/pyvo/io/uws/tests/test_job.py
+++ b/pyvo/io/uws/tests/test_job.py
@@ -14,3 +14,9 @@ class TestJob:
             "data/job.xml"))
 
         assert job.jobid == '1337'
+        assert job.version == '1.1'
+
+        job = uws.parse_job(get_pkg_data_filename(
+            "data/job-implicit-v1.0.xml"))
+
+        assert job.version == '1.0'