Exemple #1
0
 def __init__(self):
     super(NuageApi, self).__init__()
     # Prepare default and shared netpartitions
     self._prepare_netpartitions()
     neutron_extensions.append_api_extensions_path(extensions.__path__)
     lib_db_resource_extend.register_funcs('security_groups',
                                           [self._extend_resource_dict])
    def test_register_funcs(self):
        resources = ['A', 'B', 'C']
        for r in resources:
            resource_extend.register_funcs(r, (lambda x: x, ))

        for r in resources:
            self.assertIsNotNone(resource_extend.get_funcs(r))
    def test_apply_funcs(self):
        resources = ['A', 'B', 'C']
        callbacks = []

        def _cb(resp, db_obj):
            callbacks.append(resp)

        for r in resources:
            resource_extend.register_funcs(r, (_cb, ))

        for r in resources:
            resource_extend.apply_funcs(r, None, None)

        self.assertEqual(3, len(callbacks))
Exemple #4
0
    def test_fixture_backup(self):
        fake_methods = {'a': 'A', 'b': 'B'}
        orig_methods = resource_extend._resource_extend_functions
        self.assertNotEqual(fake_methods, orig_methods)

        db_fixture = fixture.DBResourceExtendFixture(
            extended_functions=fake_methods)
        db_fixture.setUp()

        resource_extend.register_funcs('C', (lambda x: x, ))
        self.assertNotEqual(orig_methods,
                            resource_extend._resource_extend_functions)

        db_fixture.cleanUp()
        self.assertEqual(orig_methods,
                         resource_extend._resource_extend_functions)
 def __init__(self):
     super(NuageApi, self).__init__()
     # Prepare default and shared netpartitions
     self._prepare_netpartitions()
     lib_db_resource_extend.register_funcs('security_groups',
                                           [self._extend_resource_dict])