def test_options(self, parser_mock, file_handler_mock, logging_mock, read_host_check_file_mock,
                  set_formatter_mock, user_root_mock, do_cleanup_mock, get_yn_input_mock):
   parser_mock.return_value = (TestHostCleanup.HostCleanupOptions('/someoutputfile', '/someinputfile', '', False), [])
   file_handler_mock.return_value = logging.FileHandler('') # disable creating real file
   user_root_mock.return_value = True
   get_yn_input_mock.return_value = True
   HostCleanup.main()
   
   # test --out
   file_handler_mock.assert_called_with('/someoutputfile')
   # test --skip
   self.assertEquals([''],HostCleanup.SKIP_LIST)
   #test --verbose
   logging_mock.assert_called_with(level=logging.INFO)
   # test --in
   read_host_check_file_mock.assert_called_with('/someinputfile')
Beispiel #2
0
  def test_options_silent(self, parser_mock, file_handler_mock, logging_mock, read_host_check_file_mock,
                   set_formatter_mock, user_root_mock, do_cleanup_mock, get_yn_input_mock):
    parser_mock.return_value = (TestHostCleanup.HostCleanupOptions('/someoutputfile', '/someinputfile', '', False,
                                                                   True, 'java_home'), [])
    file_handler_mock.return_value = logging.FileHandler('') # disable creating real file
    user_root_mock.return_value = True
    get_yn_input_mock.return_value = True
    HostCleanup.main()

    # test --out
    file_handler_mock.assert_called_with('/someoutputfile')
    # test --skip
    self.assertEquals([''],HostCleanup.SKIP_LIST)
    #test --verbose
    logging_mock.assert_called_with(level=logging.INFO)
    # test --in
    read_host_check_file_mock.assert_called_with('/someinputfile')
    self.assertFalse(get_yn_input_mock.called)
  def test_options_silent(self, parser_mock, file_handler_mock, logging_mock, read_host_check_file_mock,
                   set_formatter_mock, user_root_mock, do_cleanup_mock, get_yn_input_mock, clear_cache_mock):
    open('/tmp/someinputfile1', 'a').close()
    open('/tmp/someinputfile2', 'a').close()
    parser_mock.return_value = (TestHostCleanup.HostCleanupOptions('/someoutputfile', '/tmp/someinputfile1,/tmp/someinputfile2', '', False,
                                                                   True, 'java_home'), [])
    file_handler_mock.return_value = logging.FileHandler('') # disable creating real file
    user_root_mock.return_value = True
    get_yn_input_mock.return_value = True
    HostCleanup.main()

    # test --out
    file_handler_mock.assert_called_with('/someoutputfile')
    # test --skip
    self.assertEquals([''],HostCleanup.SKIP_LIST)
    #test --verbose
    logging_mock.assert_called_with(level=logging.INFO)
    # test --in
    read_host_check_file_mock.assert_called_with('tmp_hostcheck.result')
    self.assertFalse(get_yn_input_mock.called)
Beispiel #4
0
 def setUp(self):
     HostCleanup.logger = MagicMock()
     self.hostcleanup = HostCleanup.HostCleanup()
     # disable stdout
     out = StringIO.StringIO()
     sys.stdout = out