コード例 #1
0
    def test_mongo(self):
        """Function:  test_mongo

        Description:  Test inserting data into Mongo database.

        Arguments:

        """

        cmdline = gen_libs.get_inst(sys)
        self.argv_list.extend(("-m", "-n"))
        cmdline.argv = self.argv_list
        server_usage.main()
        coll = mongo_libs.crt_coll_inst(self.cfg, self.cfg.db, self.cfg.coll)
        coll.connect()

        self.assertTrue(coll.coll_cnt() == 1)
コード例 #2
0
    def test_root_run_func(self):
        """Function:  test_root_run_func

        Description:  Test root_run function.

        Arguments:

        """

        self.argv_list.remove("-c")

        with gen_libs.no_std_out():
            self.assertFalse(server_usage.main())
コード例 #3
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(server_usage.main())
コード例 #4
0
    def test_print_raw(self):
        """Function:  test_print_raw

        Description:  Test printing unformatted data.

        Arguments:

        """

        cmdline = gen_libs.get_inst(sys)
        cmdline.argv = self.argv_list

        with gen_libs.no_std_out():
            self.assertFalse(server_usage.main())
コード例 #5
0
    def test_no_print(self):
        """Function:  test_no_print

        Description:  Test standard out suppression.

        Arguments:

        """

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

        self.assertFalse(server_usage.main())
コード例 #6
0
    def test_help_false(self, mock_lib):
        """Function:  test_help_false

        Description:  Test with help_func returns False.

        Arguments:

        """

        mock_lib.help_func.return_value = False
        mock_lib.root_run.return_value = False

        with gen_libs.no_std_out():
            self.assertFalse(server_usage.main())
コード例 #7
0
    def test_root_run_true(self, mock_lib, mock_arg):
        """Function:  test_root_run_true

        Description:  Test with root_run returns True.

        Arguments:

        """

        mock_lib.help_func.return_value = False
        mock_lib.root_run.return_value = True
        mock_arg.arg_require.return_value = True

        self.assertFalse(server_usage.main())
コード例 #8
0
    def test_help_func(self):
        """Function:  test_help_func

        Description:  Test help_func function.

        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(server_usage.main())
コード例 #9
0
    def test_arg_require_func(self, mock_arg):
        """Function:  test_arg_require_func

        Description:  Test arg_require function.

        Arguments:

        """

        mock_arg.return_value = True

        cmdline = gen_libs.get_inst(sys)
        cmdline.argv = self.argv_list

        self.assertFalse(server_usage.main())
コード例 #10
0
    def test_dir_chk_crt_false(self, mock_lib, mock_arg, mock_run):
        """Function:  test_dir_chk_crt_false

        Description:  Test with arg_dir_chk_crt returns False.

        Arguments:

        """

        mock_lib.help_func.return_value = False
        mock_lib.root_run.return_value = True
        mock_arg.arg_require.return_value = False
        mock_arg.arg_dir_chk_crt.return_value = False
        mock_run.return_value = True

        self.assertFalse(server_usage.main())