MagicMock hides attribute errors:
```
self = <cephadm.CephadmContext object at 0x7f1121e62370>, name = 'config_json'
def __getattr__(self, name: str) -> Any:
if '_conf' in self.__dict__ and hasattr(self._conf, name):
return getattr(self._conf, name)
elif '_args' in self.__dict__ and hasattr(self._args, name):
return getattr(self._args, name)
else:
> return super().__getattribute__(name)
E AttributeError: 'CephadmContext' object has no attribute 'config_json'
```
Signed-off-by: Michael Fritch <mfritch@suse.com>
(cherry picked from commit
4a99b771a4a59671728e072bb27270bba8cb78c8)
f.write(keyring)
if daemon_type in Monitoring.components.keys():
- config_json: Dict[str, Any] = get_parm(ctx.config_json)
+ config_json: Dict[str, Any] = dict()
+ if 'config_json' in ctx:
+ config_json = get_parm(ctx.config_json)
# Set up directories specific to the monitoring component
config_dir = ''
daemon_type = 'prometheus'
uid, gid = 50, 50
daemon_id = 'home'
- ctx = mock.Mock()
+ ctx = cd.CephadmContext()
ctx.data_dir = '/somedir'
files = {
'files': {