Ejemplo n.º 1
0
    def test_help_true(self, mock_arg, mock_help):
        """Function:  test_help_true

        Description:  Test with help_func returns True.

        Arguments:

        """

        mock_arg.return_value = self.args
        mock_help.return_value = True

        self.assertFalse(elastic_db_dump.main())
Ejemplo n.º 2
0
    def test_create_repo(self):
        """Function:  test_create_repo

        Description:  Test create repo call.

        Arguments:

        """

        cmdline = gen_libs.get_inst(sys)
        self.argv_list.append("-C")
        self.argv_list.append(self.cfg.repo_name)
        self.argv_list.append("-l")
        self.argv_list.append(self.cfg.repo_dir)
        cmdline.argv = self.argv_list

        elastic_db_dump.main()

        self.elr = elastic_class.ElasticSearchRepo(self.cfg.host,
                                                   self.cfg.port,
                                                   repo=self.cfg.repo_name)

        self.assertTrue(self.cfg.repo_name in self.elr.repo_dict)
Ejemplo n.º 3
0
    def test_help_false(self, mock_arg, mock_help):
        """Function:  test_help_false

        Description:  Test with help_func returns False.

        Arguments:

        """

        mock_arg.arg_parse2.return_value = self.args
        mock_help.return_value = False
        mock_arg.arg_require.return_value = True

        self.assertFalse(elastic_db_dump.main())
Ejemplo n.º 4
0
    def test_initate_dump(self):
        """Function:  test_initate_dump

        Description:  Test initiate dump call.

        Arguments:

        """

        cmdline = gen_libs.get_inst(sys)
        self.argv_list.append("-D")
        self.argv_list.append(self.cfg.repo_name)
        cmdline.argv = self.argv_list
        self.elr = elastic_class.ElasticSearchRepo(self.cfg.host,
                                                   self.cfg.port)
        _, _ = self.elr.create_repo(
            self.cfg.repo_name,
            os.path.join(self.cfg.repo_dir, self.cfg.repo_name))
        elastic_db_dump.main()
        els = elastic_class.ElasticSearchDump(self.cfg.host,
                                              self.cfg.port,
                                              repo=self.cfg.repo_name)

        self.assertTrue(els.dump_list)
Ejemplo n.º 5
0
    def test_help_func(self):
        """Function:  test_help_func

        Description:  Test help call.

        Arguments:

        """

        cmdline = gen_libs.get_inst(sys)
        self.argv_list.append("-v")
        cmdline.argv = self.argv_list

        with gen_libs.no_std_out():
            self.assertFalse(elastic_db_dump.main())
Ejemplo n.º 6
0
    def test_arg_dir_chk_crt(self):
        """Function:  test_arg_dir_chk_crt

        Description:  Test arg dir chk crt call.

        Arguments:

        """

        cmdline = gen_libs.get_inst(sys)
        self.argv_list.remove(self.config_path)
        self.argv_list.append("TEST_DIR")
        cmdline.argv = self.argv_list

        with gen_libs.no_std_out():
            self.assertFalse(elastic_db_dump.main())
Ejemplo n.º 7
0
    def test_arg_cond_req_or(self):
        """Function:  test_arg_cond_req_or

        Description:  Test arg cond req or call.

        Arguments:

        """

        cmdline = gen_libs.get_inst(sys)
        self.argv_list.append("-C")
        self.argv_list.append("TEST_VALUE")
        cmdline.argv = self.argv_list

        with gen_libs.no_std_out():
            self.assertFalse(elastic_db_dump.main())
Ejemplo n.º 8
0
    def test_arg_xor_dict(self):
        """Function:  test_arg_xor_dict

        Description:  Test arg xor dict call.

        Arguments:

        """

        cmdline = gen_libs.get_inst(sys)
        self.argv_list.append("-L")
        self.argv_list.append("-D")
        cmdline.argv = self.argv_list

        with gen_libs.no_std_out():
            self.assertFalse(elastic_db_dump.main())
Ejemplo n.º 9
0
    def test_arg_require(self):
        """Function:  test_arg_require

        Description:  Test arg require call.

        Arguments:

        """

        cmdline = gen_libs.get_inst(sys)
        self.argv_list.remove("-c")
        self.argv_list.remove("elastic")
        cmdline.argv = self.argv_list

        with gen_libs.no_std_out():
            self.assertFalse(elastic_db_dump.main())
Ejemplo n.º 10
0
    def test_con_req_or_false(self, mock_arg, mock_help):
        """Function:  test_con_req_or_false

        Description:  Test with arg_cond_req_or returns False.

        Arguments:

        """

        mock_arg.arg_parse2.return_value = self.args
        mock_help.return_value = False
        mock_arg.arg_require.return_value = False
        mock_arg.arg_xor_dict.return_value = True
        mock_arg.arg_cond_req_or.return_value = False

        self.assertFalse(elastic_db_dump.main())
Ejemplo n.º 11
0
    def test_list_repos(self):
        """Function:  test_list_repos

        Description:  Test list repos call.

        Arguments:

        """

        cmdline = gen_libs.get_inst(sys)
        self.argv_list.append("-R")
        cmdline.argv = self.argv_list
        self.elr = elastic_class.ElasticSearchRepo(self.cfg.host,
                                                   self.cfg.port)
        _, _ = self.elr.create_repo(
            self.cfg.repo_name,
            os.path.join(self.cfg.repo_dir, self.cfg.repo_name))

        with gen_libs.no_std_out():
            self.assertFalse(elastic_db_dump.main())