def test_cant_apply_changed_repo(): a_model = EditableGitModel(REPOSITORY_NAME) a_model.populate() os.chdir(REPOSITORY_NAME) run_command("echo new > new_file") run_command("git add new_file") command = commit("new input") msg_col = a_model.get_column("message") index = Index(0, msg_col) a_model.start_history_event() orig_msg = a_model.data(index) a_model.set_data(index, "whatever change") try: write_and_wait(a_model) write_faled = False except: write_failed = True a_model = EditableGitModel(REPOSITORY_NAME) a_model.populate() new_msg = a_model.data(index) prev_msg= a_model.data(Index(1, msg_col)) error = "The write didn't fail on a modified repository" assert (write_failed and new_msg == "new input\n" and prev_msg == orig_msg), error
def test_cant_apply_changed_repo(): a_model = EditableGitModel(REPOSITORY_NAME) a_model.populate() os.chdir(REPOSITORY_NAME) run_command("echo new > new_file") run_command("git add new_file") command = commit("new input") msg_col = a_model.get_column("message") index = Index(0, msg_col) a_model.start_history_event() orig_msg = a_model.data(index) a_model.set_data(index, "whatever change") try: write_and_wait(a_model) write_faled = False except: write_failed = True a_model = EditableGitModel(REPOSITORY_NAME) a_model.populate() new_msg = a_model.data(index) prev_msg = a_model.data(Index(1, msg_col)) error = "The write didn't fail on a modified repository" assert (write_failed and new_msg == "new input\n" and prev_msg == orig_msg), error
def test_field_has_changed(test_row, test_column, test_value): our_model = EditableGitModel(REPOSITORY_NAME) our_model.populate() # print "====================================== Before the write" # for row in xrange(our_model.row_count()): # print pretty_print_from_row(our_model, row) # print "=======================================================" index = Index(test_row, test_column) our_model.start_history_event() our_model.set_data(index, test_value) write_and_wait(our_model) new_model = GitModel(REPOSITORY_NAME) new_model.populate() new_model_value = new_model.data(index) # print "======================================= After the write" # for row in xrange(our_model.row_count()): # print pretty_print_from_row(new_model, row) # print "=======================================================" if test_column in (1, 2): assert new_model_value[0] == test_value[0] and \ new_model_value[1].tzname("") == test_value[1].tzname(""), \ "The %s field wasn't changed correctly" % \ AVAILABLE_CHOICES[test_column] else: assert new_model_value == test_value, \ "The %s field wasn't changed correctly" % \ AVAILABLE_CHOICES[test_column] for row in xrange(our_model.row_count()): for column in xrange(1, our_model.column_count()): if (row == test_row and column == test_column): continue index = Index(row, column) our_value = our_model.data(index) new_value = new_model.data(index) if column in (1, 2): our_value, tz = our_value # print our_value, tz.tzname(None) new_value, tz = new_value # print new_value, tz.tzname(None) assert our_value == new_value, \ "Something else has change: (%d, %d)\ncolumn:%s\n" % \ (row, column, AVAILABLE_CHOICES[column]) + \ "%s\n%s\n%s\n" % \ (AVAILABLE_CHOICES, pretty_print_from_row(our_model, row), pretty_print_from_row(new_model, row)) + \ "%s // %s" % (our_value, new_value)