def test_sqlite_command(self):
        """Test SQLite"""

        options = {
            "path": os.path.abspath(ASSETS_DIR / "input.sqlite3"),
            "query": "SELECT id FROM One;",
        }
        argv = [get_name(), self.command, options["path"], options["query"]]
        self.assertEqual(execute_from_command_line(argv), None)
    def test_excel_command(self):
        """Test Excel"""

        options = {
            "path": os.path.abspath(ASSETS_DIR / "input.xlsx"),
            "sheet": "Sheet1",
        }
        argv = [
            get_name(), self.command, options["path"], "-S", options["sheet"]
        ]
        self.assertEqual(execute_from_command_line(argv), None)
    def test_neo4j_command(self):
        """Test Neo4j"""

        options = {
            "user": "******",
            "password": "******",
            "query": "MATCH 1 AS One;",
        }
        argv = [
            get_name(),
            "neo4j",
            options["user"],
            options["password"],
            options["query"],
        ]
        self.assertEqual(execute_from_command_line(argv), None)
Example #4
0
    def main_help_text(self, commands_only=False):
        """Return the script's main help text, as a string."""

        if commands_only:
            usage = sorted(get_commands())
        else:
            usage = [
                "",
                "Type '%s help <subcommand>' for help on a specific subcommand."
                % self.prog_name,
                "",
                "Available subcommands:",
            ]
            commands_dict = defaultdict(lambda: [])
            for name, app in get_commands().items():
                app = app.rpartition(".")[-1]
                commands_dict[app].append(name)
            for app in sorted(commands_dict):
                usage.append("")
                usage.append("[%s]" % (get_name(), ))
                for name in sorted(commands_dict[app]):
                    usage.append("    %s" % name)

        return "\n".join(usage)
    def test_unknown_args(self):
        """Test Unknown Command Error"""

        argv = [get_name(), self.command, "path", "-l", "82"]
        with self.assertRaises(SystemExit):
            execute_from_command_line(argv)
    def test_possible_match(self):
        """Test Command Error"""

        argv = [get_name(), "xsv"]
        with self.assertRaises(SystemExit):
            execute_from_command_line(argv)
    def test_commands_flag(self):
        """Test Commands Flag"""

        argv = [get_name(), "help", "--commands"]
        self.assertEqual(execute_from_command_line(argv), None)
    def test_version(self):
        """Test Version"""

        argv = [get_name(), "--version"]
        self.assertEqual(execute_from_command_line(argv), None)
    def test_unknown_command(self):
        """Test Unknown Command"""

        argv = [get_name(), "unknown"]
        with self.assertRaises(SystemExit):
            execute_from_command_line(argv)
    def test_empty_base_command(self):
        """Test Empty Base Command"""

        argv = [get_name()]
        self.assertEqual(execute_from_command_line(argv), None)
Example #11
0
    def test_csv_command(self):
        """Test CSV"""

        options = {"path": os.path.abspath(ASSETS_DIR / "input.csv")}
        argv = [get_name(), self.command, options["path"]]
        self.assertEqual(execute_from_command_line(argv), None)