elixir-cloud-aai / proTES

Proxy service for injecting middleware into GA4GH TES requests
Apache License 2.0
5 stars 6 forks source link

test: add unit tests & run integration tests in CI #76

Closed Ayush5120 closed 2 years ago

Ayush5120 commented 2 years ago

Description

Note

Executing the unit tests raises the following error:

  ============================================= test session starts ==============================================
platform linux -- Python 3.8.10, pytest-7.1.2, pluggy-1.0.0
rootdir: /home/ayush/GsoC/proTES
collected 0 items / 1 error                                                                                    

==================================================== ERRORS ====================================================
_____________________ ERROR collecting tests/unitTest/pro_tes/endpoints/test_endpoints.py ______________________
env/lib/python3.8/site-packages/foca/config/config_parser.py:99: in parse_yaml
    with open(conf) as config_file:
E   FileNotFoundError: [Errno 2] No such file or directory: '/home/ayush/GsoC/proTES/api/9e9c5aa.task_execution_service.openapi.yaml'

The above exception was the direct cause of the following exception:
tests/unitTest/pro_tes/endpoints/test_endpoints.py:8: in <module>
    from pro_tes.ga4gh.tes.server import (
pro_tes/ga4gh/tes/server.py:11: in <module>
    from pro_tes.ga4gh.tes.task_runs import TaskRuns
pro_tes/ga4gh/tes/task_runs.py:32: in <module>
    from pro_tes.tasks.tasks.track_task_progress import task__track_task_progress
pro_tes/tasks/tasks/track_task_progress.py:18: in <module>
    from pro_tes.celery_worker import celery
pro_tes/celery_worker.py:8: in <module>
    flask_app = init_app().app
pro_tes/app.py:10: in init_app
    app = foca.create_app()
env/lib/python3.8/site-packages/foca/foca.py:103: in create_app
    cnx_app = register_openapi(
env/lib/python3.8/site-packages/foca/api/register_openapi.py:40: in register_openapi
    spec_parsed = ConfigParser.merge_yaml(*spec.path)
env/lib/python3.8/site-packages/foca/config/config_parser.py:130: in merge_yaml
    yaml_dict = Addict(ConfigParser.parse_yaml(args_list.pop(0)))
env/lib/python3.8/site-packages/foca/config/config_parser.py:107: in parse_yaml
    raise OSError(
E   OSError: file '/home/ayush/GsoC/proTES/api/9e9c5aa.task_execution_service.openapi.yaml' could not be read
----------------------------------------------- Captured stderr ------------------------------------------------
[2022-09-01 22:59:53,054: INFO    ] Log formatting configured. [foca.foca]
[2022-09-01 22:59:53,054: INFO    ] Configuration file '/home/ayush/GsoC/proTES/pro_tes/config.yaml' parsed. [foca.foca]
[2022-09-01 22:59:53,218: INFO    ] Connexion app created. [foca.foca]
[2022-09-01 22:59:53,218: INFO    ] Error handler registered. [foca.foca]
[2022-09-01 22:59:53,218: INFO    ] CORS enabled. [foca.foca]
=============================================== warnings summary ===============================================
env/lib/python3.8/site-packages/openapi_spec_validator/factories.py:10
  /home/ayush/GsoC/proTES/env/lib/python3.8/site-packages/openapi_spec_validator/factories.py:10: DeprecationWarning: Subclassing validator classes is not intended to be part of their public API. A future version will make doing so an error, as the behavior of subclasses isn't guaranteed to stay the same between releases of jsonschema. Instead, prefer composition of validators, wrapping them in an object owned entirely by the downstream library.
    class Draft4ExtendedValidatorFactory(Draft4Validator):

env/lib/python3.8/site-packages/openapi_schema_validator/validators.py:59
  /home/ayush/GsoC/proTES/env/lib/python3.8/site-packages/openapi_schema_validator/validators.py:59: DeprecationWarning: Subclassing validator classes is not intended to be part of their public API. A future version will make doing so an error, as the behavior of subclasses isn't guaranteed to stay the same between releases of jsonschema. Instead, prefer composition of validators, wrapping them in an object owned entirely by the downstream library.
    class OAS30Validator(BaseOAS30Validator):

-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
=========================================== short test summary info ============================================
ERROR tests/unitTest/pro_tes/endpoints/test_endpoints.py - OSError: file '/home/ayush/GsoC/proTES/api/9e9c5aa...
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
========================================= 2 warnings, 1 error in 1.42s =========================================

The issue originates from track_task_run_progress(). As this is critical functionality, it will be important to resolve that issue.

When commenting out the offending code, current unit test coverage is:

Name                                                 Stmts   Miss  Cover   Missing
----------------------------------------------------------------------------------
pro_tes/__init__.py                                      1      0   100%
pro_tes/exceptions.py                                    9      0   100%
pro_tes/ga4gh/__init__.py                                0      0   100%
pro_tes/ga4gh/tes/__init__.py                            0      0   100%
pro_tes/ga4gh/tes/models.py                            117      0   100%
pro_tes/ga4gh/tes/server.py                             35      0   100%
pro_tes/ga4gh/tes/service_info.py                       21      1    95%   57
pro_tes/ga4gh/tes/states.py                              7      0   100%
pro_tes/ga4gh/tes/task_runs.py                         168     31    82%   143-145, 183, 190, 199, 203, 238, 328, 336, 344-345, 396-397, 413-417, 460-461, 484, 488, 492, 501-514
pro_tes/middleware/__init__.py                           0      0   100%
pro_tes/middleware/middleware.py                        15      2    87%   14, 31
pro_tes/task_distribution/__init__.py                    0      0   100%
pro_tes/task_distribution/task_distribution.py          18      1    94%   36
pro_tes/utils/__init__.py                                0      0   100%
pro_tes/utils/db_utils.py                               37     16    57%   53-64, 78-89, 117-119
tests/__init__.py                                        0      0   100%
tests/unitTest/__init__.py                               0      0   100%
tests/unitTest/mock_data.py                             26      0   100%
tests/unitTest/pro_tes/__init__.py                       0      0   100%
tests/unitTest/pro_tes/endpoints/__init__.py             0      0   100%
tests/unitTest/pro_tes/endpoints/test_endpoints.py     101      0   100%
----------------------------------------------------------------------------------
TOTAL                                                  555     51    91%
codecov[bot] commented 2 years ago

Codecov Report

:exclamation: No coverage uploaded for pull request base (dev@6333ee7). Click here to learn what that means. The diff coverage is n/a.

:exclamation: Current head 288cca9 differs from pull request most recent head c389ba2. Consider uploading reports for the commit c389ba2 to get more accurate results

@@          Coverage Diff           @@
##             dev      #76   +/-   ##
======================================
  Coverage       ?   96.55%           
======================================
  Files          ?        1           
  Lines          ?       87           
  Branches       ?        0           
======================================
  Hits           ?       84           
  Misses         ?        3           
  Partials       ?        0           
Flag Coverage Δ
Integration_Tests 96.55% <0.00%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.