diff options
author | Alex Shatov <alexs@att.com> | 2018-12-05 15:23:50 -0500 |
---|---|---|
committer | Alex Shatov <alexs@att.com> | 2018-12-05 15:23:50 -0500 |
commit | a39f4e82cef0414f510cf20e25864ac04cc8f055 (patch) | |
tree | 759f5a9f51c368456e8d8f3be65dac1951de0bd9 /tests/mock_settings.py | |
parent | 61fe1b8aa4f6e3c2388cbc573f655f60b4c1b5f3 (diff) |
4.5.0 policy-handler - multi change
DCAEGEN2-853:
- stop reporting the absence of policies or updates
as error - this is an expected result == INFO or WARNING
DCAEGEN2-903: preparation for TLS on the web-server of policy-handler
DCAEGEN2-930:
- configurable timeouts for http requests from policy-handler
- added configurable pinging on the web-socket to PDP
- added healthcheck info on the web-socket
- upgraded websocket-client lib to 0.53.0
DCAEGEN2-1017: fixed a bug on policy-filter matching
by filter_config_name
- refactored and enhanced the unit-tests
Change-Id: I111ddc57bb978554ef376cbf916965b6667dad9b
Signed-off-by: Alex Shatov <alexs@att.com>
Issue-ID: DCAEGEN2-853
Issue-ID: DCAEGEN2-903
Issue-ID: DCAEGEN2-930
Issue-ID: DCAEGEN2-1017
Diffstat (limited to 'tests/mock_settings.py')
-rw-r--r-- | tests/mock_settings.py | 41 |
1 files changed, 13 insertions, 28 deletions
diff --git a/tests/mock_settings.py b/tests/mock_settings.py index 7e05ecf..80a003e 100644 --- a/tests/mock_settings.py +++ b/tests/mock_settings.py @@ -31,31 +31,6 @@ from policyhandler.discovery import DiscoveryClient from policyhandler.onap.audit import Audit -class MonkeyHttpResponse(object): - """Monkey http reposne""" - def __init__(self, headers): - self.headers = headers or {} - - -class MonkeyedResponse(object): - """Monkey response""" - def __init__(self, full_path, res_json, json_body=None, headers=None): - self.full_path = full_path - self.req_json = json_body or {} - self.status_code = 200 - self.request = MonkeyHttpResponse(headers) - self.res = res_json - self.text = json.dumps(self.res) - - def json(self): - """returns json of response""" - return self.res - - def raise_for_status(self): - """ignoring""" - pass - - def _fix_discover_config(func): """the decorator""" if not func: @@ -83,20 +58,21 @@ class Settings(object): """init all locals""" _loaded = False logger = None - RUN_TS = datetime.utcnow().isoformat()[:-3] + 'Z' mock_config = None deploy_handler_instance_uuid = str(uuid.uuid4()) @staticmethod - @_fix_discover_config def init(): """init configs""" if Settings._loaded: + Settings.logger.info("testing policy_handler with config: %s", Config.discovered_config) return Settings._loaded = True Config.init_config() + Config.consul_url = "http://unit-test-consul:850000" + with open("tests/mock_config.json", 'r') as config_json: Settings.mock_config = json.load(config_json) @@ -107,7 +83,16 @@ class Settings(object): print("print is expected to be in the log") Settings.logger.info("========== run_policy_handler ==========") Audit.init(Config.system_name, Config.LOGGER_CONFIG_FILE_PATH) - audit = Audit(req_message="start testing policy handler") + Settings.rediscover_config() + + @staticmethod + @_fix_discover_config + def rediscover_config(updated_config=None): + """rediscover the config""" + if updated_config is not None: + Settings.mock_config = copy.deepcopy(updated_config) + + audit = Audit(req_message="rediscover_config") Config.discover(audit) |