Example #1
0
    def test_modified_files_tracked_only(self, check_output):
        check_output.return_value = os.linesep.join([
            'A docs/file1.txt', 'M data/file2.json', 'R file3.py',
            'C file4.js', '! file5.txt', '? untracked.txt', 'I ignored.txt',
            '  origin.txt'
        ]).encode('utf-8')

        self.assertEqual({
            '/home/user/repo/docs/file1.txt': 'A',
            '/home/user/repo/data/file2.json': 'M'
        }, hg.modified_files('/home/user/repo', tracked_only=True))
        check_output.assert_called_once_with(['hg', 'status'])
Example #2
0
 def test_modified_files(self):
     output = os.linesep.join([
         'A docs/file1.txt', 'M data/file2.json', 'R file3.py',
         'C file4.js', '! file5.txt', '? untracked.txt', 'I ignored.txt',
         '  origin.txt'
     ]).encode('utf-8')
     with mock.patch('subprocess.check_output',
                     return_value=output) as hg_call:
         self.assertEqual(
             {
                 '/home/user/repo/docs/file1.txt': 'A',
                 '/home/user/repo/data/file2.json': 'M',
                 '/home/user/repo/untracked.txt': '?'
             }, hg.modified_files('/home/user/repo'))
         hg_call.assert_called_once_with(['hg', 'status'])
Example #3
0
    def test_modified_files_with_commit(self, check_output):
        check_output.return_value = os.linesep.join([
            'A docs/file1.txt', 'M data/file2.json', 'R file3.py',
            'C file4.js', '! file5.txt', '? untracked.txt', 'I ignored.txt',
            '  origin.txt'
        ]).encode('utf-8')
        commit = '012012012012'

        self.assertEqual({
            '/home/user/repo/docs/file1.txt': 'A',
            '/home/user/repo/data/file2.json': 'M',
            '/home/user/repo/untracked.txt': '?'
        }, hg.modified_files('/home/user/repo', commit=commit))
        check_output.assert_called_once_with(
            ['hg', 'status', '--change=%s' % commit])
Example #4
0
 def test_modified_files(self):
     output = os.linesep.join(['A docs/file1.txt',
                               'M data/file2.json',
                               'R file3.py',
                               'C file4.js',
                               '! file5.txt',
                               '? untracked.txt',
                               'I ignored.txt',
                               '  origin.txt']).encode('utf-8')
     with mock.patch('subprocess.check_output',
                     return_value=output) as hg_call:
         self.assertEqual(
             {'/home/user/repo/docs/file1.txt': 'A',
              '/home/user/repo/data/file2.json': 'M',
              '/home/user/repo/untracked.txt': '?'},
             hg.modified_files('/home/user/repo'))
         hg_call.assert_called_once_with(
             ['hg', 'status'])
Example #5
0
 def test_modified_files_non_absolute_root(self):
     with self.assertRaises(AssertionError):
         hg.modified_files('foo/bar')
Example #6
0
 def test_modified_files_nothing_changed(self):
     output = b''
     with mock.patch('subprocess.check_output',
                     return_value=output) as hg_call:
         self.assertEqual({}, hg.modified_files('/home/user/repo'))
         hg_call.assert_called_once_with(['hg', 'status'])
Example #7
0
 def test_modified_files_non_absolute_root(self):
     with self.assertRaises(AssertionError):
         hg.modified_files('foo/bar')
Example #8
0
 def test_modified_files_nothing_changed(self, check_output):
     self.assertEqual({}, hg.modified_files('/home/user/repo'))
     check_output.assert_called_once_with(['hg', 'status'])
Example #9
0
 def test_modified_files_nothing_changed(self):
     output = b''
     with mock.patch('subprocess.check_output',
                     return_value=output) as hg_call:
         self.assertEqual({}, hg.modified_files('/home/user/repo'))
         hg_call.assert_called_once_with(['hg', 'status'])