def handle_conflict(key, action_1, client_1, action_2, client_2): print( "\n" 'Conflict for "{}". Which version would you like to keep?\n' " (1) {}{} updated at {} ({})\n" " (2) {}{} updated at {} ({})\n" " (d) View difference (requires the diff command)\n" " (X) Skip this file\n".format( key, client_1.get_uri(), key, action_1.get_remote_datetime(), action_1.state, client_2.get_uri(), key, action_2.get_remote_datetime(), action_2.state, ), file=sys.stderr, ) while True: choice = utils.get_input("Choice (default=skip): ") print("", file=sys.stderr) if choice == "d": show_diff(client_1, client_2, key) else: break if choice == "1": return Resolution.get_resolution(key, action_1, client_2, client_1) elif choice == "2": return Resolution.get_resolution(key, action_2, client_1, client_2)
def test_diff_not_found(self, which, capsys, local_client, s3_client): which.return_value = None diff.show_diff(local_client, s3_client, "something") out, err = capsys.readouterr() assert out == ( 'Missing required "diff" executable.\n' "Install this using your distribution's package manager\n")
def test_diff(self, call, local_client, s3_client): utils.set_local_contents(local_client, "something", 4000, "wow") utils.set_s3_contents(s3_client, "something", 3000, "nice") diff.show_diff(local_client, s3_client, "something") assert call.call_count == 2 assert call.call_args_list[0][0][0][0] == "diff" assert call.call_args_list[1][0][0][0] == "less"
def test_less_not_found(self, which, capsys, local_client, s3_client): def missing_less(value): return None if value == "less" else "something" which.side_effect = missing_less diff.show_diff(local_client, s3_client, "something") out, err = capsys.readouterr() assert out == ( 'Missing required "less" executable.\n' "Install this using your distribution's package manager\n")