Skip to content

Commit

Permalink
Merge pull request #3220 from SFDO-Tooling/fix-property-lookups-on-co…
Browse files Browse the repository at this point in the history
…nfig

Fix property lookups on config objects
  • Loading branch information
TheBitShepherd authored May 31, 2022
2 parents 3c4e122 + 5436998 commit 11c3bde
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
9 changes: 6 additions & 3 deletions cumulusci/core/config/base_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def __getattr__(self, name):
)

assert not STRICT_GETATTR, message
return self.lookup(name)
return self.lookup(name, already_called_getattr=True)

@classmethod
@lru_cache
Expand All @@ -82,7 +82,7 @@ def _all_allowed_names(cls):
ret.update(d)
return ret

def lookup(self, name, default=None):
def lookup(self, name, default=None, already_called_getattr=False):
tree = name.split("__")
if name.startswith("_"):
raise AttributeError(f"Attribute {name} not found")
Expand All @@ -102,4 +102,7 @@ def lookup(self, name, default=None):
if value_found:
return value
else:
return self.defaults.get(name, default)
if not already_called_getattr and hasattr(self, name):
return getattr(self, name)
else:
return self.defaults.get(name, default)
5 changes: 5 additions & 0 deletions cumulusci/core/config/tests/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,11 @@ def test_repo_url_from_repo_info(self):
config._repo_info = {"url": "https://github.com/SFDO-Tooling/CumulusCI"}
assert config.repo_url == "https://github.com/SFDO-Tooling/CumulusCI"

def test_lookup_repo_branch(self):
config = BaseProjectConfig(UniversalConfig())
config._repo_info = {"branch": "foo-bar-baz"}
assert config.lookup("repo_branch") == "foo-bar-baz"

def test_repo_url_no_repo_root(self):
config = BaseProjectConfig(UniversalConfig())
with temporary_dir():
Expand Down

0 comments on commit 11c3bde

Please sign in to comment.