Пример #1
0
 def create_sdirs_file():
     entries = create_sdirs([
         ['dirB', DIR2],
         ['dirC', DIR3],
         ['dirA', DIR1],
     ])
     return entries.path
Пример #2
0
 def create_sdirs_file():
     entries = create_sdirs([
         ['dir1', DIR1],
         ['dir2', DIR1],
         ['dir2', DIR2],
         ['dir3', DIR3],
     ])
     return entries.path
Пример #3
0
 def test_add_second_entry(self):
     entries = create_sdirs([['tmp1', DIR1]])
     mock_objects = self.mock_add('tmp2', DIR2, entries.path)
     self.assertEqual(len(mock_objects['entries'].entries), 2)
     mock_objects['module'].exit_json.assert_called_with(changed=True,
                                                         changes=[
                                                             {
                                                                 'action':
                                                                 'add',
                                                                 'mark':
                                                                 'tmp2',
                                                                 'path':
                                                                 DIR2
                                                             },
                                                         ])
Пример #4
0
 def test_duplicate_path(self):
     """update path with new mark"""
     entries = create_sdirs([['tmp1', DIR1]])
     mock_objects = self.mock_add('tmp2', DIR1, entries.path)
     self.assertEqual(len(mock_objects['entries'].entries), 1)
     mock_objects['module'].exit_json.assert_called_with(
         changed=True,
         changes=[
             {
                 'action': 'delete',
                 'mark': 'tmp1',
                 'path': DIR1
             },
             {
                 'action': 'add',
                 'mark': 'tmp2',
                 'path': DIR1
             },
         ])
Пример #5
0
    def test_casesensitivity(self):
        entries = create_sdirs([['tmp1', DIR1]])
        mock_objects = self.mock_add('TMP1', DIR2, entries.path)
        self.assertEqual(len(mock_objects['entries'].entries), 2)
        mock_objects['module'].exit_json.assert_called_with(changed=True,
                                                            changes=[
                                                                {
                                                                    'action':
                                                                    'add',
                                                                    'mark':
                                                                    'TMP1',
                                                                    'path':
                                                                    DIR2
                                                                },
                                                            ])

        mock_objects = self.mock_add('T M P 1', DIR1)
        mock_objects['module'].fail_json.assert_called_with(
            msg='Invalid mark string: “T M P 1”. Allowed characters for '
            'bookmark names are: “0-9a-zA-Z_”.')
Пример #6
0
 def test_same_entry_not_added(self):
     entries = create_sdirs([['tmp1', DIR1]])
     mock_objects = self.mock_add('tmp1', DIR1, entries.path)
     self.assertEqual(len(mock_objects['entries'].entries), 1)
     mock_objects['module'].exit_json.assert_called_with(changed=False)
Пример #7
0
 def create_sdirs_file():
     entries = create_sdirs([['home', HOME_DIR]])
     return entries.path