示例#1
0
    def test_prints_message_when_modifying_file_before_last_existing_in_same_module(
            self):
        self.given_existing_files("module/", MIGRATION_PATH, "0.rb", "1.rb")
        self.given_file_modified_in_commit("module/" + MIGRATION_PATH + "0.rb")
        check_filenames(self.commit_details, self.repository_details)
        verify(sys.stderr).write("Error: The file \"%s\" may not be modified \
since later migrations exist (\"%s\").\n" %
                                 ("module/" + MIGRATION_PATH + "0.rb", "1.rb"))
示例#2
0
    def test_prints_help_message_when_failing(self):
        self.given_existing_files("module/", MIGRATION_PATH, "1.rb")
        self.given_file_added_in_commit("module/" + MIGRATION_PATH + "0.rb")
        check_filenames(self.commit_details, self.repository_details)
        verify(sys.stderr).write(
            'If you want to commit this anyway, \
include "%s" in the commit message.\n'
            % MIGRATION_SKIP_KEYWORD
        )
示例#3
0
    def test_prints_message_when_modifying_file_before_last_existing_in_same_module(self):
        self.given_existing_files("module/", MIGRATION_PATH, "0.rb", "1.rb")
        self.given_file_modified_in_commit("module/" + MIGRATION_PATH + "0.rb")
        check_filenames(self.commit_details, self.repository_details)
        verify(sys.stderr).write(
            'Error: The file "%s" may not be modified \
since later migrations exist ("%s").\n'
            % ("module/" + MIGRATION_PATH + "0.rb", "1.rb")
        )
示例#4
0
    def test_prints_message_when_adding_file_before_existing_in_same_module(self):
        self.given_existing_files("module/", MIGRATION_PATH, "1.rb")
        self.given_file_added_in_commit("module/" + MIGRATION_PATH + "0.rb")
        check_filenames(self.commit_details, self.repository_details)
        verify(sys.stderr).write(
            'Error: The added file "%s" must have a filename \
alphabetically after the existing "%s".\n'
            % ("module/" + MIGRATION_PATH + "0.rb", "1.rb")
        )
示例#5
0
    def test_prints_message_when_adding_file_before_existing_in_same_module(
            self):
        self.given_existing_files("module/", MIGRATION_PATH, "1.rb")
        self.given_file_added_in_commit("module/" + MIGRATION_PATH + "0.rb")
        check_filenames(self.commit_details, self.repository_details)
        verify(sys.stderr).write(
            "Error: The added file \"%s\" must have a filename \
alphabetically after the existing \"%s\".\n" %
            ("module/" + MIGRATION_PATH + "0.rb", "1.rb"))
for i in revisions(20, 30):
    cd = CommitDetails(REPO, i, test_mode=True)
    result = check_commit_message(cd)
    print "Result: %d" % result
    if i in (22, 26, 29,):
        assert result == 1
    else:
        assert result == 0

print_header("Testing ordered_filename_pre_commit")

for i in revisions(40, 56):
    cd = CommitDetails(REPO, i, test_mode=True)
    rd = RepositoryDetails(REPO, i, test_mode=True)
    result = check_filenames(cd, rd)
    print "Result: %d" % result
    if i in (45, 49,):
        assert result == 1
    elif i in (51, 52,): # 52 is a rename, without order change. Could be allowed
        assert result == 2
    else:
        assert result == 0

for i in revisions(50, 66):
    cd = CommitDetails(REPO, i, test_mode=True)
    result = fail_on_tag_changes(cd)
    print "Result: %d" % result
    if i in (60, 65, 66,):
        assert result == 1
    else:
示例#7
0
    print "Result: %d" % result
    if i in (
            22,
            26,
            29,
    ):
        assert result == 1
    else:
        assert result == 0

print_header("Testing ordered_filename_pre_commit")

for i in revisions(40, 56):
    cd = CommitDetails(REPO, i, test_mode=True)
    rd = RepositoryDetails(REPO, i, test_mode=True)
    result = check_filenames(cd, rd)
    print "Result: %d" % result
    if i in (
            45,
            49,
    ):
        assert result == 1
    elif i in (
            51,
            52,
    ):  # 52 is a rename, without order change. Could be allowed
        assert result == 2
    else:
        assert result == 0

for i in revisions(50, 66):
示例#8
0
 def number_of_errors_are(self, number_of_errors):
     self.assertEquals(number_of_errors, check_filenames(self.commit_details, self.repository_details))
示例#9
0
 def test_does_not_print_to_stderr_when_successful(self):
     self.given_file_added_in_commit("module/" + MIGRATION_PATH + "0.rb")
     check_filenames(self.commit_details, self.repository_details)
     verify(sys.stderr, times(0)).write(any())
示例#10
0
 def number_of_errors_are(self, number_of_errors):
     self.assertEquals(
         number_of_errors,
         check_filenames(self.commit_details, self.repository_details))
示例#11
0
    def test_prints_help_message_when_failing(self):
        self.given_existing_files("module/", MIGRATION_PATH, "1.rb")
        self.given_file_added_in_commit("module/" + MIGRATION_PATH + "0.rb")
        check_filenames(self.commit_details, self.repository_details)
        verify(sys.stderr).write("If you want to commit this anyway, \
include \"%s\" in the commit message.\n" % MIGRATION_SKIP_KEYWORD)
示例#12
0
 def test_does_not_print_to_stderr_when_successful(self):
     self.given_file_added_in_commit("module/" + MIGRATION_PATH + "0.rb")
     check_filenames(self.commit_details, self.repository_details)
     verify(sys.stderr, times(0)).write(any())