def test_empty_initialization(self):
        exposed_objects = ExposedObjectCollection(named_objects={})
        self.assertEqual(set(exposed_objects), {":api", "get_objects"})

        self.assertEqual(len(exposed_objects.get_objects()), 0)
        self.assertEqual(exposed_objects["get_objects"](),
                         exposed_objects.get_objects())
Example #2
0
    def test_empty_initialization(self):
        exposed_objects = ExposedObjectCollection(named_objects={})
        self.assertEqual(set(exposed_objects), {':api', 'get_objects'})

        self.assertEqual(len(exposed_objects.get_objects()), 0)
        self.assertEqual(exposed_objects['get_objects'](),
                         exposed_objects.get_objects())
    def test_remove_object(self):
        exposed_objects = ExposedObjectCollection({})
        own_functions_count = len(exposed_objects)

        obj = DummyObject()
        exposed_objects.add_object(obj, "testObject")

        self.assertListEqual(exposed_objects.get_objects(), ["testObject"])
        assertRaisesNothing(self, exposed_objects.remove_object, "testObject")
        self.assertEqual(len(exposed_objects), own_functions_count)

        self.assertRaises(RuntimeError, exposed_objects.remove_object,
                          "does_not_exist")