def test_valid_branch_name(self):
        test_helpers.deployHookKit('test_script_branch_name_filter.json')

        test_helpers.runCommandInPath('git checkout -b 123-joe-bar',
                                      test_helpers.repo_checkout)

        self.assertTrue(test_helpers.gitPush('origin 123-joe-bar'),
                        'Pushing a valid branch name')
    def test_invalid_branch_name(self):
        test_helpers.deployHookKit('test_script_branch_name_filter.json')

        test_helpers.runCommandInPath('git checkout -b abc-foo-bar',
                                      test_helpers.repo_checkout)

        self.assertFalse(test_helpers.gitPush('origin abc-foo-bar'),
                         'Pushing an invalid branch name')
    def test_invalid_branch_name(self):
        test_helpers.deployHookKit('test_script_branch_name_filter.json')

        test_helpers.runCommandInPath('git checkout -b abc-foo-bar',
                                      test_helpers.repo_checkout)

        self.assertFalse(test_helpers.gitPush('origin abc-foo-bar'),
                         'Pushing an invalid branch name')
Example #4
0
 def test_push_to_branch(self):
     test_helpers.deployHookKit('test_hookkit_config.json')
     os.system('echo A >> ' + test_helpers.repo_checkout + '/testfile.py')
     test_helpers.runCommandInPath('git checkout -b test_branch',
                                   test_helpers.repo_checkout)
     test_helpers.gitCommitWithMessage('foo bar commit to push to a branch')
     self.assertTrue(test_helpers.gitPush('origin test_branch'),
                     'Push to a branch should work.')
Example #5
0
    def test_push_tag(self):
        test_helpers.deployHookKit('test_hookkit_config.json')
        test_helpers.runCommandInPath('git tag test_tag',
                                      test_helpers.repo_checkout)
        result = test_helpers.runCommandInPath('git push --tags',
                                               test_helpers.repo_checkout)

        self.assertTrue(result, "Pushing tags should work")
    def test_valid_branch_name(self):
        test_helpers.deployHookKit('test_script_branch_name_filter.json')

        test_helpers.runCommandInPath('git checkout -b 123-joe-bar',
                                      test_helpers.repo_checkout)

        self.assertTrue(test_helpers.gitPush('origin 123-joe-bar'),
                        'Pushing a valid branch name')
    def test_commit_merged_from_branch(self):
        test_helpers.deployHookKit(self.CONFIG_FILE)

        test_helpers.runCommandInPath('git checkout -b test',
                                      test_helpers.repo_checkout)

        os.system(
            ('echo foo >> ' + test_helpers.repo_checkout + '/testfile.py'))

        test_helpers.gitCommitWithMessage("I'm going to be a dupe commit!")

        test_helpers.runCommandInPath('git checkout master',
                                      test_helpers.repo_checkout)

        os.system(
            ('echo foo >> ' + test_helpers.repo_checkout + '/testfile2.py'))

        test_helpers.runCommandInPath('git add testfile2.py',
                                      test_helpers.repo_checkout)

        test_helpers.gitCommitWithMessage("I'm going to be a dupe commit!")

        test_helpers.runCommandInPath('git merge test',
                                      test_helpers.repo_checkout)

        result = test_helpers.gitPush()
        self.assertFalse(result,
                         "Pushing sha1 that already exists in other branch")
    def test_commit_merged_from_branch(self):
        test_helpers.deployHookKit(self.CONFIG_FILE)

        test_helpers.runCommandInPath('git checkout -b test',
                                      test_helpers.repo_checkout)

        os.system(('echo foo >> ' + test_helpers.repo_checkout +
                   '/testfile.py'))

        test_helpers.gitCommitWithMessage("I'm going to be a dupe commit!")

        test_helpers.runCommandInPath('git checkout master',
                                      test_helpers.repo_checkout)

        os.system(('echo foo >> ' + test_helpers.repo_checkout +
                   '/testfile2.py'))

        test_helpers.runCommandInPath('git add testfile2.py',
                                      test_helpers.repo_checkout)

        test_helpers.gitCommitWithMessage("I'm going to be a dupe commit!")

        test_helpers.runCommandInPath('git merge test',
                                      test_helpers.repo_checkout)

        result = test_helpers.gitPush()
        self.assertFalse(result,
                         "Pushing sha1 that already exists in other branch")
    def test_invalid_code_that_shouldnt_be_scanned(self):
        test_helpers.deployHookKit('test_script_file_checker_config.json')

        os.system(('echo "    print "invalid indent - nobody checks it"" >> ' +
                  test_helpers.repo_checkout + '/testfile.cpp'))

        test_helpers.runCommandInPath('git add testfile.cpp',
                                      test_helpers.repo_checkout)

        test_helpers.gitCommitWithMessage('Testing File Checker with a '
                                          'file it should ignore')

        self.assertTrue(test_helpers.gitPush(),
                        "Pushing a badly formatted file "
                        "which shouldn't be scanned")
Example #10
0
    def test_invalid_code_that_shouldnt_be_scanned(self):
        test_helpers.deployHookKit('test_script_file_checker_config.json')

        os.system(('echo "    print "invalid indent - nobody checks it"" >> ' +
                   test_helpers.repo_checkout + '/testfile.cpp'))

        test_helpers.runCommandInPath('git add testfile.cpp',
                                      test_helpers.repo_checkout)

        test_helpers.gitCommitWithMessage('Testing File Checker with a '
                                          'file it should ignore')

        self.assertTrue(
            test_helpers.gitPush(), "Pushing a badly formatted file "
            "which shouldn't be scanned")
    def test_commit_already_exists_in_other_branch(self):
        test_helpers.deployHookKit(self.CONFIG_FILE)
        os.system(('echo foo >> ' + test_helpers.repo_checkout +
                   '/testfile.py'))

        test_helpers.gitCommitWithMessage("I'm a valid commit!")
        test_helpers.gitPush()

        test_helpers.runCommandInPath('git checkout -b test',
                                      test_helpers.repo_checkout)

        result = test_helpers.runCommandInPath('git push origin test',
                                               test_helpers.repo_checkout)

        self.assertTrue(result,
                        "Pushing sha1 that already exists in other branch")
    def test_commit_already_exists_in_other_branch(self):
        test_helpers.deployHookKit(self.CONFIG_FILE)
        os.system(
            ('echo foo >> ' + test_helpers.repo_checkout + '/testfile.py'))

        test_helpers.gitCommitWithMessage("I'm a valid commit!")
        test_helpers.gitPush()

        test_helpers.runCommandInPath('git checkout -b test',
                                      test_helpers.repo_checkout)

        result = test_helpers.runCommandInPath('git push origin test',
                                               test_helpers.repo_checkout)

        self.assertTrue(result,
                        "Pushing sha1 that already exists in other branch")
Example #13
0
    def test_invalid_code_in_blacklisted_dir(self):
        test_helpers.deployHookKit('test_script_file_checker_config.json')

        os.system('mkdir ' + test_helpers.repo_checkout + '/blacklist')

        os.system(('echo "   print "invalid indent makes snakes cry"" >> ' +
                   test_helpers.repo_checkout + '/blacklist/testfile.py'))

        test_helpers.runCommandInPath('git add blacklist/testfile.py',
                                      test_helpers.repo_checkout)

        test_helpers.gitCommitWithMessage("Testing File Checker with an "
                                          "invalid file in blacklist dir")

        self.assertTrue(
            test_helpers.gitPush(), "Pushing a badly formatted Python file in"
            " a blacklisted directory should work")
    def test_invalid_code_in_blacklisted_dir(self):
        test_helpers.deployHookKit('test_script_file_checker_config.json')

        os.system('mkdir ' + test_helpers.repo_checkout + '/blacklist')

        os.system(('echo "   print "invalid indent makes snakes cry"" >> ' +
                  test_helpers.repo_checkout + '/blacklist/testfile.py'))

        test_helpers.runCommandInPath('git add blacklist/testfile.py',
                                      test_helpers.repo_checkout)

        test_helpers.gitCommitWithMessage("Testing File Checker with an "
                                          "invalid file in blacklist dir")

        self.assertTrue(test_helpers.gitPush(),
                        "Pushing a badly formatted Python file in"
                        " a blacklisted directory should work")
    def test_move_valid_code(self):
        test_helpers.deployHookKit('test_script_file_checker_config.json')

        os.system(('echo "print "valid indentation rocks"" >> ' +
                  test_helpers.repo_checkout + '/testfile.py'))

        test_helpers.gitCommitWithMessage('Testing File Checker with '
                                          'a valid file')

        test_helpers.gitPush()

        test_helpers.runCommandInPath('git mv testfile.py testfile2.py',
                                      test_helpers.repo_checkout)

        test_helpers.gitCommitWithMessage('Testing File Checker with '
                                          'moving a valid file')

        self.assertTrue(test_helpers.gitPush(),
                        'Pushing a well formatted Python file that was moved')
Example #16
0
    def test_move_valid_code(self):
        test_helpers.deployHookKit('test_script_file_checker_config.json')

        os.system(('echo "print "valid indentation rocks"" >> ' +
                   test_helpers.repo_checkout + '/testfile.py'))

        test_helpers.gitCommitWithMessage('Testing File Checker with '
                                          'a valid file')

        test_helpers.gitPush()

        test_helpers.runCommandInPath('git mv testfile.py testfile2.py',
                                      test_helpers.repo_checkout)

        test_helpers.gitCommitWithMessage('Testing File Checker with '
                                          'moving a valid file')

        self.assertTrue(test_helpers.gitPush(),
                        'Pushing a well formatted Python file that was moved')
    def test_move_and_edit_invalid_code(self):
        test_helpers.deployHookKit('test_script_file_checker_config.json')

        os.system(('echo "print "valid indentation rocks"" >> ' +
                  test_helpers.repo_checkout + '/testfile.py'))

        test_helpers.gitCommitWithMessage('Testing File Checker with '
                                          'a valid file')

        test_helpers.runCommandInPath('git mv testfile.py testfile2.py',
                                      test_helpers.repo_checkout)

        os.system(('echo "  print "invalid indentation makes me sad"" >> ' +
                  test_helpers.repo_checkout + '/testfile2.py'))

        test_helpers.gitCommitWithMessage('Testing File Checker with '
                                          'moving an invalid file')

        self.assertFalse(test_helpers.gitPush(),
                         'Pushing a move of a badly formatted Python file')
Example #18
0
    def test_move_and_edit_invalid_code(self):
        test_helpers.deployHookKit('test_script_file_checker_config.json')

        os.system(('echo "print "valid indentation rocks"" >> ' +
                   test_helpers.repo_checkout + '/testfile.py'))

        test_helpers.gitCommitWithMessage('Testing File Checker with '
                                          'a valid file')

        test_helpers.runCommandInPath('git mv testfile.py testfile2.py',
                                      test_helpers.repo_checkout)

        os.system(('echo "  print "invalid indentation makes me sad"" >> ' +
                   test_helpers.repo_checkout + '/testfile2.py'))

        test_helpers.gitCommitWithMessage('Testing File Checker with '
                                          'moving an invalid file')

        self.assertFalse(test_helpers.gitPush(),
                         'Pushing a move of a badly formatted Python file')
Example #19
0
    def setUp(self):
        # Let's set up a base repo
        repo_original = 'test_original_repo'
        os.mkdir(repo_original)
        test_helpers.runCommandInPath('git init', repo_original)
        test_helpers.runCommandInPath('touch testfile.py', repo_original)
        test_helpers.runCommandInPath('git add testfile.py', repo_original)
        test_helpers.runCommandInPath('git commit -a -m adding:testfile.py',
                                      repo_original)

        # Let's clone a server copy to work from in the future.
        test_helpers.runCommandInPath(('git clone --bare ' + repo_original +
                                       ' ' + test_helpers.repo_server), '.')
        shutil.rmtree(repo_original)
        test_helpers.runCommandInPath(
            ('git clone ' + test_helpers.repo_server + ' ' +
             test_helpers.repo_checkout), '.')
Example #20
0
 def test_push_delete_branch(self):
     self.test_push_to_branch()
     del_result = test_helpers.runCommandInPath('git push origin '
                                                ':test_branch',
                                                test_helpers.repo_checkout)
     self.assertTrue(del_result, "Push to delete branch should work")
Example #21
0
    def setUp(self):
        # Let's set up a base repo
        repo_original = 'test_original_repo'
        os.mkdir(repo_original)
        test_helpers.runCommandInPath('git init', repo_original)
        test_helpers.runCommandInPath('touch testfile.py', repo_original)
        test_helpers.runCommandInPath('git add testfile.py', repo_original)
        test_helpers.runCommandInPath('git commit -a -m adding:testfile.py',
                                      repo_original)

        # Let's clone a server copy to work from in the future.
        test_helpers.runCommandInPath(('git clone --bare ' + repo_original +
                                       ' ' + test_helpers.repo_server), '.')
        shutil.rmtree(repo_original)
        test_helpers.runCommandInPath(('git clone ' +
                                       test_helpers.repo_server +
                                       ' ' + test_helpers.repo_checkout), '.')