def test_run_doesnt_start_services_locally_if_single_slave_configured_that_isnt_localhost(
         self):
     Configuration['slaves'] = ['host_2.pod.box.net']
     build_subcommand = BuildSubcommand()
     build_subcommand.run(None, None)
     self.assertFalse(self.mock_ServiceRunner_instance.run_master.called)
     self.assertFalse(self.mock_ServiceRunner_instance.run_slave.called)
 def test_run_instantiates_buildrunner_with_correct_constructor_args_for_git_project_type(self):
     Configuration['hostname'] = 'localhost'
     Configuration['port'] = 43000
     build_subcommand = BuildSubcommand()
     build_subcommand.run(None, None, type='git')
     # assert on constructor params
     self.mock_BuildRunner.assert_called_once_with('localhost:43000', request_params={'type':'git'}, secret=None)
 def test_run_doesnt_start_services_locally_if_configured_master_hostname_isnt_localhost(
         self):
     Configuration[
         'master_hostname'] = 'some_automation_host.pod.box.net:430000'
     build_subcommand = BuildSubcommand()
     build_subcommand.run(None, None)
     self.assertFalse(self.mock_ServiceRunner_instance.run_master.called)
     self.assertFalse(self.mock_ServiceRunner_instance.run_slave.called)
Esempio n. 4
0
 def test_build_subcommand_no_args_sets_cwd_in_request_params_to_build_runner(self):
     expected_project_directory = 'mordor'
     self.mock_cwd(expected_project_directory)
     bs = BuildSubcommand()
     bs.run(log_level='whatever', master_url=None)
     # the second member of call args are the keyword arguments
     # so this checks the kw args to the constructor for BuildRunner
     actual = self.mock_build_runner_constructor_kw_args()['request_params']['project_directory']
     self.assertEqual(expected_project_directory, actual)
Esempio n. 5
0
 def test_build_subcommand_no_args_sets_cwd_in_request_params_to_build_runner(
         self):
     expected_project_directory = 'mordor'
     self.mock_cwd(expected_project_directory)
     bs = BuildSubcommand()
     bs.run(log_level='whatever', master_url=None)
     # the second member of call args are the keyword arguments
     # so this checks the kw args to the constructor for BuildRunner
     actual = self.mock_build_runner_constructor_kw_args(
     )['request_params']['project_directory']
     self.assertEqual(expected_project_directory, actual)
 def test_run_instantiates_buildrunner_with_correct_constructor_args_for_git_project_type(
         self):
     Configuration['hostname'] = 'localhost'
     Configuration['port'] = 43000
     build_subcommand = BuildSubcommand()
     build_subcommand.run(None, None, type='git')
     # assert on constructor params
     self.mock_BuildRunner.assert_called_once_with(
         'localhost:43000',
         request_params={'type': 'git'},
         secret=Secret.get())
 def test_run_starts_services_locally_if_conditions_match(self):
     """
     These conditions are:
         - master_url is not explicitly specified
         - the master host is localhost
         - there is only one slave, and it is localhost
     """
     build_subcommand = BuildSubcommand()
     build_subcommand.run(None, None)
     self.mock_ServiceRunner_instance.run_master.assert_called_with()
     self.mock_ServiceRunner_instance.run_slave.assert_called_with()
 def test_run_starts_services_locally_if_conditions_match(self):
     """
     These conditions are:
         - master_url is not explicitly specified
         - the master host is localhost
         - there is only one slave, and it is localhost
     """
     build_subcommand = BuildSubcommand()
     build_subcommand.run(None, None)
     self.mock_ServiceRunner_instance.run_master.assert_called_with()
     self.mock_ServiceRunner_instance.run_slave.assert_called_with()
 def test_run_instantiates_buildrunner_with_correct_constructor_args_for_directory_project_type(self):
     Configuration['hostname'] = 'localhost'
     Configuration['port'] = 43000
     os_getcwd_patch = self.patch('os.getcwd')
     os_getcwd_patch.return_value = '/current/directory'
     build_subcommand = BuildSubcommand()
     build_subcommand.run(None, None)
     # assert on constructor params
     self.mock_BuildRunner.assert_called_once_with(
         'localhost:43000',
         request_params={'type':'directory', 'project_directory':'/current/directory'},
         secret=None
     )
Esempio n. 10
0
    def test_main_exits_with_nonzero_exit_code_if_build_runner_fails(self):
        mock_Secret = self.patch('app.subcommands.build_subcommand.Secret')
        mock_Secret.get.return_value = 'mellon1234'
        mock_build_runner = self.mock_BuildRunner.return_value
        mock_build_runner.run.return_value = False  # run() method returns false when build fails
        build_subcommand = BuildSubcommand()
        with self.assertRaisesRegex(SystemExit, '1'):  # asserts that sys.exit(1) is called
            build_subcommand.run(log_level=None, master_url='smaug:1', build_type='middleearth',
                                 some_other_param='999')

        self.mock_BuildRunner.assert_called_once_with(
            master_url='smaug:1',
            secret='mellon1234',
            request_params={'type': 'middleearth', 'some_other_param': '999'}
        )
 def test_run_instantiates_buildrunner_with_correct_constructor_args_for_directory_project_type(
         self):
     Configuration['hostname'] = 'localhost'
     Configuration['port'] = 43000
     os_getcwd_patch = self.patch('os.getcwd')
     os_getcwd_patch.return_value = '/current/directory'
     build_subcommand = BuildSubcommand()
     build_subcommand.run(None, None)
     # assert on constructor params
     self.mock_BuildRunner.assert_called_once_with('localhost:43000',
                                                   request_params={
                                                       'type':
                                                       'directory',
                                                       'project_directory':
                                                       '/current/directory'
                                                   },
                                                   secret=Secret.get())
Esempio n. 12
0
    def test_main_exits_with_nonzero_exit_code_if_build_runner_fails(self):
        mock_Secret = self.patch('app.subcommands.build_subcommand.Secret')
        mock_Secret.get.return_value = 'mellon1234'
        mock_build_runner = self.mock_BuildRunner.return_value
        mock_build_runner.run.return_value = False  # run() method returns false when build fails
        build_subcommand = BuildSubcommand()
        with self.assertRaisesRegex(SystemExit,
                                    '1'):  # asserts that sys.exit(1) is called
            build_subcommand.run(log_level=None,
                                 master_url='smaug:1',
                                 build_type='middleearth',
                                 some_other_param='999')

        self.mock_BuildRunner.assert_called_once_with(master_url='smaug:1',
                                                      secret='mellon1234',
                                                      request_params={
                                                          'type':
                                                          'middleearth',
                                                          'some_other_param':
                                                          '999'
                                                      })
 def test_run_doesnt_start_services_locally_if_master_is_already_up(self):
     self.mock_ServiceRunner_instance.is_master_up.return_value = True
     build_subcommand = BuildSubcommand()
     build_subcommand.run(None, None)
     self.assertFalse(self.mock_ServiceRunner_instance.run_master.called)
     self.assertFalse(self.mock_ServiceRunner_instance.run_slave.called)
 def test_run_doesnt_start_services_locally_if_single_slave_configured_that_isnt_localhost(self):
     Configuration['slaves'] = ['host_2.pod.box.net']
     build_subcommand = BuildSubcommand()
     build_subcommand.run(None, None)
     self.assertFalse(self.mock_ServiceRunner_instance.run_master.called)
     self.assertFalse(self.mock_ServiceRunner_instance.run_slave.called)
 def test_run_doesnt_start_services_locally_if_configured_master_hostname_isnt_localhost(self):
     Configuration['master_hostname'] = 'some_automation_host.pod.box.net:430000'
     build_subcommand = BuildSubcommand()
     build_subcommand.run(None, None)
     self.assertFalse(self.mock_ServiceRunner_instance.run_master.called)
     self.assertFalse(self.mock_ServiceRunner_instance.run_slave.called)
 def test_run_doesnt_start_services_locally_if_master_is_already_up(self):
     self.mock_ServiceRunner_instance.is_master_up.return_value = True
     build_subcommand = BuildSubcommand()
     build_subcommand.run(None, None)
     self.assertFalse(self.mock_ServiceRunner_instance.run_master.called)
     self.assertFalse(self.mock_ServiceRunner_instance.run_slave.called)