Пример #1
0
    def test_dict_update(self):
        obs = RecorderSpaceObserver(self.max_comps, self.max_props)
        obs.dict_init(self.dict_3_element)

        replaced_values = [('comp3', self.comp_3_info_new, self.comp_3_info)]

        new_values = []

        obs.dict_update(new_values, replaced_values)
        self.assertEqual(obs.if_full, True)

        replaced_values = [('comp3', self.comp_3_info, self.comp_3_info_new)]

        obs.dict_update(new_values, replaced_values)
        self.assertEqual(obs.if_full, False)

        new_values = [('comp4', self.comp_4_info)]
        replaced_values = []
        obs.dict_update(new_values, replaced_values)

        self.assertEqual(obs.if_full, True)
Пример #2
0
    def test_dict_del(self):
        obs = RecorderSpaceObserver(self.max_comps, self.max_props)
        obs.dict_init(self.dict_4_element)

        # check that adding an element makes the recorder full
        obs.dict_del('comp4', self.comp_4_info)
        self.assertEqual(obs.if_full, False)
Пример #3
0
    def test_dict_set(self):
        obs = RecorderSpaceObserver(self.max_comps, self.max_props)
        obs.dict_init(self.dict_3_element)

        # check that adding an element makes the recorder full
        obs.dict_set('comp3', self.comp_3_info_new, self.comp_3_info)
        self.assertEqual(obs.if_full, True)
Пример #4
0
    def test_dict_init(self):

        # Test the insertion of a dictionary that does not fill the limit
        obs = RecorderSpaceObserver(self.max_comps, self.max_props)
        obs.dict_init(self.dict_3_element)

        self.assertEqual(obs._max_components, self.max_comps)
        self.assertEqual(obs._max_properties, self.max_props)
        self.assertEqual(obs._actual_components, 3)
        self.assertEqual(obs._actual_properties, 9)
        self.assertEqual(obs.if_full, False)

        # Test the insertion of a dictionary that fills the limit
        obs = RecorderSpaceObserver(self.max_comps, self.max_props)
        obs.dict_init(self.dict_4_element)
        self.assertEqual(obs.if_full, True)
Пример #5
0
    def test_dict_clear(self):
        obs = RecorderSpaceObserver(self.max_comps, self.max_props)
        obs.dict_init(self.dict_4_element)

        # check that adding an element makes the recorder full
        empty_dict = {}
        obs.dict_clear(empty_dict, self.comp_4_info)

        self.assertEqual(obs.if_full, False)
        self.assertEqual(obs._actual_components, 0)
        self.assertEqual(obs._actual_properties, 0)
Пример #6
0
    def test_dict_popitem(self):
        obs = RecorderSpaceObserver(self.max_comps, self.max_props)
        obs.dict_init(self.dict_4_element)

        obs.dict_popitem('comp4', self.comp_4_info)
        self.assertEqual(obs.if_full, False)
Пример #7
0
 def test_dict_setdefault(self):
     obs = RecorderSpaceObserver(self.max_comps, self.max_props)
     self.assertRaises(NotImplementedError, obs.dict_setdefault, "a", "a",
                       "a")