esirius_swi: add esirius sitewaitingindicator connector (#59868)

This commit is contained in:
Nicolas Roche 2021-12-16 16:27:54 +01:00
parent aa916550b3
commit afbe89fd51
8 changed files with 722 additions and 0 deletions

View File

@ -0,0 +1,44 @@
# Generated by Django 2.2.19 on 2022-01-19 14:08
from django.db import migrations, models
class Migration(migrations.Migration):
initial = True
dependencies = [
('base', '0029_auto_20210202_1627'),
]
operations = [
migrations.CreateModel(
name='ESiriusSwi',
fields=[
(
'id',
models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID'),
),
('title', models.CharField(max_length=50, verbose_name='Title')),
('slug', models.SlugField(unique=True, verbose_name='Identifier')),
('description', models.TextField(verbose_name='Description')),
('base_url', models.URLField(help_text='with trailing slash', verbose_name='Base API URL')),
(
'verify_cert',
models.BooleanField(default=True, verbose_name='Check HTTPS Certificate validity'),
),
(
'users',
models.ManyToManyField(
blank=True,
related_name='_esiriusswi_users_+',
related_query_name='+',
to='base.ApiUser',
),
),
],
options={
'verbose_name': 'eSirius sitewaitingindicator',
},
),
]

View File

@ -0,0 +1,83 @@
# -*- coding: utf-8 -*-
# Copyright (C) 2021 Entr'ouvert
#
# This program is free software: you can redistribute it and/or modify it
# under the terms of the GNU Affero General Public License as published
# by the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
from urllib.parse import urljoin
import zeep
from django.db import models
from django.utils.translation import ugettext_lazy as _
from passerelle.base.models import BaseResource
from passerelle.utils.api import endpoint
from passerelle.utils.jsonresponse import APIError
class ESiriusSwi(BaseResource):
base_url = models.URLField(_('Base API URL'), help_text=_('with trailing slash'))
verify_cert = models.BooleanField(default=True, verbose_name=_('Check HTTPS Certificate validity'))
category = _('Business Process Connectors')
class Meta:
verbose_name = u'eSirius sitewaitingindicator'
@classmethod
def get_verbose_name(cls):
return cls._meta.verbose_name
def check_status(self):
wsdl_url = urljoin(self.base_url, 'v1.0?wsdl')
response = self.requests.get(wsdl_url)
response.raise_for_status()
def get_client(self):
wsdl_url = urljoin(self.base_url, 'v1.0?wsdl')
return self.soap_client(wsdl_url=wsdl_url, settings=zeep.Settings(strict=False))
def call(self, service, **kwargs):
client = self.get_client()
method = getattr(client.service, service)
try:
return method(**kwargs)
except Exception as e:
raise APIError(e)
@endpoint(
description=_('Returns indicators for all the sites'),
perm='can_access',
)
def get_all_indicators(self, request):
response = self.call('getAllIndicators')
data = []
for item_src in response or []:
item_dest = {}
for key in [
'cumulatedWaitingVisitorNumber',
'estimatedAvgWaitingTime',
'estimatedMaxWaitingTime',
'estimatedWaitingTimeForNextTicket',
'name',
'realAvgWaitingTime',
'realMaxWaitingTime',
'resourceNumber',
'serviceWaitingIndicatorWSList',
'siteCode',
'waitingVisitorNumber',
'weekHoursWS',
]:
item_dest[key] = item_src[key]
data.append(item_dest)
return {'err': 0, 'data': data}

View File

@ -0,0 +1,66 @@
# -*- coding: utf-8 -*-
# Copyright (C) 2021 Entr'ouvert
#
# This program is free software: you can redistribute it and/or modify it
# under the terms of the GNU Affero General Public License as published
# by the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
from urllib.parse import urljoin
import zeep
from django.db import models
from django.utils.translation import ugettext_lazy as _
from passerelle.base.models import BaseResource
from passerelle.utils.jsonresponse import APIError
class Maelis(BaseResource):
base_url = models.URLField(_('Base API URL'))
category = _('Business Process Connectors')
class Meta:
verbose_name = u'eSirius sitewaitingindicator'
@classmethod
def get_verbose_name(cls):
return cls._meta.verbose_name
def check_status(self):
response = self.requests.get(self.base_url)
response.raise_for_status()
def get_client(self, wsdl_name):
wsdl_url = urljoin(self.base_url, wsdl_name)
session = requests.Session()
session.verify = False
transport = Transport(session=session)
client = zeep.Client(WSDL_URL, transport=transport)
return self.soap_client(wsdl_url=wsdl_url, wsse=wsse)
def call(self, wsdl_name, service, **kwargs):
client = self.get_client(wsdl_name)
method = getattr(client.service, service)
try:
return method(**kwargs)
except zeep.exceptions.Fault as e:
raise APIError(e)
@endpoint(
description=_('Returns indicators for all the sites'),
perm='can_access',
)
def get_sites_indicators(self, request):
response = self.call('v1.0?wsdl', 'getSitesIndicators')
return response

View File

@ -0,0 +1,22 @@
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<ns1:getAllIndicatorsResponse xmlns:ns1="http://www.esii.com/esirius/sitewaitingindicator/v1.0">
<ns1:siteWaitingIndicatorList>
<ns2:SiteWaitingIndicatorWS xmlns:ns2="http://bean.v1_0.sitewaitingindicator.webservices.esirius.es2i.com">
<ns2:cumulatedWaitingVisitorNumber>6</ns2:cumulatedWaitingVisitorNumber>
<ns2:estimatedAvgWaitingTime>00:03:29</ns2:estimatedAvgWaitingTime>
<ns2:estimatedMaxWaitingTime>-</ns2:estimatedMaxWaitingTime>
<ns2:estimatedWaitingTimeForNextTicket>-</ns2:estimatedWaitingTimeForNextTicket>
<ns2:name>Braine-l'Alleud</ns2:name>
<ns2:realAvgWaitingTime>00:03:51</ns2:realAvgWaitingTime>
<ns2:realMaxWaitingTime>00:06:42</ns2:realMaxWaitingTime>
<ns2:resourceNumber>9.000003</ns2:resourceNumber>
<ns2:serviceWaitingIndicatorWSList/>
<ns2:siteCode>site1</ns2:siteCode>
<ns2:waitingVisitorNumber>6</ns2:waitingVisitorNumber>
<ns2:weekHoursWS xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true"/>
</ns2:SiteWaitingIndicatorWS>
</ns1:siteWaitingIndicatorList>
</ns1:getAllIndicatorsResponse>
</soap:Body>
</soap:Envelope>

View File

@ -0,0 +1,412 @@
<?xml version='1.0' encoding='UTF-8'?><wsdl:definitions xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:tns="http://www.esii.com/esirius/sitewaitingindicator/v1.0" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:ns1="http://schemas.xmlsoap.org/soap/http" name="SiteWaitingIndicatorService" targetNamespace="http://www.esii.com/esirius/sitewaitingindicator/v1.0">
<wsdl:types>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:tns="http://bean.v1_0.service.webservices.esirius.es2i.com" attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://bean.v1_0.service.webservices.esirius.es2i.com">
<xsd:complexType name="DayHoursWS">
<xsd:sequence>
<xsd:element minOccurs="0" name="amStartTime" nillable="true" type="xsd:string"/>
<xsd:element minOccurs="0" name="amStopTime" nillable="true" type="xsd:string"/>
<xsd:element minOccurs="0" name="closed" type="xsd:boolean"/>
<xsd:element minOccurs="0" name="pmStartTime" nillable="true" type="xsd:string"/>
<xsd:element minOccurs="0" name="pmStopTime" nillable="true" type="xsd:string"/>
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="WeekHoursWS">
<xsd:sequence>
<xsd:element minOccurs="0" name="friday" nillable="true" type="tns:DayHoursWS"/>
<xsd:element minOccurs="0" name="monday" nillable="true" type="tns:DayHoursWS"/>
<xsd:element minOccurs="0" name="saturday" nillable="true" type="tns:DayHoursWS"/>
<xsd:element minOccurs="0" name="sunday" nillable="true" type="tns:DayHoursWS"/>
<xsd:element minOccurs="0" name="thursday" nillable="true" type="tns:DayHoursWS"/>
<xsd:element minOccurs="0" name="tuesday" nillable="true" type="tns:DayHoursWS"/>
<xsd:element minOccurs="0" name="wednesday" nillable="true" type="tns:DayHoursWS"/>
</xsd:sequence>
</xsd:complexType>
</xsd:schema>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:tns="http://www.esii.com/esirius/sitewaitingindicator/v1.0" xmlns:ns0="http://bean.v1_0.sitewaitingindicator.webservices.esirius.es2i.com" attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://www.esii.com/esirius/sitewaitingindicator/v1.0">
<xsd:import namespace="http://bean.v1_0.sitewaitingindicator.webservices.esirius.es2i.com"/>
<xsd:complexType name="ArrayOfString">
<xsd:sequence>
<xsd:element maxOccurs="unbounded" minOccurs="0" name="string" nillable="true" type="xsd:string"/>
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="string2ArrayOfStringMap">
<xsd:sequence>
<xsd:element maxOccurs="unbounded" minOccurs="0" name="entry">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="key" type="xsd:string"/>
<xsd:element minOccurs="0" name="value" type="tns:ArrayOfString"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:sequence>
</xsd:complexType>
<xsd:element name="getServiceIndicatorsBySites" type="tns:getServiceIndicatorsBySites"/>
<xsd:complexType name="getServiceIndicatorsBySites">
<xsd:sequence>
<xsd:element name="siteCodeArray" nillable="true" type="tns:ArrayOfString"/>
</xsd:sequence>
</xsd:complexType>
<xsd:element name="getServiceIndicatorsBySitesResponse" type="tns:getServiceIndicatorsBySitesResponse"/>
<xsd:complexType name="getServiceIndicatorsBySitesResponse">
<xsd:sequence>
<xsd:element minOccurs="0" name="serviceWaitingIndicatorList" type="ns0:ArrayOfServiceWaitingIndicatorWS"/>
</xsd:sequence>
</xsd:complexType>
<xsd:element name="getServiceIndicatorsBySiteAndFilters" type="tns:getServiceIndicatorsBySiteAndFilters"/>
<xsd:complexType name="getServiceIndicatorsBySiteAndFilters">
<xsd:sequence>
<xsd:element minOccurs="0" name="siteCode" nillable="true" type="xsd:string"/>
<xsd:element minOccurs="0" name="filterMap" nillable="true" type="tns:string2ArrayOfStringMap"/>
</xsd:sequence>
</xsd:complexType>
<xsd:element name="getServiceIndicatorsBySiteAndFiltersResponse" type="tns:getServiceIndicatorsBySiteAndFiltersResponse"/>
<xsd:complexType name="getServiceIndicatorsBySiteAndFiltersResponse">
<xsd:sequence>
<xsd:element minOccurs="0" name="serviceWaitingIndicatorList" type="ns0:ArrayOfServiceWaitingIndicatorWS"/>
</xsd:sequence>
</xsd:complexType>
<xsd:element name="getSitesIndicators" type="tns:getSitesIndicators"/>
<xsd:complexType name="getSitesIndicators">
<xsd:sequence/>
</xsd:complexType>
<xsd:element name="getSitesIndicatorsResponse" type="tns:getSitesIndicatorsResponse"/>
<xsd:complexType name="getSitesIndicatorsResponse">
<xsd:sequence>
<xsd:element minOccurs="0" name="siteWaitingIndicatorList" type="ns0:ArrayOfSiteWaitingIndicatorWS"/>
</xsd:sequence>
</xsd:complexType>
<xsd:element name="getAllIndicators" type="tns:getAllIndicators"/>
<xsd:complexType name="getAllIndicators">
<xsd:sequence/>
</xsd:complexType>
<xsd:element name="getAllIndicatorsResponse" type="tns:getAllIndicatorsResponse"/>
<xsd:complexType name="getAllIndicatorsResponse">
<xsd:sequence>
<xsd:element minOccurs="0" name="siteWaitingIndicatorList" type="ns0:ArrayOfSiteWaitingIndicatorWS"/>
</xsd:sequence>
</xsd:complexType>
<xsd:element name="getAllIndicatorsFilteredByServiceType" type="tns:getAllIndicatorsFilteredByServiceType"/>
<xsd:complexType name="getAllIndicatorsFilteredByServiceType">
<xsd:sequence/>
</xsd:complexType>
<xsd:element name="getAllIndicatorsFilteredByServiceTypeResponse" type="tns:getAllIndicatorsFilteredByServiceTypeResponse"/>
<xsd:complexType name="getAllIndicatorsFilteredByServiceTypeResponse">
<xsd:sequence>
<xsd:element minOccurs="0" name="siteWaitingIndicatorList" type="ns0:ArrayOfSiteWaitingIndicatorWS"/>
</xsd:sequence>
</xsd:complexType>
<xsd:element name="getServiceIndicatorsBySiteAndServices" type="tns:getServiceIndicatorsBySiteAndServices"/>
<xsd:complexType name="getServiceIndicatorsBySiteAndServices">
<xsd:sequence>
<xsd:element minOccurs="0" name="siteCode" nillable="true" type="xsd:string"/>
<xsd:element name="serviceIdArray" nillable="true" type="tns:ArrayOfString"/>
</xsd:sequence>
</xsd:complexType>
<xsd:element name="getServiceIndicatorsBySiteAndServicesResponse" type="tns:getServiceIndicatorsBySiteAndServicesResponse"/>
<xsd:complexType name="getServiceIndicatorsBySiteAndServicesResponse">
<xsd:sequence>
<xsd:element minOccurs="0" name="serviceWaitingIndicatorList" type="ns0:ArrayOfServiceWaitingIndicatorWS"/>
</xsd:sequence>
</xsd:complexType>
<xsd:element name="getAllIndicatorsBySites" type="tns:getAllIndicatorsBySites"/>
<xsd:complexType name="getAllIndicatorsBySites">
<xsd:sequence>
<xsd:element name="siteCodeArray" nillable="true" type="tns:ArrayOfString"/>
</xsd:sequence>
</xsd:complexType>
<xsd:element name="getAllIndicatorsBySitesResponse" type="tns:getAllIndicatorsBySitesResponse"/>
<xsd:complexType name="getAllIndicatorsBySitesResponse">
<xsd:sequence>
<xsd:element minOccurs="0" name="siteWaitingIndicatorList" type="ns0:ArrayOfSiteWaitingIndicatorWS"/>
</xsd:sequence>
</xsd:complexType>
<xsd:element name="getSitesIndicatorsBySites" type="tns:getSitesIndicatorsBySites"/>
<xsd:complexType name="getSitesIndicatorsBySites">
<xsd:sequence>
<xsd:element name="siteCodeArray" nillable="true" type="tns:ArrayOfString"/>
</xsd:sequence>
</xsd:complexType>
<xsd:element name="getSitesIndicatorsBySitesResponse" type="tns:getSitesIndicatorsBySitesResponse"/>
<xsd:complexType name="getSitesIndicatorsBySitesResponse">
<xsd:sequence>
<xsd:element minOccurs="0" name="siteWaitingIndicatorList" type="ns0:ArrayOfSiteWaitingIndicatorWS"/>
</xsd:sequence>
</xsd:complexType>
</xsd:schema>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:tns="http://bean.v1_0.sitewaitingindicator.webservices.esirius.es2i.com" xmlns:ns0="http://bean.v1_0.service.webservices.esirius.es2i.com" attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://bean.v1_0.sitewaitingindicator.webservices.esirius.es2i.com">
<xsd:import namespace="http://bean.v1_0.service.webservices.esirius.es2i.com"/>
<xsd:complexType name="ArrayOfServiceWaitingIndicatorWS">
<xsd:sequence>
<xsd:element maxOccurs="unbounded" minOccurs="0" name="ServiceWaitingIndicatorWS" nillable="true" type="tns:ServiceWaitingIndicatorWS"/>
</xsd:sequence>
</xsd:complexType>
<xsd:complexType abstract="true" name="AbstractWaitingIndicatorWS">
<xsd:sequence>
<xsd:element minOccurs="0" name="cumulatedWaitingVisitorNumber" type="xsd:int"/>
<xsd:element minOccurs="0" name="estimatedAvgWaitingTime" nillable="true" type="xsd:string"/>
<xsd:element minOccurs="0" name="estimatedMaxWaitingTime" nillable="true" type="xsd:string"/>
<xsd:element minOccurs="0" name="estimatedWaitingTimeForNextTicket" nillable="true" type="xsd:string"/>
<xsd:element minOccurs="0" name="name" nillable="true" type="xsd:string"/>
<xsd:element minOccurs="0" name="realAvgWaitingTime" nillable="true" type="xsd:string"/>
<xsd:element minOccurs="0" name="realMaxWaitingTime" nillable="true" type="xsd:string"/>
<xsd:element minOccurs="0" name="resourceNumber" type="xsd:float"/>
<xsd:element minOccurs="0" name="waitingVisitorNumber" type="xsd:int"/>
<xsd:element minOccurs="0" name="weekHoursWS" nillable="true" type="ns0:WeekHoursWS"/>
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="ServiceOptionWS">
<xsd:sequence>
<xsd:element minOccurs="0" name="serviceOption" nillable="true" type="xsd:string"/>
<xsd:element minOccurs="0" name="used" type="xsd:boolean"/>
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="SiteWaitingIndicatorWS">
<xsd:complexContent>
<xsd:extension base="tns:AbstractWaitingIndicatorWS">
<xsd:sequence>
<xsd:element minOccurs="0" name="serviceWaitingIndicatorWSList" nillable="true" type="tns:ArrayOfServiceWaitingIndicatorWS"/>
<xsd:element minOccurs="0" name="siteCode" nillable="true" type="xsd:string"/>
</xsd:sequence>
</xsd:extension>
</xsd:complexContent>
</xsd:complexType>
<xsd:complexType name="ArrayOfSiteWaitingIndicatorWS">
<xsd:sequence>
<xsd:element maxOccurs="unbounded" minOccurs="0" name="SiteWaitingIndicatorWS" nillable="true" type="tns:SiteWaitingIndicatorWS"/>
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="ServiceTypeWS">
<xsd:sequence>
<xsd:element minOccurs="0" name="serviceOptionList" nillable="true" type="tns:ArrayOfServiceOptionWS"/>
<xsd:element minOccurs="0" name="serviceType" nillable="true" type="xsd:string"/>
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="ArrayOfServiceOptionWS">
<xsd:sequence>
<xsd:element maxOccurs="unbounded" minOccurs="0" name="ServiceOptionWS" nillable="true" type="tns:ServiceOptionWS"/>
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="ServiceWaitingIndicatorWS">
<xsd:complexContent>
<xsd:extension base="tns:AbstractWaitingIndicatorWS">
<xsd:sequence>
<xsd:element minOccurs="0" name="businessIdentity" type="xsd:int"/>
<xsd:element minOccurs="0" name="estimatedCallTimeForNewVisitor" nillable="true" type="xsd:string"/>
<xsd:element minOccurs="0" name="guaranteedCallTimeForNewVisitor" nillable="true" type="xsd:string"/>
<xsd:element minOccurs="0" name="lastTicketValue" nillable="true" type="xsd:string"/>
<xsd:element minOccurs="0" name="levelOnEstimatedWaitingTimeForNewVisitor" type="xsd:int"/>
<xsd:element minOccurs="0" name="open" type="xsd:boolean"/>
<xsd:element minOccurs="0" name="serviceIsFull" type="xsd:boolean"/>
<xsd:element minOccurs="0" name="serviceServed" type="xsd:boolean"/>
<xsd:element minOccurs="0" name="serviceTypeWS" nillable="true" type="tns:ServiceTypeWS"/>
<xsd:element minOccurs="0" name="trend" type="xsd:int"/>
<xsd:element minOccurs="0" name="waitingConditionForNewVisitor" nillable="true" type="tns:WaitingConditionWS"/>
<xsd:element minOccurs="0" name="workStationNumberOverVeryLowPriority" type="xsd:int"/>
<xsd:element minOccurs="0" name="workStationNumberWithAbsolutePriority" type="xsd:int"/>
</xsd:sequence>
</xsd:extension>
</xsd:complexContent>
</xsd:complexType>
<xsd:complexType name="WaitingConditionWS">
<xsd:sequence>
<xsd:element minOccurs="0" name="value" type="xsd:int"/>
</xsd:sequence>
</xsd:complexType>
</xsd:schema>
</wsdl:types>
<wsdl:message name="getAllIndicatorsFilteredByServiceTypeResponse">
<wsdl:part element="tns:getAllIndicatorsFilteredByServiceTypeResponse" name="parameters">
</wsdl:part>
</wsdl:message>
<wsdl:message name="getServiceIndicatorsBySiteAndFiltersResponse">
<wsdl:part element="tns:getServiceIndicatorsBySiteAndFiltersResponse" name="parameters">
</wsdl:part>
</wsdl:message>
<wsdl:message name="getSitesIndicatorsBySitesResponse">
<wsdl:part element="tns:getSitesIndicatorsBySitesResponse" name="parameters">
</wsdl:part>
</wsdl:message>
<wsdl:message name="getSitesIndicators">
<wsdl:part element="tns:getSitesIndicators" name="parameters">
</wsdl:part>
</wsdl:message>
<wsdl:message name="getSitesIndicatorsResponse">
<wsdl:part element="tns:getSitesIndicatorsResponse" name="parameters">
</wsdl:part>
</wsdl:message>
<wsdl:message name="getAllIndicators">
<wsdl:part element="tns:getAllIndicators" name="parameters">
</wsdl:part>
</wsdl:message>
<wsdl:message name="getServiceIndicatorsBySitesResponse">
<wsdl:part element="tns:getServiceIndicatorsBySitesResponse" name="parameters">
</wsdl:part>
</wsdl:message>
<wsdl:message name="getAllIndicatorsBySites">
<wsdl:part element="tns:getAllIndicatorsBySites" name="parameters">
</wsdl:part>
</wsdl:message>
<wsdl:message name="getServiceIndicatorsBySiteAndServicesResponse">
<wsdl:part element="tns:getServiceIndicatorsBySiteAndServicesResponse" name="parameters">
</wsdl:part>
</wsdl:message>
<wsdl:message name="getServiceIndicatorsBySites">
<wsdl:part element="tns:getServiceIndicatorsBySites" name="parameters">
</wsdl:part>
</wsdl:message>
<wsdl:message name="getAllIndicatorsBySitesResponse">
<wsdl:part element="tns:getAllIndicatorsBySitesResponse" name="parameters">
</wsdl:part>
</wsdl:message>
<wsdl:message name="getServiceIndicatorsBySiteAndFilters">
<wsdl:part element="tns:getServiceIndicatorsBySiteAndFilters" name="parameters">
</wsdl:part>
</wsdl:message>
<wsdl:message name="getAllIndicatorsResponse">
<wsdl:part element="tns:getAllIndicatorsResponse" name="parameters">
</wsdl:part>
</wsdl:message>
<wsdl:message name="getAllIndicatorsFilteredByServiceType">
<wsdl:part element="tns:getAllIndicatorsFilteredByServiceType" name="parameters">
</wsdl:part>
</wsdl:message>
<wsdl:message name="getServiceIndicatorsBySiteAndServices">
<wsdl:part element="tns:getServiceIndicatorsBySiteAndServices" name="parameters">
</wsdl:part>
</wsdl:message>
<wsdl:message name="getSitesIndicatorsBySites">
<wsdl:part element="tns:getSitesIndicatorsBySites" name="parameters">
</wsdl:part>
</wsdl:message>
<wsdl:portType name="SiteWaitingIndicatorService">
<wsdl:operation name="getServiceIndicatorsBySites">
<wsdl:input message="tns:getServiceIndicatorsBySites" name="getServiceIndicatorsBySites">
</wsdl:input>
<wsdl:output message="tns:getServiceIndicatorsBySitesResponse" name="getServiceIndicatorsBySitesResponse">
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="getServiceIndicatorsBySiteAndFilters">
<wsdl:input message="tns:getServiceIndicatorsBySiteAndFilters" name="getServiceIndicatorsBySiteAndFilters">
</wsdl:input>
<wsdl:output message="tns:getServiceIndicatorsBySiteAndFiltersResponse" name="getServiceIndicatorsBySiteAndFiltersResponse">
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="getSitesIndicators">
<wsdl:input message="tns:getSitesIndicators" name="getSitesIndicators">
</wsdl:input>
<wsdl:output message="tns:getSitesIndicatorsResponse" name="getSitesIndicatorsResponse">
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="getAllIndicators">
<wsdl:input message="tns:getAllIndicators" name="getAllIndicators">
</wsdl:input>
<wsdl:output message="tns:getAllIndicatorsResponse" name="getAllIndicatorsResponse">
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="getAllIndicatorsFilteredByServiceType">
<wsdl:input message="tns:getAllIndicatorsFilteredByServiceType" name="getAllIndicatorsFilteredByServiceType">
</wsdl:input>
<wsdl:output message="tns:getAllIndicatorsFilteredByServiceTypeResponse" name="getAllIndicatorsFilteredByServiceTypeResponse">
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="getServiceIndicatorsBySiteAndServices">
<wsdl:input message="tns:getServiceIndicatorsBySiteAndServices" name="getServiceIndicatorsBySiteAndServices">
</wsdl:input>
<wsdl:output message="tns:getServiceIndicatorsBySiteAndServicesResponse" name="getServiceIndicatorsBySiteAndServicesResponse">
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="getAllIndicatorsBySites">
<wsdl:input message="tns:getAllIndicatorsBySites" name="getAllIndicatorsBySites">
</wsdl:input>
<wsdl:output message="tns:getAllIndicatorsBySitesResponse" name="getAllIndicatorsBySitesResponse">
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="getSitesIndicatorsBySites">
<wsdl:input message="tns:getSitesIndicatorsBySites" name="getSitesIndicatorsBySites">
</wsdl:input>
<wsdl:output message="tns:getSitesIndicatorsBySitesResponse" name="getSitesIndicatorsBySitesResponse">
</wsdl:output>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="SiteWaitingIndicatorServiceSoapBinding" type="tns:SiteWaitingIndicatorService">
<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="getServiceIndicatorsBySites">
<soap:operation soapAction="" style="document"/>
<wsdl:input name="getServiceIndicatorsBySites">
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output name="getServiceIndicatorsBySitesResponse">
<soap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="getServiceIndicatorsBySiteAndFilters">
<soap:operation soapAction="" style="document"/>
<wsdl:input name="getServiceIndicatorsBySiteAndFilters">
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output name="getServiceIndicatorsBySiteAndFiltersResponse">
<soap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="getSitesIndicators">
<soap:operation soapAction="" style="document"/>
<wsdl:input name="getSitesIndicators">
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output name="getSitesIndicatorsResponse">
<soap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="getAllIndicators">
<soap:operation soapAction="" style="document"/>
<wsdl:input name="getAllIndicators">
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output name="getAllIndicatorsResponse">
<soap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="getAllIndicatorsFilteredByServiceType">
<soap:operation soapAction="" style="document"/>
<wsdl:input name="getAllIndicatorsFilteredByServiceType">
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output name="getAllIndicatorsFilteredByServiceTypeResponse">
<soap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="getServiceIndicatorsBySiteAndServices">
<soap:operation soapAction="" style="document"/>
<wsdl:input name="getServiceIndicatorsBySiteAndServices">
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output name="getServiceIndicatorsBySiteAndServicesResponse">
<soap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="getAllIndicatorsBySites">
<soap:operation soapAction="" style="document"/>
<wsdl:input name="getAllIndicatorsBySites">
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output name="getAllIndicatorsBySitesResponse">
<soap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="getSitesIndicatorsBySites">
<soap:operation soapAction="" style="document"/>
<wsdl:input name="getSitesIndicatorsBySites">
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output name="getSitesIndicatorsBySitesResponse">
<soap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="SiteWaitingIndicatorService">
<wsdl:port binding="tns:SiteWaitingIndicatorServiceSoapBinding" name="SiteWaitingIndicatorServicePort">
<soap:address location="http://waitingtime-test.braine-lalleud.be/eSirius/webservices/sitewaitingindicator/v1.0"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>

View File

@ -18,6 +18,7 @@ INSTALLED_APPS += (
'passerelle.contrib.adict',
'passerelle.contrib.caluire_axel',
'passerelle.contrib.dpark',
'passerelle.contrib.esirius_swi',
'passerelle.contrib.fake_family',
'passerelle.contrib.gdema',
'passerelle.contrib.grandlyon_streetsections',

94
tests/test_esirius_swi.py Normal file
View File

@ -0,0 +1,94 @@
# Copyright (C) 2021 Entr'ouvert
#
# This program is free software: you can redistribute it and/or modify it
# under the terms of the GNU Affero General Public License as published
# by the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import json
import os
import mock
import pytest
import utils
from passerelle.contrib.esirius_swi.models import ESiriusSwi
pytestmark = pytest.mark.django_db
TEST_BASE_DIR = os.path.join(os.path.dirname(__file__), 'data', 'esirius_swi')
def get_xml_file(filename):
with open(os.path.join(TEST_BASE_DIR, filename), 'rb') as desc:
return desc.read()
def get_json_file(filename):
with open(os.path.join(TEST_BASE_DIR, "%s.json" % filename)) as fd:
return json.load(fd)
@pytest.fixture
def v1_service_wsdl():
return get_xml_file('v1.0.wsdl')
@pytest.fixture
def connector(db):
return utils.setup_access_rights(
ESiriusSwi.objects.create(
slug='test', base_url='https://example.org/eSirius/webservices/sitewaitingindicator/'
)
)
@mock.patch('passerelle.utils.Request.get')
@mock.patch('passerelle.utils.Request.post')
def test_soap_content_error(mocked_post, mocked_get, v1_service_wsdl, connector, app):
mocked_get.return_value = mock.Mock(content=v1_service_wsdl)
mocked_post.return_value = mock.Mock(
content='oups',
status_code=200,
headers={'Content-Type': 'text/xml'},
)
resp = app.get('/esirius-swi/test/get_all_indicators')
assert resp.json['err'] == 1
assert resp.json['err_desc'] == "'NoneType' object has no attribute 'getroottree'"
@mock.patch('passerelle.utils.Request.get')
@mock.patch('passerelle.utils.Request.post')
def test_get_all_indicator(mocked_post, mocked_get, v1_service_wsdl, connector, app):
mocked_get.return_value = mock.Mock(content=v1_service_wsdl)
mocked_post.return_value = mock.Mock(
content=get_xml_file('get_all_indicators.xml'),
status_code=200,
headers={'Content-Type': 'text/xml'},
)
resp = app.get('/esirius-swi/test/get_all_indicators')
assert resp.json['err'] == 0
assert resp.json['data'] == [
{
'cumulatedWaitingVisitorNumber': 6,
'estimatedAvgWaitingTime': '00:03:29',
'estimatedMaxWaitingTime': '-',
'estimatedWaitingTimeForNextTicket': '-',
'name': "Braine-l'Alleud",
'realAvgWaitingTime': '00:03:51',
'realMaxWaitingTime': '00:06:42',
'resourceNumber': 9.000003,
'serviceWaitingIndicatorWSList': None,
'siteCode': 'site1',
'waitingVisitorNumber': None,
'weekHoursWS': None,
}
]