Commit f34426ee authored by Craig Weber's avatar Craig Weber

Use tox for testing

parent 00842eb8
Pipeline #12490270 failed with stage
in 20 minutes and 9 seconds
......@@ -4,16 +4,19 @@ stages:
services: []
before_script:
- pip install -r requirements.txt
- pip install tox
test_python:3.4:
stage: test
image: python:3.4
script:
- ./test.sh
script: tox --skip-missing-interpreters
test_python:3.5:
stage: test
image: python:3.5
script:
- ./test.sh
script: tox --skip-missing-interpreters
test_python:3.6:
stage: test
image: python:3.6
script: tox --skip-missing-interpreters
FROM python:3.5
FROM python:3.6
ENV PYTHONUNBUFFERED 0
RUN mkdir /code
WORKDIR /code
ENV PYTHONPATH /code
ADD requirements.txt /code/
RUN pip install -r requirements.txt
ADD . /code/
RUN pip install -e .[development]
RUN mkdir /tox
ENV TOX_WORK_DIR='/tox'
test:
build: .
command: ./test.sh
command: tox -e py36
volumes:
- .:/code
......@@ -22,7 +22,7 @@ import sys
sys.path.insert(0, os.path.abspath('..'))
os.environ['DJANGO_SETTINGS_MODULE'] = 'sandbox.settings'
import django
import django # NOQA
django.setup()
# -- General configuration ------------------------------------------------
......@@ -247,21 +247,21 @@ htmlhelp_basename = 'instrumented-soapdoc'
# -- Options for LaTeX output ---------------------------------------------
latex_elements = {
# The paper size ('letterpaper' or 'a4paper').
#
# 'papersize': 'letterpaper',
# The paper size ('letterpaper' or 'a4paper').
#
# 'papersize': 'letterpaper',
# The font size ('10pt', '11pt' or '12pt').
#
# 'pointsize': '10pt',
# The font size ('10pt', '11pt' or '12pt').
#
# 'pointsize': '10pt',
# Additional stuff for the LaTeX preamble.
#
# 'preamble': '',
# Additional stuff for the LaTeX preamble.
#
# 'preamble': '',
# Latex figure (float) alignment
#
# 'figure_align': 'htbp',
# Latex figure (float) alignment
#
# 'figure_align': 'htbp',
}
# Grouping the document tree into LaTeX files. List of tuples
......
......@@ -2,12 +2,12 @@
import os
import sys
def main():
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "settings")
from django.core.management import execute_from_command_line
execute_from_command_line(sys.argv)
if __name__ == "__main__":
main()
import os
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
......@@ -13,6 +11,7 @@ INSTALLED_APPS = [
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'soap',
]
SECRET_KEY = 'li0$-gnv)76g$yf7p@(cg-^_q7j6df5cx$o-gsef5hd68phj!4'
......
[flake8]
ignore = E128,E201,E202,E303
max-line-length = 160
exclude = migrations
#!/usr/bin/env python
from setuptools import setup, find_packages, Distribution
import codecs
import os.path
from setuptools import setup
from versiontag import get_version, cache_git_tag
# Make sure versiontag exists before going any further
Distribution().fetch_build_eggs('versiontag>=1.2.0')
packages = [
'soap',
]
from versiontag import get_version, cache_git_tag # NOQA
setup_requires = [
'versiontag>=1.0.3',
]
requires = [
packages = find_packages('src')
install_requires = [
'Django>=1.8.11',
'django-statsd-mozilla>=0.3.16',
'suds-jurko>=0.6',
'requests>=2.9.1',
]
extras_require = {
'development': [
'flake8>=3.2.1',
'tox>=2.6.0',
],
}
def fpath(name):
return os.path.join(os.path.dirname(__file__), name)
def read(fname):
return codecs.open(fpath(fname), encoding='utf-8').read()
cache_git_tag()
setup(
......@@ -52,7 +59,8 @@ setup(
author_email='crgwbr@gmail.com',
url='https://gitlab.com/thelabnyc/instrumented-soap',
license='ISC',
package_dir={'': 'src'},
packages=packages,
install_requires=requires,
setup_requires=setup_requires
install_requires=install_requires,
extras_require=extras_require,
)
......@@ -2,12 +2,9 @@ from django_statsd.clients import statsd
from suds.client import Client
from suds.plugin import MessagePlugin
from suds.cache import FileCache
import os.path
import pathlib
import logging
from . import settings
from .http import HttpTransport
from . import settings
import logging
logger = logging.getLogger(__name__)
......
from django_statsd.clients import statsd
from suds.transport import Transport, Reply
from . import settings
import urllib.request
import logging
import requests
import io
from . import settings
logger = logging.getLogger(__name__)
......
......@@ -3,12 +3,14 @@ try:
except ImportError:
pass
def overridable(name, default=None):
try:
return getattr(settings, name, default)
except NameError:
return default
#: Enables Suds request/response logging
#: Set Django ``settings.DEBUG`` to override.
DEBUG = overridable('DEBUG', False)
......
......@@ -96,8 +96,10 @@ class SoapTest(XMLAssertions):
:param body: XML response data as bytes.
:param status: HTTP status code to return.
:param pattern: Optional. Regexp pattern to match against the request URL. Useful if your test communicates with multiple SOAP APIs that need different mock responses.
:param test_request: Optional. Function to call with a request object, before returning the response. Can use this to run assertions on the SOAP request XML.
:param pattern: Optional. Regexp pattern to match against the request URL. Useful if your
test communicates with multiple SOAP APIs that need different mock responses.
:param test_request: Optional. Function to call with a request object, before returning
the response. Can use this to run assertions on the SOAP request XML.
:return: :class:`soap.http.HttpTransport <soap.http.HttpTransport>` object
:rtype: soap.http.HttpTransport
"""
......@@ -106,12 +108,14 @@ class SoapTest(XMLAssertions):
reply = Reply(status, headers, body)
transport = HttpTransport()
def surrogate(request, *args, **kwargs):
if pattern and not re.search(pattern, request.url):
return HttpTransport.send(transport, request, *args, **kwargs)
if test_request:
test_request(request)
return reply
transport.send = mock.MagicMock()
transport.send.side_effect = surrogate
return transport
# For compatibility import everything from soap.test.* and make it accessible at soap.tests.*
from ..test import * # NOQA
import unittest
import soap
from soap import settings
from django.test import TestCase
import soap
class SOAPTest(unittest.TestCase):
class SOAPTest(TestCase):
def test_basic_soap_method_call(self):
wsdl = 'http://www.webservicex.net/uszip.asmx?WSDL'
client = soap.get_client(wsdl, 'LOCATIONS')
......@@ -20,7 +19,7 @@ class SOAPProxyTest(TestCase):
""" Set sandbox/settings to use """
if settings.PROXY_URL:
wsdl = 'http://www.webservicex.net/uszip.asmx?WSDL'
client = soap.get_client(wsdl, 'LOCATIONS')
soap.get_client(wsdl, 'LOCATIONS')
def test_private_soap_with_proxy(self):
""" Intended for local and private use only
......@@ -30,4 +29,4 @@ class SOAPProxyTest(TestCase):
if not private_ip:
return
wsdl = 'http://{}/TAXCCH/Service3.5.svc?singleWsdl'.format(private_ip)
client = soap.get_client(wsdl, 'CCH')
soap.get_client(wsdl, 'CCH')
#!/bin/sh
cd sandbox
python3 manage.py test
[tox]
toxworkdir={env:TOX_WORK_DIR:.tox}
envlist = py{34,35,36}-django{19,110,111}
[testenv]
commands =
flake8
{envpython} {toxinidir}/sandbox/manage.py test soap
extras = development
deps =
django19: django>=1.9,<1.10
django110: django>=1.10,<1.11
django111: django>=1.11,<1.12
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment