<commit_before># -*- coding: utf-8 -*-

import unittest

from dyndnsc.common.dynamiccli import parse_cmdline_args, DynamicCliMixin
from __builtin__ import staticmethod


class Dummy(DynamicCliMixin):
    def __init__(self, userid, password):
        pass

    @staticmethod
    def configuration_key():
        return "dummy"

    @staticmethod
    def configuration_key_prefix():
        return "foo"


class TestDynamicCli(unittest.TestCase):

    def setUp(self):
        pass

    def tearDown(self):
        pass

    def test_parse_cmdline_updater_args(self):
        self.assertRaises(TypeError, parse_cmdline_args, None)
        self.assertRaises(ValueError, parse_cmdline_args, None, None)
        self.assertRaises(NotImplementedError, parse_cmdline_args, object(), [DynamicCliMixin])
        self.assertEqual({}, parse_cmdline_args(object(), []))

        # test that a sample valid config parses:
        from argparse import Namespace
        args = Namespace()
        args.foo_dummy = True
        args.foo_dummy_userid = "bob"
        args.foo_dummy_password = "******"

        parsed = parse_cmdline_args(args, [Dummy])
        self.assertEqual(1, len(parsed))
        self.assertTrue(isinstance(parsed, dict))
        self.assertTrue('foo' in parsed)
        self.assertTrue(isinstance(parsed['foo'], list))
        self.assertEqual(1, len(parsed['foo']))
        self.assertTrue(isinstance(parsed['foo'][0], tuple))
        self.assertEqual(parsed['foo'][0][0], 'dummy')
        self.assertTrue(isinstance(parsed['foo'][0][1], dict))
        self.assertTrue("userid" in parsed['foo'][0][1].keys())
        self.assertTrue("password" in parsed['foo'][0][1].keys())
<commit_msg>import error<commit_after># -*- coding: utf-8 -*-

import unittest

from dyndnsc.common.dynamiccli import parse_cmdline_args, DynamicCliMixin


class Dummy(DynamicCliMixin):
    def __init__(self, userid, password):
        pass

    @staticmethod
    def configuration_key():
        return "dummy"

    @staticmethod
    def configuration_key_prefix():
        return "foo"


class TestDynamicCli(unittest.TestCase):

    def setUp(self):
        pass

    def tearDown(self):
        pass

    def test_parse_cmdline_updater_args(self):
        self.assertRaises(TypeError, parse_cmdline_args, None)
        self.assertRaises(ValueError, parse_cmdline_args, None, None)
        self.assertRaises(NotImplementedError, parse_cmdline_args, object(), [DynamicCliMixin])
        self.assertEqual({}, parse_cmdline_args(object(), []))

        # test that a sample valid config parses:
        from argparse import Namespace
        args = Namespace()
        args.foo_dummy = True
        args.foo_dummy_userid = "bob"
        args.foo_dummy_password = "******"

        parsed = parse_cmdline_args(args, [Dummy])
        self.assertEqual(1, len(parsed))
        self.assertTrue(isinstance(parsed, dict))
        self.assertTrue('foo' in parsed)
        self.assertTrue(isinstance(parsed['foo'], list))
        self.assertEqual(1, len(parsed['foo']))
        self.assertTrue(isinstance(parsed['foo'][0], tuple))
        self.assertEqual(parsed['foo'][0][0], 'dummy')
        self.assertTrue(isinstance(parsed['foo'][0][1], dict))
        self.assertTrue("userid" in parsed['foo'][0][1].keys())
        self.assertTrue("password" in parsed['foo'][0][1].keys())

{'fraction_non_alphanumeric': 0.12999403697078116, 'fraction_numerical': 0.007155635062611807, 'mean_word_length': 3.334625322997416, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '4540443', 'n_tokens_mistral': 1014, 'n_tokens_neox': 1024, 'n_words': 193}