axnsan12 / drf-yasg

Automated generation of real Swagger/OpenAPI 2.0 schemas from Django REST Framework code.
https://drf-yasg.readthedocs.io/en/stable/
Other
3.42k stars 439 forks source link

Tests: Improve test coverage 95.91% -> 98.30%. #862

Closed onegreyonewhite closed 1 year ago

onegreyonewhite commented 1 year ago

Changelog:

onegreyonewhite commented 1 year ago

@JoelLefkowitz As I promised)

Previous coverage:

Name                                                   Stmts   Miss Branch BrPart     Cover   Missing
-----------------------------------------------------------------------------------------------------
src/drf_yasg/__init__.py                                   5      0      0      0   100.00%
src/drf_yasg/app_settings.py                              23      0      4      0   100.00%
src/drf_yasg/codecs.py                                    94      7     20      1    92.98%   18, 22-25, 121->123, 209-210
src/drf_yasg/errors.py                                    10      0      6      0   100.00%
src/drf_yasg/generators.py                               273      8    124     10    95.47%   35-36, 67, 82->90, 218, 227, 241->244, 282, 483->478, 521, 526, 530->532
src/drf_yasg/inspectors/__init__.py                        9      0      0      0   100.00%
src/drf_yasg/inspectors/base.py                          150      0     58      0   100.00%
src/drf_yasg/inspectors/field.py                         370     15    176     14    94.32%   74-75, 191, 269-270, 274, 281-284, 300, 365->363, 499-500, 538->541, 591, 664->676, 666->676, 673->676, 685->690, 820-821
src/drf_yasg/inspectors/query.py                          52     16     20      1    62.50%   18-20, 54-58, 62-65, 73-88, 119->122
src/drf_yasg/inspectors/view.py                          177      1     70      2    98.79%   266, 337->341
src/drf_yasg/management/__init__.py                        0      0      0      0   100.00%
src/drf_yasg/management/commands/__init__.py               0      0      0      0   100.00%
src/drf_yasg/management/commands/generate_swagger.py      73      0     20      0   100.00%
src/drf_yasg/middleware.py                                16      0      2      0   100.00%
src/drf_yasg/openapi.py                                  366      4    108      3    98.10%   142, 277->279, 341, 690-692
src/drf_yasg/renderers.py                                 96      1     32      2    97.66%   98, 99->102
src/drf_yasg/utils.py                                    189      4    110      6    96.66%   332, 335-336, 357->355, 360->355, 432->434, 469
src/drf_yasg/views.py                                     72      1     12      2    96.43%   71->73, 75
-----------------------------------------------------------------------------------------------------
TOTAL                                                   1975     57    762     41    95.91%

Current local:

Name                                                   Stmts   Miss Branch BrPart     Cover   Missing
-----------------------------------------------------------------------------------------------------
src/drf_yasg/__init__.py                                   5      0      0      0   100.00%
src/drf_yasg/app_settings.py                              23      0      4      0   100.00%
src/drf_yasg/codecs.py                                    90      0     20      0   100.00%
src/drf_yasg/errors.py                                    10      0      6      0   100.00%
src/drf_yasg/generators.py                               273      0    124      2    99.50%   82->90, 530->532
src/drf_yasg/inspectors/__init__.py                        9      0      0      0   100.00%
src/drf_yasg/inspectors/base.py                          150      0     58      0   100.00%
src/drf_yasg/inspectors/field.py                         378      6    178      9    97.30%   307, 372->370, 506-507, 545->548, 598, 673->683, 680->683, 692->697, 827-828
src/drf_yasg/inspectors/query.py                          62      1     32      1    97.87%   19, 54->57
src/drf_yasg/inspectors/view.py                          177      1     70      2    98.79%   266, 337->341
src/drf_yasg/management/__init__.py                        0      0      0      0   100.00%
src/drf_yasg/management/commands/__init__.py               0      0      0      0   100.00%
src/drf_yasg/management/commands/generate_swagger.py      73      0     20      0   100.00%
src/drf_yasg/middleware.py                                16      0      2      0   100.00%
src/drf_yasg/openapi.py                                  366      4    108      3    98.10%   142, 277->279, 341, 690-692
src/drf_yasg/renderers.py                                 96      1     32      2    97.66%   98, 99->102
src/drf_yasg/utils.py                                    189      4    110      6    96.66%   332, 335-336, 357->355, 360->355, 432->434, 469
src/drf_yasg/views.py                                     72      1     12      2    96.43%   71->73, 75
-----------------------------------------------------------------------------------------------------
TOTAL                                                   1989     18    776     27    98.30%

This cover all critical parts of code.

I have never been able to come up with tests for some of the uncovered branches. But they don't seem to affect anything.

JoelLefkowitz commented 1 year ago

Thanks @onegreyonewhite this is great