コード例 #1
0
ファイル: cli.py プロジェクト: othalla/py-control-repository
 def take_action(self, parsed_args):
     organisation, repository, token = get_config_from_environment()
     control_repository = ControlRepository(organisation, repository, token,
                                            parsed_args.url)
     puppet_environment = control_repository.get_environment(
         parsed_args.environment[0])
     puppetfile = puppet_environment.get_puppetfile()
     puppetfile.remove_git_module(parsed_args.module[0])
コード例 #2
0
 def test_if_environment_does_not_exists(github):
     control_repository = ControlRepository('test_organization',
                                            'test_repository',
                                            'some-token')
     repository = github().get_organization().get_repo()
     repository.get_branch.side_effect = GithubException('badstatus',
                                                         'missing')
     with pytest.raises(EnvironmentNotFoundException):
         control_repository.get_environment('environment')
コード例 #3
0
ファイル: cli.py プロジェクト: othalla/py-control-repository
 def take_action(self, parsed_args):
     organisation, repository, token = get_config_from_environment()
     control_repository = ControlRepository(organisation, repository, token,
                                            parsed_args.url)
     puppet_environment = control_repository.get_environment(
         parsed_args.name[0])
     puppetfile = puppet_environment.get_puppetfile()
     module_list = puppetfile.list_modules()
     return (('Name', ), ((module, ) for module in module_list))
コード例 #4
0
ファイル: cli.py プロジェクト: othalla/py-control-repository
 def take_action(self, parsed_args):
     organisation, repository, token = get_config_from_environment()
     control_repository = ControlRepository(organisation, repository, token,
                                            parsed_args.url)
     puppet_environment = control_repository.get_environment(
         parsed_args.name[0])
     puppetfile = puppet_environment.get_puppetfile()
     forge_modules = puppetfile.forge_modules
     return (('Name', 'version'),
             ((module.name, module.version if module.version else '')
              for module in forge_modules))
コード例 #5
0
 def test_it_returns_the_list_of_environment_names(github):
     control_repository = ControlRepository('test_organization',
                                            'test_repository',
                                            'some-token')
     repository = github().get_organization().get_repo()
     branch_dev = MagicMock()
     branch_prd = MagicMock()
     branch_dev.configure_mock(name='dev')
     branch_prd.configure_mock(name='prd')
     repository.get_branches.return_value = [branch_dev, branch_prd]
     environment_list = control_repository.get_environment_names()
     assert sorted(environment_list) == sorted(['prd', 'dev'])
コード例 #6
0
ファイル: cli.py プロジェクト: othalla/py-control-repository
 def take_action(self, parsed_args):
     organisation, repository, token = get_config_from_environment()
     control_repository = ControlRepository(organisation, repository, token,
                                            parsed_args.url)
     puppet_environment = control_repository.get_environment(
         parsed_args.name[0])
     puppetfile = puppet_environment.get_puppetfile()
     git_modules = puppetfile.git_modules
     return (('Name', 'url', 'reference_type', 'referece'),
             ((module.name, module.git_url,
               module.reference_type if module.reference_type else '',
               module.reference if module.reference else '')
              for module in git_modules))
コード例 #7
0
 def test_it_returns_the_new_environment(github):
     control_repository = ControlRepository('test_organization',
                                            'test_repository',
                                            'some-token')
     repository = github().get_organization().get_repo()
     source_branch = MagicMock()
     source_branch.configure_mock(name='source_branch')
     created_branch = MagicMock()
     created_branch.configure_mock(name='newenv')
     repository.get_branch.side_effect = [source_branch, created_branch]
     puppet_environment = control_repository.create_environment(
         'source_environment', 'newenv')
     assert isinstance(puppet_environment, Environment)
     assert puppet_environment.name == 'newenv'
コード例 #8
0
 def test_it_returns_all_puppet_environments(github):
     control_repository = ControlRepository('test_organization',
                                            'test_repository',
                                            'some-token')
     repository = github().get_organization().get_repo()
     branch_dev = MagicMock()
     branch_prd = MagicMock()
     branch_dev.configure_mock(name='dev')
     branch_prd.configure_mock(name='prd')
     repository.get_branches.return_value = [branch_dev, branch_prd]
     puppet_environments = control_repository.get_environments()
     assert isinstance(puppet_environments[0], Environment)
     assert puppet_environments[0].name == 'dev'
     assert isinstance(puppet_environments[1], Environment)
     assert puppet_environments[1].name == 'prd'
コード例 #9
0
ファイル: cli.py プロジェクト: othalla/py-control-repository
 def take_action(self, parsed_args):
     if parsed_args.reference or parsed_args.reference_type:
         if not parsed_args.reference or not parsed_args.reference_type:
             exit('You must provide either a git reference type and a'
                  'git reference.')
     organisation, repository, token = get_config_from_environment()
     control_repository = ControlRepository(organisation, repository, token,
                                            parsed_args.url)
     puppet_environment = control_repository.get_environment(
         parsed_args.environment[0])
     puppetfile = puppet_environment.get_puppetfile()
     puppetfile.add_git_module(parsed_args.module[0],
                               parsed_args.url[0],
                               reference_type=parsed_args.reference_type,
                               reference=parsed_args.reference)
コード例 #10
0
 def test_it_get_control_repository_from_github(github):
     ControlRepository('organization',
                       'repository',
                       'some-token')
     github.assert_called_once()
     github.assert_called_once_with('some-token')
     github().get_organization.assert_called_once_with('organization')
     github().get_organization().get_repo.assert_called_once_with(
         'repository')
コード例 #11
0
 def test_it_returns_a_puppet_environment():
     control_repository = ControlRepository('test_organization',
                                            'test_repository',
                                            'some-token')
     puppet_environment = control_repository.get_environment('test')
     assert isinstance(puppet_environment, Environment)
コード例 #12
0
 def test_it_fails_to_get_control_repository_from_github(github):
     github.side_effect = GithubException('badstatus', 'missing')
     with pytest.raises(ControlRepositoryException):
         ControlRepository('test_organization',
                           'test_repository',
                           'some-token')
コード例 #13
0
ファイル: cli.py プロジェクト: othalla/py-control-repository
 def take_action(self, parsed_args):
     organisation, repository, token = get_config_from_environment()
     control_repository = ControlRepository(organisation, repository, token,
                                            parsed_args.url)
     environment_list = control_repository.get_environment_names()
     return (('Name', ), ((env, ) for env in environment_list))