Commit Graph

73 Commits

Author SHA1 Message Date
Thomas NOËL 8231e1465b debian: add settings.d default values 2019-07-22 13:16:31 +02:00
Michael Bideau 62dae769d6 Refactoring: remove 'extra_debug' field and replaced all 'self.debug' calls by 'self.logger.debug' 2019-07-18 22:54:50 +02:00
Michael Bideau 02f4a071fc Use HTTPResource, JSON schema for inputs, JSON lazy logging, added ForwardFile.attempt, and more
Features:
    * class AtrealOpenads now extends HTTPResource for HTTP Basic credentials
    * check_status is now also an endpoint (endpoint 'test_openads_connexion' deleted)
    * added JSON schema to validate POST request input (ouput schemas are defined too but unused for now)
    * added class 'LogJsonPayloadWithFileContent' to lazy log a json payload with content file filtered
    * added 'attempt' field to class 'ForwardFile' that count the attempt of uploading to openADS.API
    * added more controls over response data received

Refactoring:
    * removed the file content in function 'get_fwd_files_status()' and added content size instead
    * splitted the function 'get_fwd_files_status()' in two: one that retrieve detailed files, one only the summary
    * added function 'log_json_payload()' to help to log json payloads
    * added 2 functions to factorize the process of getting files from json payload
    * added function 'check_file_dict()' to factorize the process of checking a file dictionary

Fixes:
    * Default filename are now under 50 chars
    * Make the function 'get_fwd_files_status()' consistent in its return

Tests:
    * updated the test to reflect the use of HTTPResource and the split of 'get_fwd_files_status()'

More:
    * Added a lot of comments
    * Added endpoint anotation to validate response body, but its commented as the 'get' helper is not defined (not like the 'post' one)
2019-07-18 21:47:38 +02:00
Michael Bideau 85e815f72b Rebase from 'remote/origin' 2019-07-16 11:41:02 +02:00
Michael Bideau 8593779954 Added testing with tox, added AGPLv3 license, replaced namespace, and more
Packaging:
    * added author, description, classifiers, scripts and requirements in 'setup.py'

Tests:
    * added support for 'tox.ini'
    * moved 'tests' directory outside main python module

Fixes:
    * namespace is 'atreal_openads' instead of 'passerelle.apps.atreal_openads'
    * increased timeout removed from 'get' requests
    * fixed timeout typo on 'self.openADS_API_timeout'
2019-07-16 11:27:19 +02:00
Thomas NOËL 3a2d9eee6a .gitignore: exclude coverage and tests results 2019-07-15 18:41:01 +02:00
Thomas NOËL 5b2fa9d6d0 ensure tox.ini compatibility with Jenkinsfile 2019-07-15 18:23:40 +02:00
Thomas NOËL 2646ab4ee7 add tests system, via tox 2019-07-15 18:06:38 +02:00
Thomas NOËL 7897daaf49 add Jenkinsfile 2019-07-15 16:49:19 +02:00
Michael Bideau 18e57caf99 Features: added a 1h timeout to every requests 2019-07-15 13:14:38 +02:00
Michael Bideau ee0173698e Added 'test_openads_connexion' endpoint and README completed 2019-07-11 18:57:07 +02:00
Michael Bideau 522634d564 Added 'extra_debug' field and a function to only log debug message if extra_debug is enabled 2019-07-11 18:22:47 +02:00
Michael Bideau 7020d3c2d0 Cleanup: removed useless endpoints and test cases 2019-07-11 17:41:38 +02:00
Michael Bideau 6fe6307506 Tests: removed useless files added by mistake and old 'tests' directory 2019-07-11 17:18:08 +02:00
Michael Bideau 1ac8c2f14e Making tests independant of 'passerelle' and 'vagrant', added HTTP Basic credentials
Tests:
    * moved 'tests' folder inside 'atreal_openads' module
    * removed useless settings.py file
    * removed useless imports
    * added test file 'resources'
    * fixed file path (no more vagrant)
    * updated the test case of 'upload2ForwardFile' to test for 'plan' type_fichier
    * added HTTP Basic credentials to 'atreal_openads' fixture (removed 'token')

Fixes:
    * stop guessing ForwardFile.type_fichier based on file path
2019-07-11 17:07:41 +02:00
Michael Bideau 88fa11457c Added minimum required files for packaging 2019-07-10 18:30:18 +02:00
Michael Bideau f47be6b7c8 Merge branch 'master' of ssh://git.entrouvert.org/passerelle-atreal-openads 2019-07-10 18:27:22 +02:00
Michael Bideau ce44b0a733 Added HTTP Basic authentication, ForwardFiles content deleted on success, plus logging and cleaning
Features:
    * added HTTP Basic authentication (+ login/password fields, - token field)
    * ForwardFiles content deleted on upload success (object/status kept)

Logging:
    * added debuging and warning messages
    * replaced the python interpolation '%' by function args ','

Cleaning:
    * removed functions 'ajob', 'afile'
    * removed unused imports

Fixes:
    * function 'get_upload_path()' returns unique names
    * added missing imports
    * using string in dictionary keys
2019-07-10 18:23:31 +02:00
Michael Bideau 58608886aa Added HTTP Basic authentication, more logging, cleaning, some small fix
Feature:
    * added two new connector fields to store HTTP Basic credentials
    * removed one connector field that stored the HTTP auth token

Logging:
    * added debuging and warning messages
    * replaced the python interpolation '%' by function args ','

Cleaning:
    * removed functions 'ajob', 'afile'
    * removed unused imports

Fixes:
    * added missing imports
    * using string in dictionary keys
2019-07-10 17:56:20 +02:00
Michael Bideau 3c53170e4a Supporting to create a 'dossier' from a real request (no more hardcoded payload)
Features:
    * added support for a payload build from the request instead of hardcoded in
      function 'create_dossier()'
    * added a warning message when an APIError is raised all functions
    * added the name/key of the error in the error message build from a response
    * added a function 'normalize()' to normalize user's input in the payload
    * changed endpoint arguments coming from request parameters instead of URI path
      in functions 'create_dossier()', 'get_dossier()', 'get_courrier()' and
      'get_fwd_files_status()'
    * changed JSON response to use an explicit key to hold file data in function
      'create_dossier()':'recepisse' and 'get_courrier()':'courrier'
    * removed the useless key 'data' in all the JSON response
    * removed useless case 'jsondata' in function 'afile()'

Cleaning:
    * Removed useless variable 'dossier_payload'

Tests:
    * added request containing the payload in the test case for 'create_dossier()'
    * added the name/key of the error in the error message build from a response
    * used the explicit keys 'recepisse' and 'courrier' in JSON responses
    * removed the 'data' key from JSON responses
2019-05-07 16:46:02 +00:00
Michael Bideau a53e30ca9e Initial import of the tests files 2019-05-06 15:34:55 +00:00
Michael Bideau 01660430af Features
* function 'echofile()' support for posted file content, not just url

Bug fix
    * corrected file content in function 'afile()'
    * corrected payload assignment in function 'get_fwd_files_status()'
    * added 'type_dossier' to job creation in function 'create_dossier()'

Coding style: better indentation
Logging     : 'debug' instead of 'info'
Locale      : identifier in english instead of french
2019-05-06 15:27:25 +00:00
Michael Bideau 0d4b51e9ba Initial import of source code (new models: AtrealOpenads, ForwardFile) 2019-04-30 12:21:06 +00:00