From: Roland Häder Date: Mon, 11 Sep 2023 19:53:11 +0000 (+0200) Subject: Continued: X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=65c01f04e7990278ff272f72e2fdd71cd35cfdfc;p=fba.git Continued: - instances.has_pending() raises an exception if domain is not registered yet - instances.update() checks is_registered() first, then has_pending() --- diff --git a/fba/models/instances.py b/fba/models/instances.py index 52d88f3..4a10f8b 100644 --- a/fba/models/instances.py +++ b/fba/models/instances.py @@ -96,10 +96,14 @@ def has_pending(domain: str) -> bool: logger.debug("domain='%s' - CALLED!", domain) domain_helper.raise_on(domain) + if not is_registered(domain): + raise ValueError(f"domain='{domain}' is not registered but function was invoked.") + has = False for key in _pending: logger.debug("key='%s',domain='%s',_pending[key]()=%d", key, domain, len(_pending[key])) if domain in _pending[key]: + logger.debug("domain='%s' at key='%s' has pending data ...", domain, key) has = True break @@ -109,10 +113,11 @@ def has_pending(domain: str) -> bool: def update(domain: str): logger.debug("domain='%s' - CALLED!", domain) domain_helper.raise_on(domain) - if not has_pending(domain): - raise Exception(f"domain='{domain}' has no pending instance data, but function invoked") - elif not is_registered(domain): + + if not is_registered(domain): raise Exception(f"domain='{domain}' cannot be updated while not being registered") + elif not has_pending(domain): + raise Exception(f"domain='{domain}' has no pending instance data, but function invoked") logger.debug("Updating instance data for domain='%s' ...", domain) sql_string = "" @@ -278,6 +283,8 @@ def set_success(domain: str): def is_registered(domain: str, skip_raise = False) -> bool: logger.debug("domain='%s',skip_raise='%s' - CALLED!", domain, skip_raise) + domain_helper.raise_on(domain) + if not isinstance(skip_raise, bool): raise ValueError(f"skip_raise[]='{type(skip_raise)}' is not type of 'bool'") @@ -341,8 +348,6 @@ def deobfuscate(char: str, domain: str, blocked_hash: str = None) -> tuple: raise ValueError(f"char='{char}' not found in domain='{domain}' but function invoked") elif not isinstance(domain, str): raise ValueError(f"Parameter domain[]='{type(domain)}'") - elif domain == "": - raise ValueError("Parameter 'domain' is empty") elif not isinstance(blocked_hash, str) and blocked_hash is not None: raise ValueError(f"Parameter blocked_hash[]='{type(blocked_hash)}' is not of type 'str'")