Coverage for create_gitlab_projects.py: 78%

23 statements  

« prev     ^ index     » next       coverage.py v7.6.4, created at 2024-11-04 21:22 +0000

1"""Create GitLab repositories from folder.""" 

2 

3import sys 

4from argparse import Namespace 

5 

6from sel_tools.config import REPO_DIR 

7from sel_tools.file_export.solutions_check import check_code_for_solutions_code 

8from sel_tools.gitlab_api.create_repo import ( 

9 create_repos, 

10 store_student_repo_info_to_config_file, 

11) 

12from sel_tools.utils.args import ArgumentParserFactory 

13 

14 

15def parse_arguments(arguments: list[str]) -> Namespace: 

16 """Parse CLI arguments.""" 

17 factory = ArgumentParserFactory.default_parser(__doc__) 

18 factory.add_repo_base_name() 

19 factory.add_group_id() 

20 factory.add_repo_info_dir() 

21 factory.add_source_folder(REPO_DIR / "export" / "homework") 

22 factory.add_number_of_repos() 

23 factory.add_gitlab_token() 

24 factory.add_publish_solutions() 

25 

26 return factory.parser.parse_args(arguments[1:]) 

27 

28 

29def main() -> None: 

30 """main.""" 

31 arguments = parse_arguments(sys.argv) 

32 check_code_for_solutions_code(arguments.source_path, arguments.publish_solutions) 

33 student_repos, group_name = create_repos( 

34 arguments.source_path, 

35 arguments.repo_base_name, 

36 arguments.group_id, 

37 arguments.number_of_repos, 

38 arguments.gitlab_token, 

39 ) 

40 store_student_repo_info_to_config_file(arguments.repo_info_dir, group_name, student_repos) 

41 

42 

43if __name__ == "__main__": 

44 main()