Commit Graph

21 Commits

Author SHA1 Message Date
Emmanuel Cazenave 351a1a6242 adapt tests to python3 (#39533) 2020-02-04 17:28:28 +01:00
Michael Bideau 498a36bba3 Tests: fixed failing 'test_get_courrier_type' because of previous commit 2019-10-29 18:00:58 +01:00
Michael Bideau 6809c75d33 Make the connector more generic; Fixed urls and some pylint issues
Features
    * Added 'get_courrier_type' endpoint that return a 'courrier type' for a given type_dossier
    * Added url parameter 'type_dossier_detaille' to 'create_dossier' to post it in the request body
    * Replaced the way 'type fichier' is defined: now looks into 'XXX_type_raw' for file 'XXX'

Fixes
    * Url components are now encoded
    * Pylint warnings
    * Loging do not raise an error when 'files' var is empty in 'create_dossier'

Tests
    * Added 2 new errors tests to 'test_create_dossier'
    * Added 'test_get_courrier_type' to test endpoint 'get_courrier_type'
    * Fixed pylint warnings
2019-10-24 17:24:55 +02:00
Michael Bideau 31ee9a8ea6 Tests: Refactoring: moving fixtures to conftest.py, added some fixture for ForwardFile and HttpRequest 2019-08-26 14:32:32 +00:00
Michael Bideau a951f062f0 Refactoring: fix most of the (many) 'flake8' complaints 2019-08-22 16:02:06 +00:00
Michael Bideau 9df996e5ad Refactoring: fix all of the 'pylint' complaints for tests files (conftests, settings) 2019-08-22 15:13:27 +00:00
Michael Bideau 05280c153e License: prepended license text to all tests files 2019-08-22 14:51:04 +00:00
Michael Bideau afcca49f53 Refactoring: fix most of the (many many) 'pylint' complaints 2019-08-22 14:44:52 +00:00
Michael Bideau c7e882c1e3 Resources: removed 'trac.ico' file (should not have been commited) 2019-08-21 14:51:04 +00:00
Michael Bideau 910fc8ad57 Tests: set 'now' to a time when 'guichet' is open in 'test_openads_create_dossier' (to prevent failure when running test when 'guichet' is closed) 2019-08-21 08:54:50 +00:00
Michael Bideau 990f1fb7bc Added 'guichet' (planned availability), added CRUD views for each entity, many fixes and refactoring
Features:
    * A connector now can be associated with 'collectivites',
      and each of them can have one 'guichet'.
      A 'collectivite' have a name and an openADS technical identifier
      A 'guichet' allow to define hours and days for when its 'collectivite' is "open"
    * Each of those entities have a view to CRUD it

    * For entity ForwardFile:
       - Added association with a connector, and eventually a 'collectivite'
       - Added ForwardFiles 'size' field
       - Added updating fields 'content_type', 'file_hash' and 'size' on save()
       - Added custom validation on save()

    * For entity AtrealOpenads:
       - Added permissions on each endpoint
       - Added 'email' field support for each type of 'demandeur'
       - 'numero_dossier' is now required in the url for some endpoints (previously was a GET param)
       - Added 'upload_user_files' as an endpoint (but can still be used as a method with request=None)
       - The 'upload_user_files()' method now only handle forward file that have status='pending'

Fixes:
    * Added "*args" and "**kwargs" arguments to some connector endpoint methods
    * Added 'verbose_name' and 'ordering' on each entity META
    * Added decorator '@force_encoded_string_output' to prevent utf-8 issues with python2
    * Added __repr__, __str__ and __unicode__ functions to each entities
    * Added database indexes for each entity
    * Commented out useless JSON schema imports
    * Removed unused variable assignations

Refactoring:
    * Moved utilities functions to utils.py file
    * Added a BaseModel to provide some default functions for Models
    * Added enum/translations of hard-coded values for ForwardFile 'upload_status' field

Tests:
    * Added test for each entity
    * Added tests files specific to utilities, forms and views
    * Total code coverage is 99% with only 10 statement missed
2019-08-20 17:00:12 +00:00
Michael Bideau 4fc61d5f5e Added 'lettre_type' param to 'get_courrier()' endpoint 2019-07-29 14:35:56 +02:00
Michael Bideau d4080dae85 Added 'collectivite' param to 'create_dossier()' endpoint, removed useless '*args' and '**kwargs' 2019-07-29 14:30:50 +02:00
Michael Bideau 98cd089254 100% test coverage, dict strings are truncated when dumped, error messages homogeneized, and more
Features:
    * replaced the loging of json payload with the use of a DictDumper that lazy truncate strings too long
    * homogenize error messages

Fixes:
    * changed the signature of 'check_file_dict()' to match other functions and fix a bug
    * changed the signature of 'upload2ForwardFile()' to force input for 'type_fichier' argument

Refactoring:
    * removed dead code in 'upload_user_files()'
    * using 'basestring' instead of testing for 'str' and 'unicode'
    * renamed 'requerant' by 'demandeur'
    * removed useless and maybe problematic 'join()' (forgotten from the previous commit)
    * added more comments

Tests:
    * 100% test coverage!
    * fixed failing tests
    * added tests for every function
    * completed missing tests (mostly for exceptions)
    * added more comments
    * added the lines of missing statement in the coverage report
2019-07-25 14:29:06 +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 2646ab4ee7 add tests system, via tox 2019-07-15 18:06: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 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