Ejemplo n.º 1
0
    def test_find_invalid_filenames(self):
        filenames = ['/tmp/outside_repo',
                     '%s/inexistent_file' % self.root,
                     '%s/directory_in_repo/' % self.root,
                     '%s/valid' % self.root]
        expected = {
            '/tmp/outside_repo': 'does not belong to repository',
            '%s/inexistent_file' % self.root: 'does not exist',
            '%s/directory_in_repo/' % self.root: ('Directories are not yet ' +
                                                  'supported'),
        }

        with mock.patch(
                'os.path.exists',
                side_effect=lambda filename: 'inexistent' not in filename), \
             mock.patch(
                'os.path.isdir',
                side_effect=lambda filename: 'directory' in filename):
            invalid_filenames = dict(
                gitlint.find_invalid_filenames(filenames, self.root))

        self.assertEqual(expected.keys(), invalid_filenames.keys())
        for filename in invalid_filenames:
            self.assertIn(filename, invalid_filenames[filename])
            self.assertIn(expected[filename], invalid_filenames[filename])
Ejemplo n.º 2
0
    def test_find_invalid_filenames(self):
        file_outside_repo = '/tmp/outside_repo'
        inexistent_file = os.path.join(self.root, 'inexistent_file')
        directory_in_repo = os.path.join(self.root, 'directory_in_repo')
        valid_file = os.path.join(self.root, 'valid')
        filenames = [
            file_outside_repo, inexistent_file, directory_in_repo, valid_file
        ]
        expected = {
            file_outside_repo: 'does not belong to repository',
            inexistent_file: 'does not exist',
            directory_in_repo: 'Directories are not yet supported',
        }

        self.fs.create_file(file_outside_repo)
        self.fs.create_dir(directory_in_repo)
        self.fs.create_file(valid_file)

        invalid_filenames = dict(
            gitlint.find_invalid_filenames(filenames, self.root))

        self.assertEqual(expected.keys(), invalid_filenames.keys())
        for filename in invalid_filenames:
            self.assertIn(filename, invalid_filenames[filename])
            self.assertIn(expected[filename], invalid_filenames[filename])
Ejemplo n.º 3
0
    def test_find_invalid_filenames(self):
        filenames = [
            '/tmp/outside_repo',
            '%s/inexistent_file' % self.root,
            '%s/directory_in_repo/' % self.root,
            '%s/valid' % self.root
        ]
        expected = {
            '/tmp/outside_repo':
            'does not belong to repository',
            '%s/inexistent_file' % self.root:
            'does not exist',
            '%s/directory_in_repo/' % self.root:
            ('Directories are not yet ' + 'supported'),
        }

        with mock.patch(
                'os.path.exists',
                side_effect=lambda filename: 'inexistent' not in filename), \
             mock.patch(
                'os.path.isdir',
                side_effect=lambda filename: 'directory' in filename):
            invalid_filenames = dict(
                gitlint.find_invalid_filenames(filenames, self.root))

        self.assertEqual(expected.keys(), invalid_filenames.keys())
        for filename in invalid_filenames:
            self.assertIn(filename, invalid_filenames[filename])
            self.assertIn(expected[filename], invalid_filenames[filename])
Ejemplo n.º 4
0
    def test_find_invalid_filenames(self):
        file_outside_repo = '/tmp/outside_repo'
        inexistent_file = os.path.join(self.root, 'inexistent_file')
        directory_in_repo = os.path.join(self.root, 'directory_in_repo')
        valid_file = os.path.join(self.root, 'valid')
        filenames = [
            file_outside_repo, inexistent_file, directory_in_repo, valid_file
        ]
        expected = {
            file_outside_repo: 'does not belong to repository',
            inexistent_file: 'does not exist',
            directory_in_repo: 'Directories are not yet supported',
        }

        self.fs.create_file(file_outside_repo)
        self.fs.create_dir(directory_in_repo)
        self.fs.create_file(valid_file)

        invalid_filenames = dict(
            gitlint.find_invalid_filenames(filenames, self.root))

        self.assertEqual(expected.keys(), invalid_filenames.keys())
        for filename in invalid_filenames:
            self.assertIn(filename, invalid_filenames[filename])
            self.assertIn(expected[filename], invalid_filenames[filename])