Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_dup_keys():
with pytest.raises(rend.exc.RenderException):
ret = run_sls(['dupkeys'])
async def test_read_rend_exc(self, mock_hub: testing.MockHub):
'''
test heist.roster.init.read when a rend.exc is raised
'''
# Setup
roster = 'flat'
mock_hub.roster.flat.read.side_effect = rend.exc.RenderException("Jinja error '}'")
# Execute
assert not await heist.roster.init.read(mock_hub, roster)
# Verify
mock_hub.roster.flat.read.assert_called_once()
async def read(hub, roster: str) -> List[Dict[str, Any]]:
'''
Given the rosters to read in, the tgt and the tgt_type
'''
ret = []
try:
ready = await getattr(hub, f'roster.{roster}.read')()
except rend.exc.RenderException as exc:
log.critical(f'Could not render the {roster} roster, error: {exc.args[0]}')
return False
if not ready:
log.critical(f'The roster {roster} did not return data when rendered')
return False
if not isinstance(ready, dict):
log.critical(f'The roster {roster} is not formatted correctly')
return False
for id_, condition in ready.items():
if not isinstance(condition, dict):
log.critical(f'The roster {roster} is not formatted correctly.')
return False
if 'id' not in condition: