def test__if_push_events_change_works(self, gitlab: GitLab): gf = GitLabForm( config_string=config_service_push_events_true, project_or_group=GROUP_AND_PROJECT_NAME, ) gf.main() services = [] for service_name in ["asana", "hipchat", "redmine"]: service = gitlab.get_service(GROUP_AND_PROJECT_NAME, service_name) services.append(service) assert all([service["active"] for service in services]) is True assert all([service["push_events"] for service in services]) is True gf = GitLabForm( config_string=config_service_push_events_false, project_or_group=GROUP_AND_PROJECT_NAME, ) gf.main() services = [] for service_name in ["asana", "hipchat", "redmine"]: service = gitlab.get_service(GROUP_AND_PROJECT_NAME, service_name) services.append(service) assert all([service["active"] for service in services]) is True assert all([service["push_events"] for service in services]) is False
def initialize_configuration_and_gitlab(self): try: if hasattr(self, "config_string"): gitlab = GitLab(config_string=self.config_string) else: gitlab = GitLab(config_path=self.config) configuration = gitlab.get_configuration() self.access_levels_transformer.transform(configuration) return gitlab, configuration except ConfigFileNotFoundException as e: fatal( f"Config file not found at: {e}", exit_code=EXIT_INVALID_INPUT, ) except ConfigInvalidException as e: fatal( f"Invalid config:\n{e.underlying}", exit_code=EXIT_INVALID_INPUT, ) except TestRequestFailedException as e: fatal( f"GitLab test request failed:\n{e.underlying}", exit_code=EXIT_PROCESSING_ERROR, )
def initialize_configuration_and_gitlab(self): try: if hasattr(self, "config_string"): gitlab = GitLab(config_string=self.config_string) else: gitlab = GitLab(config_path=self.config) configuration = gitlab.get_configuration() return gitlab, configuration except ConfigFileNotFoundException as e: cli_ui.error(f"Config file not found at: {e}") sys.exit(EXIT_INVALID_INPUT) except TestRequestFailedException as e: cli_ui.error(f"GitLab test request failed. Exception: '{e}'") sys.exit(EXIT_PROCESSING_ERROR)
def test__if_delete_works(self, gitlab: GitLab): gf = GitLabForm(config_string=config_service_jira_commit_events_true, project_or_group=GROUP_AND_PROJECT_NAME) gf.main() service = gitlab.get_service(GROUP_AND_PROJECT_NAME, 'jira') assert service['active'] is True assert service['commit_events'] is True gf = GitLabForm(config_string=config_service_jira_delete, project_or_group=GROUP_AND_PROJECT_NAME) gf.main() service = gitlab.get_service(GROUP_AND_PROJECT_NAME, 'jira') assert service['active'] is False
def initialize_configuration_and_gitlab(self): try: if hasattr(self, 'config_string'): gl = GitLab(config_string=self.config_string) c = Configuration(config_string=self.config_string) else: gl = GitLab(self.config.strip()) c = Configuration(self.config.strip()) return gl, c except ConfigFileNotFoundException as e: logging.fatal('Aborting - config file not found at: %s', e) sys.exit(1) except TestRequestFailedException as e: logging.fatal("Aborting - GitLab test request failed, details: '%s'", e) sys.exit(2)
def test__mattermost_confidential_issues_events(self, gitlab: GitLab): gf = GitLabForm( config_string=config_service_mattermost_confidential_issues_events, project_or_group=GROUP_AND_PROJECT_NAME) gf.main() service = gitlab.get_service(GROUP_AND_PROJECT_NAME, 'mattermost') assert service['confidential_issues_events'] is False
def test__if_jira_commit_events_false_works(self, gitlab: GitLab): gf = GitLabForm( config_string=config_service_jira_commit_events_false, project_or_group=GROUP_AND_PROJECT_NAME, ) gf.main() service = gitlab.get_service(GROUP_AND_PROJECT_NAME, "jira") assert service["active"] is True assert service["commit_events"] is False
def test__if_push_events_false_works(self, gitlab: GitLab): gf = GitLabForm(config_string=config_service_push_events_false, project_or_group=GROUP_AND_PROJECT_NAME) gf.main() services = [] for service_name in ['asana', 'hipchat', 'redmine']: service = gitlab.get_service(GROUP_AND_PROJECT_NAME, service_name) services.append(service) assert all([service['active'] for service in services]) is True assert all([service['push_events'] for service in services]) is False
def initialize_configuration_and_gitlab(self): try: gl = GitLab(self.args.config) c = Configuration(self.args.config) return gl, c except ConfigFileNotFoundException as e: logging.fatal('Aborting - config file not found at: %s', e) sys.exit(1) except TestRequestFailedException as e: logging.fatal( "Aborting - GitLab test request failed, details: '%s'", e) sys.exit(2)
from gitlabform.gitlab import GitLab from gitlabform.gitlab.core import NotFoundException, UnexpectedResponseException CONFIG = """ gitlab: # GITLAB_URL and GITLAB_TOKEN should be in the env variables api_version: 4 """ GROUP_NAME = 'gitlabform_tests_group' DEVELOPER_ACCESS = 30 gl = GitLab(config_string=CONFIG) def get_gitlab(): return gl def create_group(group_name): try: gl.get_group(group_name) except NotFoundException: gl.create_group(group_name, group_name) def create_project_in_group(group_name, project_name): try: gl.get_project(group_name + '/' + project_name) except NotFoundException: