Refactoring: fix most of the (many) 'flake8' complaints

This commit is contained in:
Michael Bideau 2019-08-22 16:02:06 +00:00
parent 9df996e5ad
commit a951f062f0
13 changed files with 401 additions and 390 deletions

2
.flake8 Normal file
View File

@ -0,0 +1,2 @@
[flake8]
max-line-length = 100

View File

@ -24,6 +24,7 @@ from django.forms import ModelForm
from .models import ForwardFile, Collectivite, Guichet
class ForwardFileForm(ModelForm):
"""Form for the ForwardFile model."""

View File

@ -26,24 +26,24 @@
JSON_SCHEMA_FILE = {
"description": "A file object",
"$id" : "#file",
"$id": "#file",
"type": "object",
"properties": {
"content" : {"type": "string"},
"content": {"type": "string"},
"content_type": {"type": ["string", "null"]},
"filename" : {"type": "string"}
"filename": {"type": "string"}
},
"required": ["content", "filename"]
}
JSON_SCHEMA_FILE_B64 = {
"description": "A file object encoded in base64",
"$id" : "#file",
"$id": "#file",
"type": "object",
"properties": {
"b64_content" : {"type": "string"},
"b64_content": {"type": "string"},
"content_type": {"type": ["string", "null"]},
"filename" : {"type": "string"}
"filename": {"type": "string"}
},
"required": ["b64_content", "filename"]
}
@ -51,13 +51,13 @@ JSON_SCHEMA_FILE_B64 = {
JSON_SCHEMA_DATE_FRENCH = {
"type": "string",
# pylint: disable=anomalous-backslash-in-string
"pattern": "^(0?[1-9]|[12][0-9]|3[01])/(0?[1-9]|1[012])/\d{4}$"
"pattern": "^(0?[1-9]|[12][0-9]|3[01])/(0?[1-9]|1[012])/\d{4}$" # noqa: W605
}
JSON_SCHEMA_CHECK_STATUS_OUT = {
"$schema": "http://json-schema.org/draft-07/schema#",
"title" : "Response of an openADS 'connexion' test",
"type" : "object",
"title": "Response of an openADS 'connexion' test",
"type": "object",
"properties": {
"response": {"type": "integer"}
},
@ -66,12 +66,12 @@ JSON_SCHEMA_CHECK_STATUS_OUT = {
JSON_SCHEMA_CREATE_DOSSIER_IN = {
"$schema": "http://json-schema.org/draft-07/schema#",
"title" : "Incoming request to create a 'dossier' in openADS.API",
"title": "Incoming request to create a 'dossier' in openADS.API",
"definitions": {
"refs-cadastrales": {
"description": "The 3 items of a 'cadastrale' reference",
"$id" : "#refs-cadastrales",
"type" : "array",
"$id": "#refs-cadastrales",
"type": "array",
"items": {
"type": "string"
},
@ -99,11 +99,11 @@ JSON_SCHEMA_CREATE_DOSSIER_IN = {
"plan_cadastral_3": {"$ref": "#/definitions/file_plan_cadastral"},
"plan_cadastral_4": {"$ref": "#/definitions/file_plan_cadastral"},
"plan_cadastral_5": {"$ref": "#/definitions/file_plan_cadastral"},
"terrain_numero_voie" : {"type": "string"},
"terrain_nom_voie" : {"type": "string"},
"terrain_code_postal" : {"type": "string"},
"terrain_localite" : {"type": "string"},
"terrain_lieu_dit" : {"type": ["string", "null"]},
"terrain_numero_voie": {"type": "string"},
"terrain_nom_voie": {"type": "string"},
"terrain_code_postal": {"type": "string"},
"terrain_localite": {"type": "string"},
"terrain_lieu_dit": {"type": ["string", "null"]},
"reference_cadastrale": {
"description": "A list of 'cadastrales' references",
"type": "array",
@ -116,24 +116,24 @@ JSON_SCHEMA_CREATE_DOSSIER_IN = {
"description": "A list of 'cadastrales' references",
# conditionaly required and typed below
},
"proprietaire" : {"enum": ["Oui", "Non"]},
"qualite" : {"type": "string"},
"denomination" : {}, # conditionaly required and typed below
"raison_sociale" : {}, # conditionaly required and typed below
"nom" : {"type": "string"},
"prenom" : {"type": "string"},
"numero_voie" : {"type": "string"},
"nom_voie" : {"type": "string"},
"code_postal" : {"type": "string"},
"localite" : {"type": "string"},
"lieu_dit" : {"type": ["string", "null"]},
"mandataire_nom" : {}, # conditionaly required and typed below
"mandataire_prenom" : {}, # conditionaly required and typed below
"proprietaire": {"enum": ["Oui", "Non"]},
"qualite": {"type": "string"},
"denomination": {}, # conditionaly required and typed below
"raison_sociale": {}, # conditionaly required and typed below
"nom": {"type": "string"},
"prenom": {"type": "string"},
"numero_voie": {"type": "string"},
"nom_voie": {"type": "string"},
"code_postal": {"type": "string"},
"localite": {"type": "string"},
"lieu_dit": {"type": ["string", "null"]},
"mandataire_nom": {}, # conditionaly required and typed below
"mandataire_prenom": {}, # conditionaly required and typed below
"mandataire_numero_voie": {}, # conditionaly required and typed below
"mandataire_nom_voie" : {}, # conditionaly required and typed below
"mandataire_nom_voie": {}, # conditionaly required and typed below
"mandataire_code_postal": {}, # conditionaly required and typed below
"mandataire_localite" : {}, # conditionaly required and typed below
"mandataire_lieu_dit" : {} # conditionaly required and typed below
"mandataire_localite": {}, # conditionaly required and typed below
"mandataire_lieu_dit": {} # conditionaly required and typed below
},
# requirements
@ -166,7 +166,7 @@ JSON_SCHEMA_CREATE_DOSSIER_IN = {
{
"properties": {
"qualite": {"const": "Un particulier"},
"denomination" : {"type": "null"},
"denomination": {"type": "null"},
"raison_sociale": {"type": "null"}
}
},
@ -176,7 +176,7 @@ JSON_SCHEMA_CREATE_DOSSIER_IN = {
{
"properties": {
"qualite": {"const": "Une personne morale"},
"denomination" : {"type": "string"},
"denomination": {"type": "string"},
"raison_sociale": {"type": "string"}
},
"required": ["denomination", "raison_sociale"]
@ -193,13 +193,13 @@ JSON_SCHEMA_CREATE_DOSSIER_IN = {
{
"properties": {
"proprietaire": {"const": "Oui"},
"mandataire_nom" : {"type": "null"},
"mandataire_prenom" : {"type": "null"},
"mandataire_nom": {"type": "null"},
"mandataire_prenom": {"type": "null"},
"mandataire_numero_voie": {"type": "null"},
"mandataire_nom_voie" : {"type": "null"},
"mandataire_nom_voie": {"type": "null"},
"mandataire_code_postal": {"type": "null"},
"mandataire_localite" : {"type": "null"},
"mandataire_lieu_dit" : {"type": "null"}
"mandataire_localite": {"type": "null"},
"mandataire_lieu_dit": {"type": "null"}
}
},
@ -210,14 +210,14 @@ JSON_SCHEMA_CREATE_DOSSIER_IN = {
{
"properties": {
"proprietaire": {"const": "Non"},
"mandataire_nom" : {"type": "string"},
"mandataire_prenom" : {"type": "string"},
"mandataire_nom": {"type": "string"},
"mandataire_prenom": {"type": "string"},
"mandataire_numero_voie": {"type": "string"},
"mandataire_nom_voie" : {"type": "string"},
"mandataire_nom_voie": {"type": "string"},
"mandataire_code_postal": {"type": "string"},
"mandataire_localite" : {"type": "string"},
"mandataire_qualite" : {"type": "string"},
"mandataire_lieu_dit" : {"type": ["string", "null"]}
"mandataire_localite": {"type": "string"},
"mandataire_qualite": {"type": "string"},
"mandataire_lieu_dit": {"type": ["string", "null"]}
},
"required": [
"mandataire_nom",
@ -238,7 +238,7 @@ JSON_SCHEMA_CREATE_DOSSIER_IN = {
{
"properties": {
"mandataire_qualite": {"const": "Un particulier"},
"mandataire_denomination" : {"type": "null"},
"mandataire_denomination": {"type": "null"},
"mandataire_raison_sociale": {"type": "null"}
}
},
@ -248,7 +248,7 @@ JSON_SCHEMA_CREATE_DOSSIER_IN = {
{
"properties": {
"mandataire_qualite": {"const": "Une personne morale"},
"mandataire_denomination" : {"type": "string"},
"mandataire_denomination": {"type": "string"},
"mandataire_raison_sociale": {"type": "string"}
},
"required": [
@ -296,8 +296,8 @@ JSON_SCHEMA_CREATE_DOSSIER_IN = {
JSON_SCHEMA_CREATE_DOSSIER_OUT = {
"$schema": "http://json-schema.org/draft-07/schema#",
"title" : "Response of a 'dossier' creation in openADS.API",
"type" : "object",
"title": "Response of a 'dossier' creation in openADS.API",
"type": "object",
"properties": {
"numero_dossier": {"type": "string"},
"recepisse": JSON_SCHEMA_FILE_B64
@ -307,14 +307,14 @@ JSON_SCHEMA_CREATE_DOSSIER_OUT = {
JSON_SCHEMA_GET_DOSSIER_OUT = {
"$schema": "http://json-schema.org/draft-07/schema#",
"title" : "Response of a 'dossier' creation in openADS.API",
"type" : "object",
"title": "Response of a 'dossier' creation in openADS.API",
"type": "object",
"properties": {
"etat" : {"type": "string"},
"date_depot" : JSON_SCHEMA_DATE_FRENCH,
"etat": {"type": "string"},
"date_depot": JSON_SCHEMA_DATE_FRENCH,
"date_decision": JSON_SCHEMA_DATE_FRENCH,
"date_limite_instruction": JSON_SCHEMA_DATE_FRENCH,
"decision" : {"type": "string"}
"decision": {"type": "string"}
},
"required": [
"etat",
@ -327,20 +327,20 @@ JSON_SCHEMA_GET_DOSSIER_OUT = {
JSON_SCHEMA_FORWARDFILE = {
"description": "A ForwardFile object (PDF document that must be forwarded to openADS)",
"$id" : "#forwardfile",
"$id": "#forwardfile",
"type": "object",
"properties": {
"id" : {"type": "integer"},
"numero_demande" : {"type": "string"},
"numero_dossier" : {"type": "string"},
"type_fichier" : {"type": "string"},
"file_hash" : {"type": "string"},
"orig_filename" : {"type": "string"},
"content_type" : {"type": "string"},
"upload_status" : {"type": "string"},
"upload_attempt" : {"type": "integer"},
"upload_msg" : {"type": "string"},
"content_size" : {"type": "integer"},
"id": {"type": "integer"},
"numero_demande": {"type": "string"},
"numero_dossier": {"type": "string"},
"type_fichier": {"type": "string"},
"file_hash": {"type": "string"},
"orig_filename": {"type": "string"},
"content_type": {"type": "string"},
"upload_status": {"type": "string"},
"upload_attempt": {"type": "integer"},
"upload_msg": {"type": "string"},
"content_size": {"type": "integer"},
"last_update_datetime": {"type": "string", "format": "date-time"}
},
"required": [
@ -361,43 +361,43 @@ JSON_SCHEMA_FORWARDFILE = {
JSON_SCHEMA_GET_FWD_FILES_OUT = {
"$schema": "http://json-schema.org/draft-07/schema#",
"title" : "Response of a request about the forwarding (detailled) of user files to openADS",
"type" : "array",
"title": "Response of a request about the forwarding (detailled) of user files to openADS",
"type": "array",
"items": {"$ref": "#/definitions/forwardfile"},
"definitions": {
"forwardfile" : JSON_SCHEMA_FORWARDFILE
"forwardfile": JSON_SCHEMA_FORWARDFILE
}
}
JSON_SCHEMA_GET_FWD_FILE_STATUS = {
"description": "The status of a ForwardFile",
"$id" : "#forwardfile-status",
"$id": "#forwardfile-status",
"type": "string",
# pylint: disable=anomalous-backslash-in-string
"pattern": "^\[\w+\] .+ => .+$"
"pattern": "^\[\w+\] .+ => .+$" # noqa: W605
}
JSON_SCHEMA_GET_FWD_FILES_STATUS_OUT = {
"$schema": "http://json-schema.org/draft-07/schema#",
"title" : "Response of a request about the forwarding (summarized) of user files to openADS",
"type" : "object",
"title": "Response of a request about the forwarding (summarized) of user files to openADS",
"type": "object",
"properties": {
"all_forwarded": {"type": "boolean"},
"pending" : {"type": "array", "items": {"$ref": "#/definitions/forwardfile-status"}},
"pending": {"type": "array", "items": {"$ref": "#/definitions/forwardfile-status"}},
"uploading": {"type": "array", "items": {"$ref": "#/definitions/forwardfile-status"}},
"success" : {"type": "array", "items": {"$ref": "#/definitions/forwardfile-status"}},
"failed" : {"type": "array", "items": {"$ref": "#/definitions/forwardfile-status"}}
"success": {"type": "array", "items": {"$ref": "#/definitions/forwardfile-status"}},
"failed": {"type": "array", "items": {"$ref": "#/definitions/forwardfile-status"}}
},
"required": ["all_forwarded", "pending", "uploading", "success", "failed"],
"definitions": {
"forwardfile-status" : JSON_SCHEMA_GET_FWD_FILE_STATUS
"forwardfile-status": JSON_SCHEMA_GET_FWD_FILE_STATUS
}
}
JSON_SCHEMA_GET_COURRIER_OUT = {
"$schema": "http://json-schema.org/draft-07/schema#",
"title" : "Response of a 'courrier' from an openADS 'dossier'",
"type" : "object",
"title": "Response of a 'courrier' from an openADS 'dossier'",
"type": "object",
"properties": {
"courrier": JSON_SCHEMA_FILE_B64
},

View File

@ -41,12 +41,12 @@ from passerelle.utils.jsonresponse import APIError
from .json_schemas import (
JSON_SCHEMA_CREATE_DOSSIER_IN,
#JSON_SCHEMA_CHECK_STATUS_OUT,
#JSON_SCHEMA_CREATE_DOSSIER_OUT,
#JSON_SCHEMA_GET_DOSSIER_OUT,
#JSON_SCHEMA_GET_FWD_FILES_OUT,
#JSON_SCHEMA_GET_FWD_FILES_STATUS_OUT,
#JSON_SCHEMA_GET_COURRIER_OUT
# JSON_SCHEMA_CHECK_STATUS_OUT,
# JSON_SCHEMA_CREATE_DOSSIER_OUT,
# JSON_SCHEMA_GET_DOSSIER_OUT,
# JSON_SCHEMA_GET_FWD_FILES_OUT,
# JSON_SCHEMA_GET_FWD_FILES_STATUS_OUT,
# JSON_SCHEMA_GET_COURRIER_OUT
)
from .utils import (
@ -169,7 +169,7 @@ class ForwardFile(models.Model, BaseModel): # pylint: disable=too-many-instance-
self.upload_file.delete()
# else, update metadata
else:
self.size = self.upload_file.size if self.upload_file else 0 # pylint: disable=no-member
self.size = self.upload_file.size if self.upload_file else 0 # noqa: E501, pylint: disable=no-member
self.update_file_hash()
self.update_content_type(only_if_empty=True)
# validation (calling self.clean())
@ -188,8 +188,7 @@ class ForwardFile(models.Model, BaseModel): # pylint: disable=too-many-instance-
raise ValidationError(
_("A %(object)s cannot have all the following fields empty: %(fields)s." % {
'object': self.get_verbose_name(),
'fields': ['file_hash', 'orig_filename', 'upload_file']}
)
'fields': ['file_hash', 'orig_filename', 'upload_file']})
)
return ret
@ -354,8 +353,7 @@ class Guichet(models.Model, BaseModel):
or (day > self.ouverture_sem_d
and day < self.fermeture_sem_d
and date_t > ouverture_jour_date_t
and date_t < fermeture_jour_date_t
)
and date_t < fermeture_jour_date_t)
)
return False
@ -480,7 +478,6 @@ class AtrealOpenads(BaseResource, HTTPResource, BaseModel):
u"Expecting '%s' value in JSON %s in file dict to be a %s (not a %s)" %
('file.filename', title, 'string', type(dict_file['filename'])))
def get_first_file_from_payload(self,
payload,
title='payload',
@ -503,14 +500,14 @@ class AtrealOpenads(BaseResource, HTTPResource, BaseModel):
@endpoint(
description=_("Test an openADS 'connexion'")
#~ get={
#~ 'description': _("Test an openADS 'connexion'"),
#~ 'response_body': {
#~ 'schema': {
#~ 'application/json': JSON_SCHEMA_CHECK_STATUS_OUT
#~ }
#~ }
#~ }
# get={
# 'description': _("Test an openADS 'connexion'"),
# 'response_body': {
# 'schema': {
# 'application/json': JSON_SCHEMA_CHECK_STATUS_OUT
# }
# }
# }
)
# pylint: disable=unused-argument,arguments-differ,keyword-arg-before-vararg
def check_status(self, request=None, *args, **kwargs):
@ -520,11 +517,10 @@ class AtrealOpenads(BaseResource, HTTPResource, BaseModel):
response.raise_for_status()
return {'response': response.status_code}
@endpoint(
perm='can_access',
methods=['post'],
pattern='^(?P<type_dossier>\w+)/?$', # pylint: disable=anomalous-backslash-in-string
pattern='^(?P<type_dossier>\w+)/?$', # noqa: W605,E501, pylint: disable=anomalous-backslash-in-string
example_pattern='{type_dossier}/',
parameters={
'type_dossier': {'description': _("Type of 'dossier'"), 'example_value': 'DIA'},
@ -542,11 +538,11 @@ class AtrealOpenads(BaseResource, HTTPResource, BaseModel):
'application/json': JSON_SCHEMA_CREATE_DOSSIER_IN
} # pylint: disable=too-many-statements,too-many-branches,too-many-locals
}
#~ 'response_body': {
#~ 'schema': {
#~ 'application/json': JSON_SCHEMA_CREATE_DOSSIER_OUT
#~ }
#~ }
# 'response_body': {
# 'schema': {
# 'application/json': JSON_SCHEMA_CREATE_DOSSIER_OUT
# }
# }
}
)
# pylint: disable=unused-argument,keyword-arg-before-vararg
@ -599,9 +595,9 @@ class AtrealOpenads(BaseResource, HTTPResource, BaseModel):
payload["terrain"] = {
"numero_voie": normalize(json_data['fields']['terrain_numero_voie']),
"nom_voie" : normalize(json_data['fields']['terrain_nom_voie']),
"nom_voie": normalize(json_data['fields']['terrain_nom_voie']),
"code_postal": normalize(json_data['fields']['terrain_code_postal']),
"localite" : normalize(json_data['fields']['terrain_localite']),
"localite": normalize(json_data['fields']['terrain_localite']),
"references_cadastrales": []
}
if 'terrain_lieu_dit' in json_data['fields'] and json_data['fields']['terrain_lieu_dit']:
@ -611,14 +607,14 @@ class AtrealOpenads(BaseResource, HTTPResource, BaseModel):
payload["terrain"]["references_cadastrales"].append({
"prefixe": normalize(ref[0]),
"section": normalize(ref[1]),
"numero" : normalize(ref[2])
"numero": normalize(ref[2])
})
if json_data['fields']['autres_parcelles']:
for ref in json_data['fields']['references_cadastrales']:
payload["terrain"]["references_cadastrales"].append({
"prefixe": normalize(ref[0]),
"section": normalize(ref[1]),
"numero" : normalize(ref[2])
"numero": normalize(ref[2])
})
# setup demandeur variable prefix
@ -638,14 +634,14 @@ class AtrealOpenads(BaseResource, HTTPResource, BaseModel):
# get the demandeur informations
demandeur = {
"type_personne": type_personne,
"typologie" : 'petitionnaire' if key == 'demandeurs' else 'delegataire',
"nom" : normalize(json_data['fields']['%snom' % prefix]),
"prenom" : normalize(json_data['fields']['%sprenom' % prefix]),
"typologie": 'petitionnaire' if key == 'demandeurs' else 'delegataire',
"nom": normalize(json_data['fields']['%snom' % prefix]),
"prenom": normalize(json_data['fields']['%sprenom' % prefix]),
"adresse": {
"numero_voie": normalize(json_data['fields']['%snumero_voie' % prefix]),
"nom_voie" : normalize(json_data['fields']['%snom_voie' % prefix]),
"nom_voie": normalize(json_data['fields']['%snom_voie' % prefix]),
"code_postal": normalize(json_data['fields']['%scode_postal' % prefix]),
"localite" : normalize(json_data['fields']['%slocalite' % prefix])
"localite": normalize(json_data['fields']['%slocalite' % prefix])
},
"coordonnees": {
"email": normalize(json_data['fields']['%semail' % prefix])
@ -736,11 +732,11 @@ class AtrealOpenads(BaseResource, HTTPResource, BaseModel):
# append the file to the list
files.append({
'type_fichier' : type_fichier,
'type_fichier': type_fichier,
'orig_filename': filename,
'content_type' : content_type,
'file_hash' : file_hash,
'upload_file' : upload_file
'content_type': content_type,
'file_hash': file_hash,
'upload_file': upload_file
})
# log files to be forwarded
@ -843,28 +839,28 @@ class AtrealOpenads(BaseResource, HTTPResource, BaseModel):
# respond with the 'numero_dossier' and the recepisse file
return {
'numero_dossier': numero_dossier,
'recepisse' : recepisse
'recepisse': recepisse
}
@endpoint(
perm='can_access',
description=_("Get informations about an openADS 'dossier'"),
# pylint: disable=anomalous-backslash-in-string
pattern='^(?P<type_dossier>\w+)/(?P<numero_dossier>\w+)/?$',
pattern='^(?P<type_dossier>\w+)/(?P<numero_dossier>\w+)/?$', # noqa: W605
example_pattern='{type_dossier}/{numero_dossier}',
parameters={
'type_dossier' : {'description': _("Type of 'dossier'"), 'example_value': 'DIA'},
'type_dossier': {'description': _("Type of 'dossier'"), 'example_value': 'DIA'},
'numero_dossier': {'description': _("Identifier for 'dossier'"),
'example_value': 'DIA0130551900001'}
},
#~ get={
#~ 'description': _("Get informations about an openADS 'dossier'"),
#~ 'response_body': {
#~ 'schema': {
#~ 'application/json': JSON_SCHEMA_GET_DOSSIER_OUT
#~ }
#~ }
#~ }
# get={
# 'description': _("Get informations about an openADS 'dossier'"),
# 'response_body': {
# 'schema': {
# 'application/json': JSON_SCHEMA_GET_DOSSIER_OUT
# }
# }
# }
)
# pylint: disable=unused-argument,keyword-arg-before-vararg
def get_dossier(self, request, type_dossier, numero_dossier, *args, **kwargs):
@ -896,22 +892,22 @@ class AtrealOpenads(BaseResource, HTTPResource, BaseModel):
@endpoint(
perm='can_access',
description=_("Get informations about the forwarding of user files to openADS"),
pattern='^(?P<numero_dossier>\w+)/?$', # pylint: disable=anomalous-backslash-in-string
pattern='^(?P<numero_dossier>\w+)/?$', # noqa: W605,E501, pylint: disable=anomalous-backslash-in-string
example_pattern='{numero_dossier}/',
parameters={
'numero_dossier': {'description': _("Identifier for 'dossier'"),
'example_value': 'DIA0130551900001'},
'fichier_id' : {'description': _("File identifier"),
'fichier_id': {'description': _("File identifier"),
'example_value': '78'}
},
#~ get={
#~ 'description': _("Get informations about the forwarding of user files to openADS"),
#~ 'response_body': {
#~ 'schema': {
#~ 'application/json': JSON_SCHEMA_GET_FWD_FILES_OUT
#~ }
#~ }
#~ }
# get={
# 'description': _("Get informations about the forwarding of user files to openADS"),
# 'response_body': {
# 'schema': {
# 'application/json': JSON_SCHEMA_GET_FWD_FILES_OUT
# }
# }
# }
)
# pylint: disable=unused-argument,keyword-arg-before-vararg,no-self-use
def get_fwd_files(self, request, numero_dossier, fichier_id=None, *args, **kwargs):
@ -939,18 +935,18 @@ class AtrealOpenads(BaseResource, HTTPResource, BaseModel):
# append each file to the response payload
for fwd_file in fwd_files:
payload.append({
'id' : fwd_file.id,
'id': fwd_file.id,
'numero_demande': fwd_file.numero_demande,
'numero_dossier': fwd_file.numero_dossier,
'type_fichier' : fwd_file.type_fichier,
'file_hash' : fwd_file.file_hash,
'orig_filename' : fwd_file.orig_filename,
'content_type' : fwd_file.content_type,
'upload_status' : fwd_file.upload_status,
'type_fichier': fwd_file.type_fichier,
'file_hash': fwd_file.file_hash,
'orig_filename': fwd_file.orig_filename,
'content_type': fwd_file.content_type,
'upload_status': fwd_file.upload_status,
'upload_attempt': fwd_file.upload_attempt,
'upload_msg' : fwd_file.upload_msg,
'content_size' : fwd_file.upload_file.size if fwd_file.upload_file else 0,
'last_update_datetime' : fwd_file.last_update_datetime
'upload_msg': fwd_file.upload_msg,
'content_size': fwd_file.upload_file.size if fwd_file.upload_file else 0,
'last_update_datetime': fwd_file.last_update_datetime
})
# return the payload containing the list of files
@ -959,22 +955,22 @@ class AtrealOpenads(BaseResource, HTTPResource, BaseModel):
@endpoint(
perm='can_access',
description=_("Get informations about the forwarding of a user file to openADS"),
pattern='^(?P<numero_dossier>\w+)/?$', # pylint: disable=anomalous-backslash-in-string
pattern='^(?P<numero_dossier>\w+)/?$', # noqa: W605,E501, pylint: disable=anomalous-backslash-in-string
example_pattern='{numero_dossier}/',
parameters={
'numero_dossier': {'description': _("Identifier for 'dossier'"),
'example_value': 'DIA0130551900001'},
'fichier_id' : {'description': _("File identifier"),
'fichier_id': {'description': _("File identifier"),
'example_value': '78'}
},
#~ get={
#~ 'description': _("Get informations about the forwarding of a user file to openADS"),
#~ 'response_body': {
#~ 'schema': {
#~ 'application/json': JSON_SCHEMA_GET_FWD_FILES_STATUS_OUT
#~ }
#~ }
#~ }
# get={
# 'description': _("Get informations about the forwarding of a user file to openADS"),
# 'response_body': {
# 'schema': {
# 'application/json': JSON_SCHEMA_GET_FWD_FILES_STATUS_OUT
# }
# }
# }
)
# pylint: disable=unused-argument,keyword-arg-before-vararg
def get_fwd_files_status(self, request, numero_dossier, fichier_id=None, *args, **kwargs):
@ -986,10 +982,10 @@ class AtrealOpenads(BaseResource, HTTPResource, BaseModel):
# prepare the response payload
payload = {
'all_forwarded': True,
'pending' : [],
'uploading' : [],
'success' : [],
'failed' : []
'pending': [],
'uploading': [],
'success': [],
'failed': []
}
# build a summary of all files statuses
@ -1009,24 +1005,23 @@ class AtrealOpenads(BaseResource, HTTPResource, BaseModel):
@endpoint(
perm='can_access',
description=_("Get a 'courrier' from an openADS 'dossier'"),
# pylint: disable=anomalous-backslash-in-string
pattern='^(?P<type_dossier>\w+)/(?P<numero_dossier>\w+)/(?P<lettre_type>\w+)/?$',
pattern='^(?P<type_dossier>\w+)/(?P<numero_dossier>\w+)/(?P<lettre_type>\w+)/?$', # noqa: W605,E501, pylint: disable=anomalous-backslash-in-string
example_pattern='{type_dossier}/{numero_dossier}/{lettre_type}',
parameters={
'type_dossier' : {'description': _("Type of 'dossier'"), 'example_value': 'DIA'},
'type_dossier': {'description': _("Type of 'dossier'"), 'example_value': 'DIA'},
'numero_dossier': {'description': _("Identifier for 'dossier'"),
'example_value': 'DIA0130551900001'},
'lettre_type' : {'description': _("Courrier ID to get"),
'lettre_type': {'description': _("Courrier ID to get"),
'example_value': 'dia_renonciation_preempter'}
},
#~ get={
#~ 'description': _("Get a 'courrier' from an openADS 'dossier'"),
#~ 'response_body': {
#~ 'schema': {
#~ 'application/json': JSON_SCHEMA_GET_COURRIER_OUT
#~ }
#~ }
#~ }
# get={
# 'description': _("Get a 'courrier' from an openADS 'dossier'"),
# 'response_body': {
# 'schema': {
# 'application/json': JSON_SCHEMA_GET_COURRIER_OUT
# }
# }
# }
)
# pylint: disable=unused-argument,keyword-arg-before-vararg
def get_courrier(self, request, type_dossier, numero_dossier, lettre_type, *args, **kwargs):
@ -1099,24 +1094,24 @@ class AtrealOpenads(BaseResource, HTTPResource, BaseModel):
perm='can_access',
description=_("Trigger the uploading of user's files to openADS"),
# pylint: disable=anomalous-backslash-in-string
pattern='^(?P<type_dossier>\w+)/(?P<numero_dossier>\w+)/?$',
pattern='^(?P<type_dossier>\w+)/(?P<numero_dossier>\w+)/?$', # noqa: W605
example_pattern='{type_dossier}/{numero_dossier}',
parameters={
'type_dossier' : {'description': _("Type of 'dossier'"), 'example_value': 'DIA'},
'type_dossier': {'description': _("Type of 'dossier'"), 'example_value': 'DIA'},
'numero_dossier': {'description': _("Identifier for 'dossier'"),
'example_value': 'DIA0130551900001'},
'file_ids' : {'description': _(("List of ForwardFile IDs to upload "
'file_ids': {'description': _(("List of ForwardFile IDs to upload "
"(coma separated)")),
'example_value': '12,18'}
}, # pylint: disable=too-many-statements,too-many-branches,too-many-locals
#~ get={
#~ 'description': _("Trigger the uploading of user's files to openADS"),
#~ 'response_body': {
#~ 'schema': {
#~ 'application/json': JSON_SCHEMA_UPLOAD_USER_FILES
#~ }
#~ }
#~ }
# get={
# 'description': _("Trigger the uploading of user's files to openADS"),
# 'response_body': {
# 'schema': {
# 'application/json': JSON_SCHEMA_UPLOAD_USER_FILES
# }
# }
# }
)
# @raise ForwareFile.DoesNotExist if not found
# pylint: disable=unused-argument,keyword-arg-before-vararg
@ -1176,12 +1171,12 @@ class AtrealOpenads(BaseResource, HTTPResource, BaseModel):
# add the file content and data to the payload
payload.append({
'filename' : '%s%s' % (
'filename': '%s%s' % (
fwd_file.orig_filename,
'.pdf' if fwd_file.orig_filename[-4:] != '.pdf' else ''),
'content_type' : fwd_file.content_type,
'b64_content' : base64.b64encode(fwd_file.upload_file.read()),
'file_type' : fwd_file.type_fichier
'content_type': fwd_file.content_type,
'b64_content': base64.b64encode(fwd_file.upload_file.read()),
'file_type': fwd_file.type_fichier
})
self.logger.debug("upload_user_files() payload added")

View File

@ -76,7 +76,7 @@ for view in [
regex_base = r'^(?P<connecteur>[\w,-]+)/'
# pylint: disable=anomalous-backslash-in-string
regex_pkey = '/(?P<pk>[\w,-]+)'
regex_pkey = '/(?P<pk>[\w,-]+)' # noqa: W605
url_name = url_prefix + view.model.get_class_name_dash_case()
regex_url = '%s%s' % (url_prefix if view_action != 'view' else '',
@ -93,7 +93,7 @@ for view in [
# for 'guichet' prefix the regex by the collectivite
if view.model.get_class_name() == 'Guichet':
regex_base += 'collectivite/(?P<collectivite>[\w,-]+)/'
regex_base += 'collectivite/(?P<collectivite>[\w,-]+)/' # noqa: W605
# build the regex
regex = regex_base + regex_url + regex_pkey + '$'

View File

@ -56,8 +56,10 @@ class MLStripper(HTMLParser):
def __init__(self):
self.reset()
self.fed = []
def handle_data(self, data):
self.fed.append(data)
def get_data(self):
"""Get the stripped data as a string."""
return ''.join(self.fed)
@ -103,9 +105,11 @@ def get_file_digest(content, chunk_size=100000):
"""Return a hash for the content specified."""
digest = hashlib.sha256()
content.seek(0)
def read_chunk():
"""Read 'chunk_size' amount of data from the content."""
return content.read(chunk_size)
for chunk in iter(read_chunk, ''):
digest.update(chunk)
return digest.hexdigest()
@ -145,7 +149,7 @@ def trunc_str_values(value, limit, visited=None, truncate_text=u'…'):
if visited is None:
visited = []
if not value in visited:
if value not in visited:
if isinstance(value, basestring) and len(value) > limit:
value = value[:limit] + truncate_text
elif isinstance(value, (dict, list, tuple)):

View File

@ -161,7 +161,7 @@ class ForwardFileDeleteView(DeleteView):
})
return reverse_lazy('view-connector', kwargs={
'connector': 'atreal-openads',
'slug' : get_connecteur_from_request(self).slug
'slug': get_connecteur_from_request(self).slug
})
@ -176,10 +176,10 @@ class CollectiviteView(DetailView):
context = super(CollectiviteView, self).get_context_data(**kwargs)
context['connecteur'] = get_connecteur_from_request(self)
context['guichet_add_url'] = reverse_lazy('create-guichet', kwargs={
'connecteur' : context['connecteur'].slug,
'connecteur': context['connecteur'].slug,
'collectivite': self.get_object().id})
context['forward_files_list_url'] = reverse_lazy('col-list-forward-files', kwargs={
'connecteur' : context['connecteur'].slug,
'connecteur': context['connecteur'].slug,
'collectivite': self.get_object().id})
return context
@ -236,11 +236,11 @@ class CollectiviteCreateView(CreateView):
def get_success_url(self):
if self.request.GET.get('back-to') == 'list-collectivites':
return reverse_lazy('list-collectivites', kwargs={
'connecteur' : get_connecteur_from_request(self).slug
'connecteur': get_connecteur_from_request(self).slug
})
return reverse_lazy('view-connector', kwargs={
'connector': 'atreal-openads',
'slug' : get_connecteur_from_request(self).slug
'slug': get_connecteur_from_request(self).slug
})
@ -260,7 +260,7 @@ class CollectiviteUpdateView(UpdateView):
def get_success_url(self):
if self.request.GET.get('back-to') == 'list-collectivites':
return reverse_lazy('list-collectivites', kwargs={
'connecteur' : get_connecteur_from_request(self).slug
'connecteur': get_connecteur_from_request(self).slug
})
return self.get_object().get_absolute_url()
@ -281,11 +281,11 @@ class CollectiviteDeleteView(DeleteView):
def get_success_url(self):
if self.request.GET.get('back-to') == 'list-collectivites':
return reverse_lazy('list-collectivites', kwargs={
'connecteur' : get_connecteur_from_request(self).slug
'connecteur': get_connecteur_from_request(self).slug
})
return reverse_lazy('view-connector', kwargs={
'connector': 'atreal-openads',
'slug' : get_connecteur_from_request(self).slug
'slug': get_connecteur_from_request(self).slug
})
@ -325,7 +325,7 @@ class GuichetCreateView(CreateView):
def get_success_url(self):
return reverse_lazy('view-collectivite', kwargs={
'connecteur': get_connecteur_from_request(self).slug,
'pk' : get_collectivite_from_request(self).id
'pk': get_collectivite_from_request(self).id
})
@ -361,7 +361,7 @@ class GuichetDeleteView(DeleteView):
def get_success_url(self):
return reverse_lazy('view-collectivite', kwargs={
'connecteur': get_connecteur_from_request(self).slug,
'pk' : get_collectivite_from_request(self).id
'pk': get_collectivite_from_request(self).id
})

View File

@ -26,7 +26,7 @@ LANGUAGE_CODE = 'en-us'
TIME_ZONE = 'UTC'
# include app
INSTALLED_APPS += ( # pylint: disable=undefined-variable
INSTALLED_APPS += ( # noqa: F821, pylint: disable=undefined-variable
'atreal_openads',
)

View File

@ -38,7 +38,7 @@ from django.http.request import HttpRequest, QueryDict
from django.http.response import JsonResponse
from django.core.files import File
from django.core.files.base import ContentFile
#from django.db.models.query import QuerySet
# from django.db.models.query import QuerySet
from django.core.exceptions import ValidationError
from passerelle.utils.jsonresponse import APIError
@ -86,6 +86,7 @@ def atreal_openads(db):
basic_auth_password=OPENADS_API_PASSWORD
)
@pytest.fixture
# pylint: disable=unused-argument,redefined-outer-name,invalid-name
def collectivite_1(db, atreal_openads):
@ -96,6 +97,7 @@ def collectivite_1(db, atreal_openads):
openADS_id='3'
)
@pytest.fixture
# pylint: disable=unused-argument,redefined-outer-name,invalid-name
def collectivite_1_guichet(db, atreal_openads, collectivite_1):
@ -333,7 +335,7 @@ def test_get_files_from_payload(atreal_openads):
title = 'payload'
assert atreal_openads.get_files_from_payload({'files':[{'a':'file'}]}) == [{'a':'file'}]
assert atreal_openads.get_files_from_payload({'files': [{'a': 'file'}]}) == [{'a': 'file'}]
with pytest.raises(APIError) as exception:
atreal_openads.get_files_from_payload({})
@ -345,7 +347,7 @@ def test_get_files_from_payload(atreal_openads):
'files', title, 'list', type(''))
with pytest.raises(APIError) as exception:
atreal_openads.get_files_from_payload({'files': {'i':'invalid'}})
atreal_openads.get_files_from_payload({'files': {'i': 'invalid'}})
assert unicode(exception.value) == u"Expecting '%s' value in JSON %s to be a %s (not a %s)" % (
'files', title, 'list', type({}))
@ -443,73 +445,73 @@ def test_create_dossier(atreal_openads, collectivite_1, collectivite_1_guichet):
"fields": {
# proprietaire
"proprietaire" : "Non",
"proprietaire": "Non",
"proprietaire_raw": "Non",
# mandataire
"mandataire_prenom" : "John",
"mandataire_nom" : "Man",
"mandataire_email" : "mandataire_email@domain.example",
"mandataire_prenom": "John",
"mandataire_nom": "Man",
"mandataire_email": "mandataire_email@domain.example",
"mandataire_qualite" : "Une personne morale",
"mandataire_qualite_raw" : "Une personne morale",
"mandataire_qualite": "Une personne morale",
"mandataire_qualite_raw": "Une personne morale",
"mandataire_denomination" : "SELARL",
"mandataire_raison_sociale" : "Super Juriste",
"mandataire_denomination": "SELARL",
"mandataire_raison_sociale": "Super Juriste",
"mandataire_numero_voie": "808",
"mandataire_nom_voie" : "Avenue de l'argent",
"mandataire_lieu_dit" : "geoisbour",
"mandataire_nom_voie": "Avenue de l'argent",
"mandataire_lieu_dit": "geoisbour",
"mandataire_code_postal": "13004",
"mandataire_localite" : "Marseille",
"mandataire_localite": "Marseille",
# petitionnaire
"prenom": "Toto",
"nom" : "Loulou",
"email" : "petitionnaire_email@domain.example",
"nom": "Loulou",
"email": "petitionnaire_email@domain.example",
"qualite" : "Un particulier",
"qualite": "Un particulier",
"qualite_raw": "Un particulier",
"numero_voie": "52",
"nom_voie" : "Avenue de la Blaque",
"lieu_dit" : "tierquar",
"nom_voie": "Avenue de la Blaque",
"lieu_dit": "tierquar",
"code_postal": "13004",
"localite" : "Marseille",
"localite": "Marseille",
# terrain
"terrain_numero_voie": "23",
"terrain_nom_voie" : "Boulevard de la République",
"terrain_lieu_dit" : "Leecorne",
"terrain_nom_voie": "Boulevard de la République",
"terrain_lieu_dit": "Leecorne",
"terrain_code_postal": "13002",
"terrain_localite" : "Marseille",
"terrain_localite": "Marseille",
# références cadastrales
"reference_cadastrale" : [["999", "Z", "0010"]],
"autres_parcelles" : True,
"reference_cadastrale": [["999", "Z", "0010"]],
"autres_parcelles": True,
"references_cadastrales": [["123", "D", "9874"]],
# user attached files
"cerfa": {
"content" : get_file_data(TEST_FILE_CERFA_DIA),
"content": get_file_data(TEST_FILE_CERFA_DIA),
"content_type": "invalid/content type",
"field_id" : "50",
"filename" : os.path.basename(TEST_FILE_CERFA_DIA)
"field_id": "50",
"filename": os.path.basename(TEST_FILE_CERFA_DIA)
},
"plan_cadastral_1": {
"content" : get_file_data(TEST_FILE_PLAN_CADASTRAL),
"content": get_file_data(TEST_FILE_PLAN_CADASTRAL),
"content_type": "application/pdf",
"filename" : os.path.basename(TEST_FILE_PLAN_CADASTRAL)
"filename": os.path.basename(TEST_FILE_PLAN_CADASTRAL)
},
"plan_cadastral_2": {
"content" : get_file_data(TEST_FILE_PLAN_CADASTRAL),
"content": get_file_data(TEST_FILE_PLAN_CADASTRAL),
"content_type": "application/pdf",
#"filename" : 'plan_cad'
# "filename": 'plan_cad'
},
"pouvoir_mandat": {
"content" : get_file_data(TEST_FILE_CERFA_DIA),
"content": get_file_data(TEST_FILE_CERFA_DIA),
"content_type": "application/pdf",
"filename" : 'mandat'
"filename": 'mandat'
}
}
}
@ -582,11 +584,11 @@ def test_create_dossier(atreal_openads, collectivite_1, collectivite_1_guichet):
"datetime or string formatted to '%s'" % now_str_fmt))
fake_resp_json = {
'numero_dossier' : FAKE_NUMERO_DOSSIER,
'numero_dossier': FAKE_NUMERO_DOSSIER,
'files': [{
'b64_content' : get_file_data(TEST_FILE_CERFA_DIA),
'content_type' : 'text/plain',
'filename' : 'recepisse_depot_%s.pdf' % FAKE_NUMERO_DOSSIER,
'b64_content': get_file_data(TEST_FILE_CERFA_DIA),
'content_type': 'text/plain',
'filename': 'recepisse_depot_%s.pdf' % FAKE_NUMERO_DOSSIER,
}]
}
fake_resp = Response()
@ -604,7 +606,7 @@ def test_create_dossier(atreal_openads, collectivite_1, collectivite_1_guichet):
assert jresp['recepisse']['content_type'] == 'application/pdf'
assert jresp['recepisse']['filename'] == fake_resp_json['files'][0]['filename']
fake_resp_json['numero_dossier'] = {'a':'invalid type'}
fake_resp_json['numero_dossier'] = {'a': 'invalid type'}
fake_resp._content = json.dumps(fake_resp_json) # pylint: disable=protected-access
with pytest.raises(APIError) as exception:
with mock.patch('passerelle.utils.Request.post') as requests_post:
@ -691,10 +693,10 @@ def test_get_dossier(atreal_openads):
assert unicode(exception.value) == "HTTP error: 502"
fake_resp_json = {
'etat' : u"Non préemption en cours",
'date_depot' : "24/04/2019",
'date_decision' : "",
'decision' : "",
'etat': u"Non préemption en cours",
'date_depot': "24/04/2019",
'date_decision': "",
'decision': "",
'date_limite_instruction': "24/06/2019"
}
fake_resp = Response()
@ -721,10 +723,10 @@ def test_get_dossier(atreal_openads):
assert unicode(exception.value) == u'No JSON content returned: %r' % fake_resp._content
fake_resp_json = {
'errors' : [{
'location' : 'path',
'name' : 'Invalid Type',
'description' : '"invalid_type" is not one of DIA, PC, DP, AT, PD'
'errors': [{
'location': 'path',
'name': 'Invalid Type',
'description': '"invalid_type" is not one of DIA, PC, DP, AT, PD'
}]
}
fake_resp.status_code = 404
@ -846,9 +848,9 @@ def test_get_courrier(atreal_openads):
fake_resp_json = {
'files': [{
'filename' : "instruction_4.pdf",
'content_type' : "text/plain",
'b64_content' : get_file_data(TEST_FILE_CERFA_DIA)
'filename': "instruction_4.pdf",
'content_type': "text/plain",
'b64_content': get_file_data(TEST_FILE_CERFA_DIA)
}]
}
fake_resp = Response()
@ -888,8 +890,8 @@ def test_get_response_error(atreal_openads):
fake_resp_json = {
'errors': [
{
'location' : 'entity.name',
'name' : 'constraint',
'location': 'entity.name',
'name': 'constraint',
'description': 'Must start with an uppercase letter'
}
]
@ -945,10 +947,10 @@ def test_upload_user_files(atreal_openads):
with pytest.raises(TypeError) as exception:
atreal_openads.upload_user_files(req, 'DIA', FAKE_NUMERO_DOSSIER,
file_ids={'invalid':'type'})
file_ids={'invalid': 'type'})
assert unicode(exception.value) == (
u"Invalid 'file_ids' argument type '%s' (must be string or list)" % (
type({'invalid':'type'})))
type({'invalid': 'type'})))
forwardfile = build_forwardfile_from_path(atreal_openads,
TEST_FILE_CERFA_DIA,

View File

@ -70,6 +70,7 @@ def atreal_openads(db):
basic_auth_password=OPENADS_API_PASSWORD
)
@pytest.fixture
# pylint: disable=unused-argument,redefined-outer-name,invalid-name
def collectivite_1(db, atreal_openads):
@ -80,6 +81,7 @@ def collectivite_1(db, atreal_openads):
openADS_id='3'
)
@pytest.fixture
# pylint: disable=unused-argument,redefined-outer-name,invalid-name
def collectivite_1_guichet(db, atreal_openads, collectivite_1):

View File

@ -80,6 +80,7 @@ def atreal_openads(db):
basic_auth_password=OPENADS_API_PASSWORD
)
@pytest.fixture
# pylint: disable=unused-argument,redefined-outer-name,invalid-name
def collectivite_1(db, atreal_openads):
@ -90,6 +91,7 @@ def collectivite_1(db, atreal_openads):
openADS_id='3'
)
@pytest.fixture
# pylint: disable=unused-argument,redefined-outer-name,invalid-name
def collectivite_1_guichet(db, atreal_openads, collectivite_1):
@ -242,17 +244,17 @@ def test_trunc_str_values():
dic = {'a': '123456789', 'b123456789': '987654321'}
assert trunc_str_values(dic, 5) == {'a': u'12345…', 'b123456789': u'98765…'}
dic = {'a': '123456789', 'b123456789': '987654321', 'c': {'c1':'ABCDEFGHIJK'}}
dic = {'a': '123456789', 'b123456789': '987654321', 'c': {'c1': 'ABCDEFGHIJK'}}
assert trunc_str_values(dic, 5) == {'a': u'12345…', 'b123456789': u'98765…',
'c': {'c1': u'ABCDE…'}}
dic = {'a': '123456789', 'b123456789': '987654321', 'c': {'c1':'ABCDEFGHIJK'},
dic = {'a': '123456789', 'b123456789': '987654321', 'c': {'c1': 'ABCDEFGHIJK'},
'd': ['123456789']}
assert trunc_str_values(dic, 5) == {'a': u'12345…', 'b123456789': u'98765…',
'c': {'c1': u'ABCDE…'}, 'd': [u'12345…']}
dic = {'a': '123456789', 'b123456789': '987654321', 'c': {'c1':'ABCDEFGHIJK'},
'd': ['123456789', {'eeeeeeeeee':'132456789'}]}
dic = {'a': '123456789', 'b123456789': '987654321', 'c': {'c1': 'ABCDEFGHIJK'},
'd': ['123456789', {'eeeeeeeeee': '132456789'}]}
assert trunc_str_values(dic, 5) == {'a': u'12345…', 'b123456789': u'98765…',
'c': {'c1': u'ABCDE…'},
'd': [u'12345…', {'eeeeeeeeee': u'13245…'}]}

View File

@ -85,6 +85,7 @@ def atreal_openads(db):
basic_auth_password=OPENADS_API_PASSWORD
)
@pytest.fixture
# pylint: disable=unused-argument,redefined-outer-name,invalid-name
def collectivite_1(db, atreal_openads):
@ -95,6 +96,7 @@ def collectivite_1(db, atreal_openads):
openADS_id='3'
)
@pytest.fixture
# pylint: disable=unused-argument,redefined-outer-name,invalid-name
def collectivite_1_guichet(db, atreal_openads, collectivite_1):
@ -109,6 +111,7 @@ def collectivite_1_guichet(db, atreal_openads, collectivite_1):
fermeture_sem_h=datetime.time(12, 15)
)
@pytest.fixture
# pylint: disable=unused-argument,redefined-outer-name,invalid-name
def forwardfile_1(db, atreal_openads, collectivite_1):
@ -153,7 +156,7 @@ def test_get_connecteur_from_request(atreal_openads, forwardfile_1): # pylint: d
# pylint: disable=unused-argument,redefined-outer-name
def test_get_collectivite_from_request(atreal_openads, collectivite_1): # pylint: disable=invalid-name
def test_get_collectivite_from_request(atreal_openads, collectivite_1): # noqa: E501, pylint: disable=invalid-name
"""Test for function 'get_collectivite_from_request()'."""
req = HttpRequest()