def test_verbose(self): cb = CallbackBase() result = {'item': 'some_item LEFTIN', '_ansible_verbose_always': 'chicane'} json_out = cb._dump_results(result) self.assertFalse('SENTINEL' in json_out) self.assertTrue('LEFTIN' in json_out)
def test_exception(self): cb = CallbackBase() result = {'item': 'some_item LEFTIN', 'exception': ['frame1', 'SENTINEL']} json_out = cb._dump_results(result) self.assertFalse('SENTINEL' in json_out) self.assertFalse('exception' in json_out) self.assertTrue('LEFTIN' in json_out)
def test_no_log(self): cb = CallbackBase() result = {'item': 'some_item', '_ansible_no_log': True, 'some_secrets': 'SENTINEL'} json_out = cb._dump_results(result) self.assertFalse('SENTINEL' in json_out) self.assertTrue('no_log' in json_out) self.assertTrue('output has been hidden' in json_out)
def test_mixed_keys(self): cb = CallbackBase() result = {3: 'pi', 'tau': 6} json_out = cb._dump_results(result) round_trip_result = json.loads(json_out) assert len(round_trip_result) == 2 assert '3' in round_trip_result assert 'tau' in round_trip_result assert round_trip_result['3'] == 'pi' assert round_trip_result['tau'] == 6
def test_diff(self): cb = CallbackBase() result = { 'item': 'some_item LEFTIN', 'diff': ['remove stuff', 'added LEFTIN'], '_ansible_verbose_always': 'chicane' } json_out = cb._dump_results(result) assert 'SENTINEL' not in json_out assert 'LEFTIN' in json_out
def test_exception(self): cb = CallbackBase() result = { 'item': 'some_item LEFTIN', 'exception': ['frame1', 'SENTINEL'] } json_out = cb._dump_results(result) assert 'SENTINEL' not in json_out assert 'exception' not in json_out assert 'LEFTIN' in json_out
def test_internal_keys(self): cb = CallbackBase() result = {'item': 'some_item', '_ansible_some_var': 'SENTINEL', 'testing_ansible_out': 'should_be_left_in LEFTIN', 'invocation': 'foo --bar whatever [some_json]', 'some_dict_key': {'a_sub_dict_for_key': 'baz'}, 'bad_dict_key': {'_ansible_internal_blah': 'SENTINEL'}, 'changed': True} json_out = cb._dump_results(result) self.assertFalse('"_ansible_' in json_out) self.assertFalse('SENTINEL' in json_out) self.assertTrue('LEFTIN' in json_out)