Example #1
0
    def test_get_untracked_files_with_same_filename_different_case(
            self, mock_os_walk):
        """ Test P4Clean differentiates untracked files with same filename but
        different case."""
        # This test cannot be ran under windows. System is case insensitive.
        if platform.system() == 'Windows':
            return

        # patch os.walk return value
        mock_os_walk.return_value = [("/path", [], [
            'test.log', 'TEST.log', 'readme.txt', 'README.txt', 'ReAdMe.TxT'
        ])]

        with patch.object(Perforce, 'info') as info_mock:
            # Mock Perforce.info() method
            info_mock.return_value = (2010, 'dummy')

            perforce = Perforce()
            # Mock _get_perforce_fstat
            perforce._get_perforce_fstat = Mock()
            perforce._get_perforce_fstat.return_value = \
                "... clientFile /path/readme.txt \n \
                ... clientFile /path/README.txt \n \
                ... clientFile /path/path2/code.c "

            # The test
            untracked_files = perforce.get_untracked_files("dummy")

        self.assertEqual(len(untracked_files), 3)
        self.assertTrue("/path/test.log" in untracked_files)
        self.assertTrue("/path/TEST.log" in untracked_files)
        self.assertTrue("/path/ReAdMe.TxT" in untracked_files)
Example #2
0
    def test_get_untracked_files_with_same_filename_different_case(self,
                                                                   mock_os_walk):
        """ Test P4Clean differentiates untracked files with same filename but
        different case."""
        # This test cannot be ran under windows. System is case insensitive.
        if platform.system() == 'Windows':
            return

        # patch os.walk return value
        mock_os_walk.return_value = [("/path", [], ['test.log',
                                                    'TEST.log',
                                                    'readme.txt',
                                                    'README.txt',
                                                    'ReAdMe.TxT'])]

        with patch.object(Perforce, 'info') as info_mock:
            # Mock Perforce.info() method
            info_mock.return_value = (2010, 'dummy')

            perforce = Perforce()
            # Mock _get_perforce_fstat
            perforce._get_perforce_fstat = Mock()
            perforce._get_perforce_fstat.return_value = \
                "... clientFile /path/readme.txt \n \
                ... clientFile /path/README.txt \n \
                ... clientFile /path/path2/code.c "

            # The test
            untracked_files = perforce.get_untracked_files("dummy")

        self.assertEqual(len(untracked_files), 3)
        self.assertTrue("/path/test.log" in untracked_files)
        self.assertTrue("/path/TEST.log" in untracked_files)
        self.assertTrue("/path/ReAdMe.TxT" in untracked_files)
Example #3
0
    def test_perforce_get_untracked_files(self, mock_os_walk):
        """ Test Perforce `get_untracked_files` method. """
        # patch os.walk return value
        mock_os_walk.return_value = [("/path", ['blarg', 'test'],
                                      ['test.log', 'newfile.c', 'newfile.h'])]

        with patch.object(Perforce, 'info') as info_mock:
            # Mock Perforce.info() method
            info_mock.return_value = (2010, 'dummy')
            perforce = Perforce()
            # Mock _get_perforce_fstat
            perforce._get_perforce_fstat = Mock()
            perforce._get_perforce_fstat.return_value = \
                "...clientFile /path/test.log \n \
                ... clientFile /path/blarg/file.txt \n \
                ... clientFile /path/path2/code.c "

            # The test
            untracked_files = perforce.get_untracked_files("dummy")

        self.assertEqual(len(untracked_files), 2)
        self.assertTrue(os.path.normpath("/path/newfile.c") in untracked_files)
        self.assertTrue(os.path.normpath("/path/newfile.h") in untracked_files)
Example #4
0
    def test_perforce_get_untracked_files(self, mock_os_walk):
        """ Test Perforce `get_untracked_files` method. """
        # patch os.walk return value
        mock_os_walk.return_value = [("/path", ['blarg', 'test'], ['test.log',
                                                                   'newfile.c',
                                                                   'newfile.h'])]

        with patch.object(Perforce, 'info') as info_mock:
            # Mock Perforce.info() method
            info_mock.return_value = (2010, 'dummy')
            perforce = Perforce()
            # Mock _get_perforce_fstat
            perforce._get_perforce_fstat = Mock()
            perforce._get_perforce_fstat.return_value = \
                "...clientFile /path/test.log \n \
                ... clientFile /path/blarg/file.txt \n \
                ... clientFile /path/path2/code.c "

            # The test
            untracked_files = perforce.get_untracked_files("dummy")

        self.assertEqual(len(untracked_files), 2)
        self.assertTrue(os.path.normpath("/path/newfile.c") in untracked_files)
        self.assertTrue(os.path.normpath("/path/newfile.h") in untracked_files)