files.new_contents: # Licensed under a 3-clause BSD style license - see LICENSE.rst
  """
  ===============
  eJWST TAP tests
  ===============
  
  European Space Astronomy Centre (ESAC)
  European Space Agency (ESA)
  
  """
  import os
  import shutil
  from unittest.mock import MagicMock
  
  import astropy.units as u
  import numpy as np
  import pytest
  from astropy import units
  from astropy.coordinates.sky_coordinate import SkyCoord
  from astropy.table import Table
  from astropy.units import Quantity
  
  from astroquery.esa.jwst import JwstClass
  from astroquery.esa.jwst.tests.DummyTapHandler import DummyTapHandler
  from astroquery.ipac.ned import Ned
  from astroquery.simbad import Simbad
  from astroquery.utils import TableList
  from astroquery.utils.tap.conn.tests.DummyConnHandler import DummyConnHandler
  from astroquery.utils.tap.conn.tests.DummyResponse import DummyResponse
  from astroquery.utils.tap.core import TapPlus
  from astroquery.utils.tap.xmlparser import utils
  from astroquery.vizier import Vizier
  
  from astroquery.esa.jwst import conf
  
  
  def data_path(filename):
      data_dir = os.path.join(os.path.dirname(__file__), 'data')
      return os.path.join(data_dir, filename)
  
  
  def get_plane_id_mock(url, *args, **kwargs):
      return ['00000000-0000-0000-879d-ae91fa2
  
  [... the rest is omitted ...]
files.new_path: astroquery/esa/jwst/tests/test_jwsttap.py
files.old_contents: # Licensed under a 3-clause BSD style license - see LICENSE.rst
  """
  ===============
  eJWST TAP tests
  ===============
  
  European Space Astronomy Centre (ESAC)
  European Space Agency (ESA)
  
  """
  import os
  import shutil
  from unittest.mock import MagicMock
  
  import astropy.units as u
  import numpy as np
  import pytest
  from astropy import units
  from astropy.coordinates.sky_coordinate import SkyCoord
  from astropy.table import Table
  from astropy.units import Quantity
  
  from astroquery.esa.jwst import JwstClass
  from astroquery.esa.jwst.tests.DummyTapHandler import DummyTapHandler
  from astroquery.ipac.ned import Ned
  from astroquery.simbad import Simbad
  from astroquery.utils import TableList
  from astroquery.utils.tap.conn.tests.DummyConnHandler import DummyConnHandler
  from astroquery.utils.tap.conn.tests.DummyResponse import DummyResponse
  from astroquery.utils.tap.core import TapPlus
  from astroquery.utils.tap.xmlparser import utils
  from astroquery.vizier import Vizier
  
  from astroquery.esa.jwst import conf
  
  
  def data_path(filename):
      data_dir = os.path.join(os.path.dirname(__file__), 'data')
      return os.path.join(data_dir, filename)
  
  
  def get_plane_id_mock(url, *args, **kwargs):
      return ['00000000-0000-0000-879d-ae91fa2
  
  [... the rest is omitted ...]
files.old_path: astroquery/esa/jwst/tests/test_jwsttap.py
files.new_contents: # Licensed under a 3-clause BSD style license - see LICENSE.rst
  """
  =============
  Gaia TAP plus
  =============
  
  @author: Juan Carlos Segovia
  @contact: juan.carlos.segovia@sciops.esa.int
  
  European Space Astronomy Centre (ESAC)
  European Space Agency (ESA)
  
  Created on 30 jun. 2016
  
  
  """
  import os
  from unittest.mock import patch
  
  import pytest
  from requests import HTTPError
  
  from astroquery.gaia import conf
  from astroquery.gaia.core import GaiaClass
  from astroquery.gaia.tests.DummyTapHandler import DummyTapHandler
  from astroquery.utils.tap.conn.tests.DummyConnHandler import DummyConnHandler
  from astroquery.utils.tap.conn.tests.DummyResponse import DummyResponse
  import astropy.units as u
  from astropy.coordinates.sky_coordinate import SkyCoord
  from astropy.units import Quantity
  import numpy as np
  from astroquery.utils.tap.xmlparser import utils
  from astroquery.utils.tap.core import TapPlus, TAP_CLIENT_ID
  from astroquery.utils.tap import taputils
  
  
  def data_path(filename):
      data_dir = os.path.join(os.path.dirname(__file__), 'data')
      return os.path.join(data_dir, filename)
  
  
  class TestTap:
  
      def test_show_message(self):
          connHandler = DummyConnHandler()
  
          dummy_response = DummyResponse(200)
  
          message_text = "1653401204784D[type:
  
  [... the rest is omitted ...]
files.new_path: astroquery/gaia/tests/test_gaiatap.py
files.old_contents: # Licensed under a 3-clause BSD style license - see LICENSE.rst
  """
  =============
  Gaia TAP plus
  =============
  
  @author: Juan Carlos Segovia
  @contact: juan.carlos.segovia@sciops.esa.int
  
  European Space Astronomy Centre (ESAC)
  European Space Agency (ESA)
  
  Created on 30 jun. 2016
  
  
  """
  import os
  from unittest.mock import patch
  
  import pytest
  from requests import HTTPError
  
  from astroquery.gaia import conf
  from astroquery.gaia.core import GaiaClass
  from astroquery.gaia.tests.DummyTapHandler import DummyTapHandler
  from astroquery.utils.tap.conn.tests.DummyConnHandler import DummyConnHandler
  from astroquery.utils.tap.conn.tests.DummyResponse import DummyResponse
  import astropy.units as u
  from astropy.coordinates.sky_coordinate import SkyCoord
  from astropy.units import Quantity
  import numpy as np
  from astroquery.utils.tap.xmlparser import utils
  from astroquery.utils.tap.core import TapPlus, TAP_CLIENT_ID
  from astroquery.utils.tap import taputils
  
  
  def data_path(filename):
      data_dir = os.path.join(os.path.dirname(__file__), 'data')
      return os.path.join(data_dir, filename)
  
  
  class TestTap:
  
      def test_show_message(self):
          connHandler = DummyConnHandler()
  
          dummy_response = DummyResponse(200)
  
          message_text = "1653401204784D[type:
  
  [... the rest is omitted ...]
files.old_path: astroquery/gaia/tests/test_gaiatap.py
files.new_contents: # Licensed under a 3-clause BSD style license - see LICENSE.rst
  """
  =============
  TAP plus
  =============
  
  @author: Juan Carlos Segovia
  @contact: juan.carlos.segovia@sciops.esa.int
  
  European Space Astronomy Centre (ESAC)
  European Space Agency (ESA)
  
  Created on 30 jun. 2016
  
  
  """
  from astroquery.utils.tap.conn.tests.DummyResponse import DummyResponse
  
  
  class DummyConn:
      '''
      classdocs
      '''
  
      def __init__(self, name=None):
          self.response = DummyResponse()
          self.name = name
          self.httpConn = DummyHttpConn(self.response)
          self.cookie = None
          self.ishttps = False
  
      def request(self, method, context=None, body=None, headers=None):
          self.response.set_data(method, context, body, headers)
  
      def getresponse(self):
          return self.response
  
      def get_connection(self, ishttps=False, cookie=None, verbose=False):
          self.ishttps = ishttps
          self.cookie = cookie
          return self.httpConn
  
      def get_connection_secure(self, verbose):
          return self.httpConn
  
      def __str__(self):
          return self.name
  
  
  class DummyHttpConn:
  
      def __init__(self, response):
          self.response = response
          self.reqmethod = None
          self.requrl = None
          self.reqbody = None
          self.reqheaders = None
  
      def request(self, method, url, body
  
  [... the rest is omitted ...]
files.new_path: astroquery/utils/tap/conn/tests/DummyConn.py
files.old_contents: # Licensed under a 3-clause BSD style license - see LICENSE.rst
  """
  =============
  TAP plus
  =============
  
  @author: Juan Carlos Segovia
  @contact: juan.carlos.segovia@sciops.esa.int
  
  European Space Astronomy Centre (ESAC)
  European Space Agency (ESA)
  
  Created on 30 jun. 2016
  
  
  """
  from astroquery.utils.tap.conn.tests.DummyResponse import DummyResponse
  
  
  class DummyConn:
      '''
      classdocs
      '''
  
      def __init__(self, name=None):
          self.response = DummyResponse()
          self.name = name
          self.httpConn = DummyHttpConn(self.response)
          self.cookie = None
          self.ishttps = False
  
      def request(self, method, context, body, headers):
          self.response.set_data(method, context, body, headers)
  
      def getresponse(self):
          return self.response
  
      def get_connection(self, ishttps=False, cookie=None, verbose=False):
          self.ishttps = ishttps
          self.cookie = cookie
          return self.httpConn
  
      def get_connection_secure(self, verbose):
          return self.httpConn
  
      def __str__(self):
          return self.name
  
  
  class DummyHttpConn:
  
      def __init__(self, response):
          self.response = response
          self.reqmethod = None
          self.requrl = None
          self.reqbody = None
          self.reqheaders = None
  
      def request(self, method, url, body=None, headers
  
  [... the rest is omitted ...]
files.old_path: astroquery/utils/tap/conn/tests/DummyConn.py
files.new_contents: # Licensed under a 3-clause BSD style license - see LICENSE.rst
  """
  =============
  TAP plus
  =============
  
  @author: Juan Carlos Segovia
  @contact: juan.carlos.segovia@sciops.esa.int
  
  European Space Astronomy Centre (ESAC)
  European Space Agency (ESA)
  
  Created on 30 jun. 2016
  
  
  """
  
  
  class DummyResponse:
      '''
      classdocs
      '''
  
      STATUS_MESSAGES = {200: "OK", 303: "OK", 500: "ERROR"}
  
      def __init__(self, status_code=None):
          self.reason = ""
          self.set_status_code(status_code)
          self.index = 0
          self.set_data(None, None, None, None)
  
      def set_status_code(self, status_code):
          self.status = status_code
          self.reason = self.STATUS_MESSAGES.get(status_code)
  
      def set_data(self, method, context=None, body=None, headers=None):
          self.method = method
          self.context = context
          self.body = body
          self.headers = headers
          self.index = 0
  
      def get_method(self):
          return self.method
  
      def get_context(self):
          return self.context
  
      def get_body(self):
          return self.body
  
      def read(self, size=None):
          v = self.get_body()
          if v is None:
              return None
          else:
              if size is None or size < 0:
                  # read all
                  return v.encode(encoding='utf_8',
  
  [... the rest is omitted ...]
files.new_path: astroquery/utils/tap/conn/tests/DummyResponse.py
files.old_contents: # Licensed under a 3-clause BSD style license - see LICENSE.rst
  """
  =============
  TAP plus
  =============
  
  @author: Juan Carlos Segovia
  @contact: juan.carlos.segovia@sciops.esa.int
  
  European Space Astronomy Centre (ESAC)
  European Space Agency (ESA)
  
  Created on 30 jun. 2016
  
  
  """
  
  
  class DummyResponse:
      '''
      classdocs
      '''
  
      STATUS_MESSAGES = {200: "OK", 303: "OK", 500: "ERROR"}
  
      def __init__(self, status_code=None):
          self.reason = ""
          self.set_status_code(status_code)
          self.index = 0
          self.set_data(None, None, None, None)
  
      def set_status_code(self, status_code):
          self.status = status_code
          self.reason = self.STATUS_MESSAGES.get(status_code)
  
      def set_data(self, method, context, body, headers):
          self.method = method
          self.context = context
          self.body = body
          self.headers = headers
          self.index = 0
  
      def get_method(self):
          return self.method
  
      def get_context(self):
          return self.context
  
      def get_body(self):
          return self.body
  
      def read(self, size=None):
          v = self.get_body()
          if v is None:
              return None
          else:
              if size is None or size < 0:
                  # read all
                  return v.encode(encoding='utf_8', errors='strict
  
  [... the rest is omitted ...]
files.old_path: astroquery/utils/tap/conn/tests/DummyResponse.py
files.new_contents: # Licensed under a 3-clause BSD style license - see LICENSE.rst
  """
  =============
  TAP plus
  =============
  
  @author: Juan Carlos Segovia
  @contact: juan.carlos.segovia@sciops.esa.int
  
  European Space Astronomy Centre (ESAC)
  European Space Agency (ESA)
  
  Created on 30 jun. 2016
  
  
  """
  import os
  import pytest
  
  from astroquery.utils.tap.model.job import Job
  from astroquery.utils.tap.conn.tests.DummyConnHandler import DummyConnHandler
  from astroquery.utils.tap.conn.tests.DummyResponse import DummyResponse
  from astroquery.utils.tap.xmlparser import utils
  
  
  def data_path(filename):
      data_dir = os.path.join(os.path.dirname(__file__), 'data')
      return os.path.join(data_dir, filename)
  
  
  def test_job_basic():
  
      with pytest.raises(AttributeError):
          job = Job(async_job=True)
          job.get_results()
  
  
  def test_job_get_results(capsys, tmpdir):
      job = Job(async_job=True)
      jobid = "12345"
      outputFormat = "votable"
      job.jobid = jobid
      job.parameters['format'] = outputFormat
      responseCheckPhase = DummyResponse(500)
      responseCheckPhase.set_data(method='GET', body='FINISHED')
      waitRequest = f"async/{jobid}/phase"
      connHandler = DummyConnHandler()
      connHandler.set_response(waitRequest,
  
  [... the rest is omitted ...]
files.new_path: astroquery/utils/tap/model/tests/test_job.py
files.old_contents: # Licensed under a 3-clause BSD style license - see LICENSE.rst
  """
  =============
  TAP plus
  =============
  
  @author: Juan Carlos Segovia
  @contact: juan.carlos.segovia@sciops.esa.int
  
  European Space Astronomy Centre (ESAC)
  European Space Agency (ESA)
  
  Created on 30 jun. 2016
  
  
  """
  import os
  import pytest
  
  from astroquery.utils.tap.model.job import Job
  from astroquery.utils.tap.conn.tests.DummyConnHandler import DummyConnHandler
  from astroquery.utils.tap.conn.tests.DummyResponse import DummyResponse
  from astroquery.utils.tap.xmlparser import utils
  
  
  def data_path(filename):
      data_dir = os.path.join(os.path.dirname(__file__), 'data')
      return os.path.join(data_dir, filename)
  
  
  def test_job_basic():
  
      with pytest.raises(AttributeError):
          job = Job(async_job=True)
          job.get_results()
  
  
  def test_job_get_results(capsys, tmpdir):
      job = Job(async_job=True)
      jobid = "12345"
      outputFormat = "votable"
      job.jobid = jobid
      job.parameters['format'] = outputFormat
      responseCheckPhase = DummyResponse(500)
      responseCheckPhase.set_data(method='GET',
                                  context=None,
                                  body='FINISHED',
                                  headers=None)
      waitRequest = f"async/{jobid}/phase"
      connHandler = DummyConnHandler()
  
  
  [... the rest is omitted ...]
files.old_path: astroquery/utils/tap/model/tests/test_job.py
files.new_contents: # Licensed under a 3-clause BSD style license - see LICENSE.rst
  """
  =============
  TAP plus
  =============
  
  @author: Juan Carlos Segovia
  @contact: juan.carlos.segovia@sciops.esa.int
  
  European Space Astronomy Centre (ESAC)
  European Space Agency (ESA)
  
  Created on 30 jun. 2016
  """
  import os
  from unittest.mock import patch
  
  import numpy as np
  import pytest
  from requests import HTTPError
  
  from astroquery.utils.tap.model.tapcolumn import TapColumn
  
  from astroquery.utils.tap.conn.tests.DummyConnHandler import DummyConnHandler
  from astroquery.utils.tap.conn.tests.DummyResponse import DummyResponse
  from astroquery.utils.tap.core import TapPlus, TAP_CLIENT_ID
  from astroquery.utils.tap.xmlparser import utils
  from astroquery.utils.tap import taputils
  
  
  def data_path(filename):
      data_dir = os.path.join(os.path.dirname(__file__), 'data')
      return os.path.join(data_dir, filename)
  
  
  def test_load_tables():
      connHandler = DummyConnHandler()
      tap = TapPlus("http://test:1111/tap", connhandler=connHandler)
      responseLoadTable = DummyResponse(500)
      tableDataFile = data_path('test_tables.xml')
      tableData = utils.read_file_content(tableDataFile)
      responseLoadTable.set_data(method='GET', body=tableData)
      tableRequest = "tables"
      connHandler.set_response(table
  
  [... the rest is omitted ...]
files.new_path: astroquery/utils/tap/tests/test_tap.py
files.old_contents: # Licensed under a 3-clause BSD style license - see LICENSE.rst
  """
  =============
  TAP plus
  =============
  
  @author: Juan Carlos Segovia
  @contact: juan.carlos.segovia@sciops.esa.int
  
  European Space Astronomy Centre (ESAC)
  European Space Agency (ESA)
  
  Created on 30 jun. 2016
  """
  import os
  from unittest.mock import patch
  
  import numpy as np
  import pytest
  from requests import HTTPError
  
  from astroquery.utils.tap.model.tapcolumn import TapColumn
  
  from astroquery.utils.tap.conn.tests.DummyConnHandler import DummyConnHandler
  from astroquery.utils.tap.conn.tests.DummyResponse import DummyResponse
  from astroquery.utils.tap.core import TapPlus, TAP_CLIENT_ID
  from astroquery.utils.tap.xmlparser import utils
  from astroquery.utils.tap import taputils
  
  
  def data_path(filename):
      data_dir = os.path.join(os.path.dirname(__file__), 'data')
      return os.path.join(data_dir, filename)
  
  
  def test_load_tables():
      connHandler = DummyConnHandler()
      tap = TapPlus("http://test:1111/tap", connhandler=connHandler)
      responseLoadTable = DummyResponse(500)
      tableDataFile = data_path('test_tables.xml')
      tableData = utils.read_file_content(tableDataFile)
      responseLoadTable.set_data(method='GET',
                                 context=None,
                                 body=tableData,
                                 headers=None)
      tableRequest = "
  
  [... the rest is omitted ...]
files.old_path: astroquery/utils/tap/tests/test_tap.py