def test_getattr_search_path_no_match(self): config = BaseConfig() config.search_path = ['_first', '_middle', '_last'] config._first = {} config._middle = {} config._last = {} self.assertEquals(config.foo, None)
def test_getattr_search_path_match_first(self): config = BaseConfig() config.search_path = ['_first', '_middle', '_last'] config._first = {'foo': 'bar'} config._middle = {} config._last = {} self.assertEquals(config.foo, 'bar')
def test_convert_connected_app(self): project_config = BaseProjectConfig( self.global_config, { "services": { "connected_app": { "attributes": { "callback_url": {}, "client_id": {}, "client_secret": {}, } } } }, ) keychain = self.keychain_class(project_config, self.key) app_config = { "callback_url": "http://localhost:8080/callback", "client_id": "CLIENT", "client_secret": "SECRET", } keychain.config["app"] = BaseConfig(app_config) keychain._convert_connected_app() self.assertEqual(app_config, keychain.get_service("connected_app").config)
def test_getattr_search_path_match_last(self): config = BaseConfig() config.search_path = ['_first', '_middle', '_last'] config._first = {} config._middle = {} config._last = {'foo': 'bar'} self.assertEquals(config.foo, 'bar')
def test_getattr_search_path_no_match(self): config = BaseConfig() config.search_path = ["_first", "_middle", "_last"] config._first = {} config._middle = {} config._last = {} self.assertEquals(config.foo, None)
def test_getattr_search_path_match_first(self): config = BaseConfig() config.search_path = ["_first", "_middle", "_last"] config._first = {"foo": "bar"} config._middle = {} config._last = {} self.assertEquals(config.foo, "bar")
def test_load_files__empty(self): dummy_keychain = BaseEncryptedProjectKeychain(self.project_config, self.key) os.makedirs( os.path.join(self.tempdir_home, ".cumulusci", self.project_name)) self._write_file( os.path.join(self.tempdir_home, "test.org"), dummy_keychain._encrypt_config(BaseConfig({"foo": "bar" })).decode("utf-8"), ) keychain = self.keychain_class(self.project_config, self.key) del keychain.config["orgs"] keychain._load_files(self.tempdir_home, ".org", "orgs") self.assertIn("foo", keychain.get_org("test").config)
def test_load_files__empty(self): dummy_keychain = BaseEncryptedProjectKeychain(self.project_config, self.key) os.makedirs(os.path.join(self.tempdir_home, ".cumulusci", self.project_name)) self._write_file( os.path.join(self.tempdir_home, "test.org"), dummy_keychain._encrypt_config(BaseConfig({"foo": "bar"})).decode("utf-8"), ) keychain = self.keychain_class(self.project_config, self.key) del keychain.config["orgs"] with mock.patch.object( self.keychain_class, "global_config_dir", Path(self.tempdir_home) ): keychain._load_orgs() self.assertIn("foo", keychain.get_org("test").config) self.assertEqual(keychain.get_org("test").keychain, keychain)
def test_getattr_default_child_missing_config(self): config = BaseConfig() config.config = {} config.defaults = {'foo__bar': 'default'} self.assertEquals(config.foo__bar, 'default')
def test_getattr_default_toplevel(self): config = BaseConfig() config.config = {"foo": "bar"} config.defaults = {"foo": "default"} self.assertEqual(config.foo, "bar")
def test_getattr_default_child(self): config = BaseConfig() config.config = {"foo": {"bar": "baz"}} config.defaults = {"foo__bar": "default"} self.assertEquals(config.foo__bar, "baz")
def test_getattr_child_key(self): config = BaseConfig() config.config = {'foo': {'bar': 'baz'}} self.assertEquals(config.foo__bar, 'baz')
def test_get_connected_app(self): keychain = self.keychain_class(self.project_config, self.key) keychain.app = keychain._encrypt_config(BaseConfig({})) app = keychain.get_connected_app() self.assertIsInstance(app, ConnectedAppOAuthConfig)
def test_getattr_child_parent_key_missing(self): config = BaseConfig() config.config = {} self.assertEquals(config.foo__bar, None)
def test_getattr_default_toplevel_missing_config(self): config = BaseConfig() config.config = {} config.defaults = {'foo': 'default'} self.assertEquals(config.foo, 'default')
def test_getattr_default_child_missing_config(self): config = BaseConfig() config.config = {} config.defaults = {"foo__bar": "default"} self.assertEqual(config.foo__bar, "default")
def test_getattr_default_toplevel(self): config = BaseConfig() config.config = {'foo': 'bar'} config.defaults = {'foo': 'default'} self.assertEquals(config.foo, 'bar')
def test_getattr_toplevel_key(self): config = BaseConfig() config.config = {'foo': 'bar'} self.assertEquals(config.foo, 'bar')
def test_getattr_default_child_missing_default(self): config = BaseConfig() config.config = {'foo': {'bar': 'baz'}} config.defaults = {} self.assertEquals(config.foo__bar, 'baz')
def test_getattr_default_toplevel_missing_config(self): config = BaseConfig() config.config = {} config.defaults = {"foo": "default"} self.assertEqual(config.foo, "default")
def test_getattr_default_child_missing_default(self): config = BaseConfig() config.config = {"foo": {"bar": "baz"}} config.defaults = {} self.assertEqual(config.foo__bar, "baz")
def test_getattr_toplevel_key(self): config = BaseConfig() config.config = {"foo": "bar"} self.assertEqual(config.foo, "bar")
def test_getattr_child_key(self): config = BaseConfig() config.config = {"foo": {"bar": "baz"}} self.assertEqual(config.foo__bar, "baz")
def test_getattr_default_toplevel_missing_default(self): config = BaseConfig() config.config = {"foo": "bar"} config.defaults = {} self.assertEquals(config.foo, "bar")
def test_getattr_empty_search_path(self): config = BaseConfig() config.search_path = [] self.assertEquals(config.foo, None)
def test_getattr_toplevel_key_missing(self): config = BaseConfig() config.config = {} self.assertEqual(config.foo, None)
def test_getattr_child_key_missing(self): config = BaseConfig() config.config = {"foo": {}} self.assertEqual(config.foo__bar, None)