def _show_prompt(self, cfn, stack, data, allowed): """ Helper method to create colourised diff outut and prompt for update """ resp = cfn.get_template(stack)['GetTemplateResponse'] old_body = resp['GetTemplateResult']['TemplateBody'] diff = make_diff(old_body, data) if len(diff): print "Diff from previous:" print diff chkeys = get_changed_keys_from_templates(old_body, data) chkeys = [k for k in chkeys if not allowed.match(k)] print "Changed data:" for k in sorted(chkeys): print k answer = self._get_input("Continue? [Yn]: ") if answer.lower().startswith('n'): return False else: LOG.warning('No difference, not updating') return False return True
def test_make_diff_same_data(self): a = b = '[1, 2, 3]' assert_equals(utils.make_diff(a, b), '')
def test_make_diff_different_data(self): a = '{"a": [1, 2, 3]}' b = '{"a": [1, 2, 4]}' output = utils.make_diff(a, b) assert_equals(True, len(output) > 0)