<commit_before># Copyright 2014-2015 Boxkite Inc.

# This file is part of the DataCats package and is released under
# the terms of the GNU Affero General Public License version 3.0.
# See LICENSE.txt or http://www.fsf.org/licensing/licenses/agpl-3.0.html

from unittest import TestCase

from datacats.cli.main import _subcommand_arguments


def _s(cmd):
    command, args = _subcommand_arguments(cmd.split())
    return command, ' '.join(args)


class TestParseArguments(TestCase):
    def test_help(self):
        self.assertEqual(_s('help'), (None, '--help'))

    def test_help_long_option(self):
        self.assertEqual(_s('--help'), (None, '--help'))

    def test_help_short_option(self):
        self.assertEqual(_s('-h'), (None, '-h'))
<commit_msg>more cli parsing tests<commit_after># Copyright 2014-2015 Boxkite Inc.

# This file is part of the DataCats package and is released under
# the terms of the GNU Affero General Public License version 3.0.
# See LICENSE.txt or http://www.fsf.org/licensing/licenses/agpl-3.0.html

from unittest import TestCase

from datacats.cli.main import _subcommand_arguments
from datacats.error import DatacatsError


def _s(cmd):
    command, args = _subcommand_arguments(cmd.split())
    return command, ' '.join(args)


class TestParseArguments(TestCase):
    def test_help(self):
        self.assertEqual(_s('help'), (None, '--help'))

    def test_help_long_option(self):
        self.assertEqual(_s('--help'), (None, '--help'))

    def test_help_short_option(self):
        self.assertEqual(_s('-h'), (None, '-h'))

    def test_bad_subcommand(self):
        self.assertRaises(DatacatsError, _s, 'whatsup')

    def test_help_subcommand(self):
        self.assertEqual(_s('help info'), ('info', '--help info'))

    def test_subcommand(self):
        self.assertEqual(_s('info'), ('info', 'info'))

    def test_subcommand_option_first(self):
        self.assertEqual(_s('-q info'), ('info', '-q info'))

    def test_subcommand_option_last(self):
        self.assertEqual(_s('info -q'), ('info', 'info -q'))

{'fraction_non_alphanumeric': 0.14029126213592233, 'fraction_numerical': 0.011650485436893204, 'mean_word_length': 3.8838862559241707, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1345726', 'n_tokens_mistral': 678, 'n_tokens_neox': 646, 'n_words': 168}