@@ -0,0 +1,2244 @@
+# Licensed to the StackStorm, Inc ('StackStorm') under one or more%0A# contributor license agreements.  See the NOTICE file distributed with%0A# this work for additional information regarding copyright ownership.%0A# The ASF licenses this file to You under the Apache License, Version 2.0%0A# (the %22License%22); you may not use this file except in compliance with%0A# the License.  You may obtain a copy of the License at%0A#%0A#     http://www.apache.org/licenses/LICENSE-2.0%0A#%0A# Unless required by applicable law or agreed to in writing, software%0A# distributed under the License is distributed on an %22AS IS%22 BASIS,%0A# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.%0A# See the License for the specific language governing permissions and%0A# limitations under the License.%0A%0Aimport os%0A%0Aimport mock%0A%0Afrom st2common.content import utils as content_utils%0Afrom st2common.bootstrap.base import ResourceRegistrar%0Afrom st2common.persistence.pack import Pack%0Afrom st2common.persistence.pack import ConfigSchema%0A%0Afrom st2tests import DbTestCase%0Afrom st2tests import fixturesloader%0A%0A%0A__all__ = %5B%0A    'ResourceRegistrarTestCase'%0A%5D%0A%0APACK_PATH = os.path.join(fixturesloader.get_fixtures_base_path(), 'dummy_pack_1')%0A%0A%0Aclass ResourceRegistrarTestCase(DbTestCase):%0A    def test_register_packs(self):%0A        # Verify DB is empty%0A        pack_dbs = Pack.get_all()%0A        config_schema_dbs = ConfigSchema.get_all()%0A%0A        self.assertEqual(len(pack_dbs), 0)%0A        self.assertEqual(len(config_schema_dbs), 0)%0A%0A        registrar = ResourceRegistrar()%0A        registrar._pack_loader.get_packs = mock.Mock()%0A        registrar._pack_loader.get_packs.return_value = %7B'dummy_pack_1': PACK_PATH%7D%0A        packs_base_paths = content_utils.get_packs_base_paths()%0A        registrar.register_packs(base_dirs=packs_base_paths)%0A%0A        # Verify pack and schema have been registered%0A        pack_dbs = Pack.get_all()%0A        config_schema_dbs = ConfigSchema.get_all()%0A%0A        self.assertEqual(len(pack_dbs), 1)%0A        self.assertEqual(len(config_schema_dbs), 1)%0A%0A        self.assertEqual(pack_dbs%5B0%5D.name, 'dummy_pack_1')%0A        self.assertTrue('api_key' in config_schema_dbs%5B0%5D.attributes)%0A        self.assertTrue('api_secret' in config_schema_dbs%5B0%5D.attributes)%0A

Add tests for pack and config schema registrar.