コード例 #1
0
ファイル: test_command_line.py プロジェクト: uroborov/pyocnos
 def test_fail_when_config_does_not_exist(self):
     with self.assertRaises(IOError):
         process(config_file_path='foo.yml',
                 hostname='foo.com',
                 actions=[],
                 save_config_file_path=None,
                 candidate_file_path=None)
コード例 #2
0
ファイル: test_command_line.py プロジェクト: uroborov/pyocnos
 def test_success_apply_action(self, mock_ocnos):
     ocnos_instance = mock_ocnos.return_value.__enter__.return_value
     process(config_file_path=os.path.join(current_path,
                                           'user-details.yml.example'),
             hostname='foobar.com',
             actions=['apply'],
             save_config_file_path=None,
             candidate_file_path='candidate.xml')
     ocnos_instance.load_candidate_config.assert_called_once_with(
         filename='candidate.xml')
     ocnos_instance.commit_config.assert_called_once()
コード例 #3
0
ファイル: test_command_line.py プロジェクト: uroborov/pyocnos
 def test_success_connection(self, mock_ocnos):
     process(config_file_path=os.path.join(current_path,
                                           'user-details.yml.example'),
             hostname='foobar.com',
             actions=[],
             save_config_file_path=None,
             candidate_file_path=None)
     mock_ocnos.assert_called_once_with(hostname='foobar.com',
                                        username='******',
                                        password='******',
                                        timeout=30)
コード例 #4
0
ファイル: test_command_line.py プロジェクト: uroborov/pyocnos
 def test_success_startup_action(self, mock_ocnos):
     ocnos_instance = mock_ocnos.return_value.__enter__.return_value
     ocnos_instance.get_config.return_value = {'startup': b'Startup config'}
     file_path = os.path.join(current_path, 'startup.xml')
     process(config_file_path=os.path.join(current_path,
                                           'user-details.yml.example'),
             hostname='foobar.com',
             actions=['startup'],
             save_config_file_path=file_path,
             candidate_file_path=None)
     ocnos_instance.get_config.assert_called_once_with('startup')
     os.remove(file_path)
コード例 #5
0
ファイル: test_command_line.py プロジェクト: uroborov/pyocnos
 def test_success_connection_action(self, mock_ocnos):
     # As the OCNOS class is used in a context manager,
     # we need to mock the response from __enter__ which
     # is returned by the context manager.
     ocnos_instance = mock_ocnos.return_value.__enter__.return_value
     process(config_file_path=os.path.join(current_path,
                                           'user-details.yml.example'),
             hostname='foobar.com',
             actions=['connection'],
             save_config_file_path=None,
             candidate_file_path=None)
     ocnos_instance.is_alive.assert_called_once()