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 assert "Gitlabber - clones or pulls entire groups/projects tree from gitlab" in output
def test_clone_subgroup_only_archived(): os.environ['GITLAB_URL'] = 'http://www.gitlab.com/' output = io_util.execute(['-p', '--print-format', 'json', '-a', 'only'], 60) obj = json.loads(output) assert obj['children'][0]['name'] == 'Group Test' assert obj['children'][0]['children'][0]['name'] == 'Subgroup Test' assert len(obj['children'][0]['children'][0]['children']) == 1 assert obj['children'][0]['children'][0]['children'][0][ 'name'] == 'archived-project'
def test_clone_subgroup_exclude_archived(): os.environ['GITLAB_URL'] = 'http://www.gitlab.com/' output = io_util.execute(['-p', '--print-format', 'json', '-a', 'exclude'], 60) obj = json.loads(output) assert obj['children'][0]['name'] == 'Group Test' assert obj['children'][0]['children'][0]['name'] == 'Subgroup Test' assert len(obj['children'][0]['children'][0]['children']) == 2 assert obj['children'][0]['children'][0]['children'][0][ 'name'] == 'gitlab-project-submodule' assert obj['children'][0]['children'][0]['children'][1][ 'name'] == 'gitlabber-sample-submodule'
def test_clone_subgroup_naming_path(): os.environ['GITLAB_URL'] = 'http://www.gitlab.com/' output = io_util.execute(['-p', '--print-format', 'json', '-n', 'path'], 60) obj = json.loads(output) assert obj['children'][0]['name'] == 'erez-group-test' assert obj['children'][0]['children'][0]['name'] == 'subgroup-test' assert len(obj['children'][0]['children'][0]['children']) == 3 assert obj['children'][0]['children'][0]['children'][0][ 'name'] == 'archived-project' assert obj['children'][0]['children'][0]['children'][1][ 'name'] == 'gitlab-project-submodule' assert obj['children'][0]['children'][0]['children'][2][ 'name'] == 'gitlabber-sample-submodule'
def test_file_input(): os.environ['GITLAB_URL'] = 'http://gitlab.my.com/' output = io_util.execute(["-f", gitlab_util.YAML_TEST_INPUT_FILE, "-p", '-t', 'xxx']) with open(gitlab_util.TREE_TEST_OUTPUT_FILE, 'r') as treeFile: assert treeFile.read().strip() == output.strip()
def test_version(): output = io_util.execute(["--version"]) assert VERSION in output