ezbz / gitlabber

Gitlabber - clones or pulls entire groups tree from gitlab
MIT License
467 stars 78 forks source link

`test_help` fails for `optional arguments` #118

Closed hashworks closed 1 week ago

hashworks commented 8 months ago

Describe the bug Running python -m pytest fails for test_help.

To Reproduce python -m pytest

============================= test session starts ==============================
platform linux -- Python 3.11.5, pytest-7.4.3, pluggy-1.3.0 -- /usr/bin/python
cachedir: .pytest_cache
rootdir: /build/python-gitlabber/src/python-gitlabber
configfile: setup.cfg
plugins: timeout-2.2.0, cov-4.1.0, integration-0.2.3
collecting ... collected 56 items

tests/test_archive.py::test_archive_parse PASSED                         [  1%]
tests/test_archive.py::test_archive_string PASSED                        [  3%]
tests/test_archive.py::test_repr PASSED                                  [  5%]
tests/test_archive.py::test_archive_api_value PASSED                     [  7%]
tests/test_archive.py::test_archive_invalid PASSED                       [  8%]
tests/test_cli.py::test_args_version PASSED                              [ 10%]
tests/test_cli.py::test_args_logging PASSED                              [ 12%]
tests/test_cli.py::test_args_include PASSED                              [ 14%]
tests/test_cli.py::test_validate_path PASSED                             [ 16%]
tests/test_cli.py::test__missing_token PASSED                            [ 17%]
tests/test_cli.py::test_missing_url PASSED                               [ 19%]
tests/test_cli.py::test_empty_tree PASSED                                [ 21%]
tests/test_cli.py::test_missing_dest PASSED                              [ 23%]
tests/test_format.py::test_format_parse PASSED                           [ 25%]
tests/test_format.py::test_format_string PASSED                          [ 26%]
tests/test_format.py::test_repr PASSED                                   [ 28%]
tests/test_format.py::test_format_invalid PASSED                         [ 30%]
tests/test_git.py::test_create_new_user_dir PASSED                       [ 32%]
tests/test_git.py::test_is_git_repo_true PASSED                          [ 33%]
tests/test_git.py::test_is_git_repo_throws PASSED                        [ 35%]
tests/test_git.py::test_pull_repo PASSED                                 [ 37%]
tests/test_git.py::test_clone_repo PASSED                                [ 39%]
tests/test_git.py::test_clone_repo_recursive PASSED                      [ 41%]
tests/test_git.py::test_pull_repo_recursive PASSED                       [ 42%]
tests/test_git.py::test_pull_repo_interrupt PASSED                       [ 44%]
tests/test_git.py::test_clone_repo_interrupt PASSED                      [ 46%]
tests/test_gitlab_tree.py::test_load_tree PASSED                         [ 48%]
tests/test_gitlab_tree.py::test_filter_tree_include_positive PASSED      [ 50%]
tests/test_gitlab_tree.py::test_filter_tree_include_negative PASSED      [ 51%]
tests/test_gitlab_tree.py::test_filter_tree_include_deep_positive PASSED [ 53%]
tests/test_gitlab_tree.py::test_filter_tree_exclude_positive PASSED      [ 55%]
tests/test_gitlab_tree.py::test_filter_tree_exclude_deep_positive PASSED [ 57%]
tests/test_gitlab_tree.py::test_filter_tree_exclude_negative PASSED      [ 58%]
tests/test_gitlab_tree.py::test_print_tree_json PASSED                   [ 60%]
tests/test_gitlab_tree.py::test_print_tree_yaml PASSED                   [ 62%]
tests/test_gitlab_tree.py::test_load_tree_from_file PASSED               [ 64%]
tests/test_gitlab_tree.py::test_empty_tree PASSED                        [ 66%]
tests/test_gitlab_tree.py::test_archive_included PASSED                  [ 67%]
tests/test_gitlab_tree.py::test_archive_excluded PASSED                  [ 69%]
tests/test_gitlab_tree.py::test_archive_only PASSED                      [ 71%]
tests/test_gitlab_tree.py::test_get_ca_path PASSED                       [ 73%]
tests/test_method.py::test_method_parse PASSED                           [ 75%]
tests/test_method.py::test_method_string PASSED                          [ 76%]
tests/test_method.py::test_repr PASSED                                   [ 78%]
tests/test_method.py::test_method_invalid PASSED                         [ 80%]
tests/test_naming.py::test_naming_parse PASSED                           [ 82%]
tests/test_naming.py::test_naming_string PASSED                          [ 83%]
tests/test_naming.py::test_repr PASSED                                   [ 85%]
tests/test_naming.py::test_naming_invalid PASSED                         [ 87%]
tests/test_integration.py::test_help FAILED                              [ 89%]
tests/test_integration.py::test_version PASSED                           [ 91%]
tests/test_integration.py::test_file_input PASSED                        [ 92%]
tests/test_e2e.py::test_clone_subgroup SKIPPED (Slow integration tests
skipped)                                                                 [ 94%]
tests/test_e2e.py::test_clone_subgroup_exclude_archived SKIPPED (Slow
integration tests skipped)                                               [ 96%]
tests/test_e2e.py::test_clone_subgroup_only_archived SKIPPED (Slow
integration tests skipped)                                               [ 98%]
tests/test_e2e.py::test_clone_subgroup_naming_path SKIPPED (Slow
integration tests skipped)                                               [100%]

=================================== FAILURES ===================================
__________________________________ test_help ___________________________________

    @pytest.mark.integration_test
    def test_help():
        output = io_util.execute(["-h"])
        assert "usage:" in output
        assert "examples:" in output
        assert "positional arguments:" in output
>       assert "optional arguments:" in output
E       assert 'optional arguments:' in 'usage: gitlabber [-h] [-t token] [-u url] [--verbose] [-p]\n                 [--print-format {json,yaml,tree}] [-n {name,path}]\n                 [-m {ssh,http}] [-a {include,exclude,only}] [-i csv] [-x csv]\n                 [-r] [--version]\n                 [dest]\n\nGitlabber - clones or pulls entire groups/projects tree from gitlab\n\npositional arguments:\n  dest                  destination path for the cloned tree (created if doesn\'t exist)\n\noptions:\n  -h, --help            show this help message and exit\n  -t token, --token token\n                        gitlab personal access token https://docs.gitlab.com/ee/user/profile/personal_access_tokens.html\n  -u url, --url url     base gitlab url (e.g.: \'http://gitlab.mycompany.com\')\n  --verbose             print more verbose output\n  -p, --print           print the tree without cloning\n  --print-format {json,yaml,tree}\n                        print format (default: \'tree\')\n  -n {name,path}, --naming {name,path}\n                        the folder naming strategy for projects from the gitlab API attributes (default: "name")\n  -m {ssh,http}, --method {ssh,http}\n                        the git transport method to use for cloning (default: "ssh")\n  -a {include,exclude,only}, --archived {include,exclude,only}\n                        include archived projects and groups in the results (default: "include")\n  -i csv, --include csv\n                        comma delimited list of glob patterns of paths to projects or groups to clone/pull\n  -x csv, --exclude csv\n                        comma delimited list of glob patterns of paths to projects or groups to exclude from clone/pull\n  -r, --recursive       clone/pull git submodules recursively\n  --version             print the version\n\nexamples:\n\n    clone an entire gitlab tree using a url and a token:\n    gitlabber -t <personal access token> -u <gitlab url>\n\n    only print the gitlab tree:\n    gitlabber -p .\n\n    clone only projects under subgroup \'MySubGroup\' to location \'~/GitlabRoot\':\n    gitlabber -i \'/MyGroup/MySubGroup**\' ~/GitlabRoot\n\n    clone only projects under group \'MyGroup\' excluding any projects under subgroup \'MySubGroup\':\n    gitlabber -i \'/MyGroup**\' -x \'/MyGroup/MySubGroup**\' .\n\n    clone an entire gitlab tree except projects under groups named \'ArchiveGroup\':\n    gitlabber -x \'/ArchiveGroup**\' .\n\n    clone projects that start with a case insensitive \'w\' using a regular expression:\n    gitlabber -i \'/{[w].*}\' .\n    \n'

tests/test_integration.py:16: AssertionError
=========================== short test summary info ============================
FAILED tests/test_integration.py::test_help - assert 'optional arguments:' in...
=================== 1 failed, 51 passed, 4 skipped in 1.02s ====================

Expected behavior No tests fail.

Versions (please complete the following information):

Additional context Using sed -i '/optional arguments/d' tests/test_integration.py as a workaround.