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

"""
    tests.t_utils.test_dynamic
    ~~~~~~~~~~~~~~~~~~~~~~~~~~
    :copyright: Copyright 2017 by the Stormrose Project team, see AUTHORS.
    :license: MIT License, see LICENSE for details.
"""


from unittest import TestCase
from xobox.utils.dynamic import Dynamic, DynamicIterable


class TestXoboxUtilsDynamic(TestCase):
    """
    Unit tests for :py:mod:`xobox.utils.dynamic`
    """

    def test_01(self):
        """
        Test Case 01:
        Try instantiating a Dynamic object.
        
        Test is passed if the instance proves being a :py:class:`~xobox.utils.dynamic.Dynamic` instance.
        """
        obj = Dynamic()
        self.assertIsInstance(obj, Dynamic)

    def test_02(self):
        """
        Test Case 02:
        Instantiate a dynamic object with payload data.
        
        Test is passed if the corresponding attribute can be verified
        """
        d = {'tests': 123}
        obj = Dynamic(**d)
        self.assertTrue(hasattr(obj, 'tests'))

    def test_03(self):
        """
        Test Case 03:
        Try instantiating a DynamicIterable object.
        
        Test is passed if the instance proves being a :py:class:`~xobox.utils.dynamic.DynamicIterable` instance.
        """
        obj = DynamicIterable()
        self.assertIsInstance(obj, DynamicIterable)

    def test_04(self):
        """
        Test Case 04:
        Insert data into a DynamicIterable object and verify dictionary-style accessibility.
        
        Test is passed if the added member is in the keys and the linked data equal to the inserted tests data.
        """
        obj = DynamicIterable()
        obj['tests'] = 123
        self.assertIn('tests', obj)
        self.assertEqual(obj['tests'], 123)

    def test_05(self):
        """
        Test Case 05:
        Insert data into a DynamicIterable object and verify object-style accessibility.
        
        Test is passed if the object proves having a corresponding attribute, providing the inserted tests data.
        """
        obj = DynamicIterable()
        obj['tests'] = 123
        self.assertTrue(hasattr(obj, 'tests'))
        self.assertEqual(obj.test, 123)

    def test_06(self):
        """
        Test Case 06:
        Create a DynamicIterable with initial data passed as dictionary.
        
        Test is passed if initial member is in the keys and the linked data is equal to the initial tests data.
        """
        d = {'tests': 123}
        obj = DynamicIterable(d)
        self.assertIn('tests', obj)
        self.assertEqual(obj['tests'], 123)<commit_msg>Fixed typo in test case<commit_after># -*- coding: utf-8 -*-

"""
    tests.t_utils.test_dynamic
    ~~~~~~~~~~~~~~~~~~~~~~~~~~
    :copyright: Copyright 2017 by the Stormrose Project team, see AUTHORS.
    :license: MIT License, see LICENSE for details.
"""


from unittest import TestCase
from xobox.utils.dynamic import Dynamic, DynamicIterable


class TestXoboxUtilsDynamic(TestCase):
    """
    Unit tests for :py:mod:`xobox.utils.dynamic`
    """

    def test_01(self):
        """
        Test Case 01:
        Try instantiating a Dynamic object.
        
        Test is passed if the instance proves being a :py:class:`~xobox.utils.dynamic.Dynamic` instance.
        """
        obj = Dynamic()
        self.assertIsInstance(obj, Dynamic)

    def test_02(self):
        """
        Test Case 02:
        Instantiate a dynamic object with payload data.
        
        Test is passed if the corresponding attribute can be verified
        """
        d = {'tests': 123}
        obj = Dynamic(**d)
        self.assertTrue(hasattr(obj, 'tests'))

    def test_03(self):
        """
        Test Case 03:
        Try instantiating a DynamicIterable object.
        
        Test is passed if the instance proves being a :py:class:`~xobox.utils.dynamic.DynamicIterable` instance.
        """
        obj = DynamicIterable()
        self.assertIsInstance(obj, DynamicIterable)

    def test_04(self):
        """
        Test Case 04:
        Insert data into a DynamicIterable object and verify dictionary-style accessibility.
        
        Test is passed if the added member is in the keys and the linked data equal to the inserted tests data.
        """
        obj = DynamicIterable()
        obj['tests'] = 123
        self.assertIn('tests', obj)
        self.assertEqual(obj['tests'], 123)

    def test_05(self):
        """
        Test Case 05:
        Insert data into a DynamicIterable object and verify object-style accessibility.
        
        Test is passed if the object proves having a corresponding attribute, providing the inserted tests data.
        """
        obj = DynamicIterable()
        obj['tests'] = 123
        self.assertTrue(hasattr(obj, 'tests'))
        self.assertEqual(obj.tests, 123)

    def test_06(self):
        """
        Test Case 06:
        Create a DynamicIterable with initial data passed as dictionary.
        
        Test is passed if initial member is in the keys and the linked data is equal to the initial tests data.
        """
        d = {'tests': 123}
        obj = DynamicIterable(d)
        self.assertIn('tests', obj)
        self.assertEqual(obj['tests'], 123)
{'fraction_non_alphanumeric': 0.10028490028490028, 'fraction_numerical': 0.01899335232668566, 'mean_word_length': 2.1973284760170007, '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': '1659312', 'n_tokens_mistral': 1508, 'n_tokens_neox': 1356, 'n_words': 487}