def test_combinations(self):
        entries = ShellmarkEntries(path=tmp_file())
        entries.add_entry(mark='dir1', path=DIR1)
        entries.add_entry(mark='dir2', path=DIR2)
        entries.add_entry(mark='dir3', path=DIR3)
        self.assertEqual(entries.get_entries(mark='dir3')[0].path, DIR3)

        # Delete one entry
        entries.delete_entries(mark='dir2')
        self.assertEqual(entries.get_entries(mark='dir3')[0].path, DIR3)

        # Sort
        entries.sort(reverse=True)
        self.assertEqual(entries.get_entries(mark='dir3')[0].path, DIR3)

        # Update one entry
        entries.update_entries(old_mark='dir1', new_path=DIR2)
        self.assertEqual(entries.get_entries(mark='dir3')[0].path, DIR3)

        entries.write()

        content = entries.get_raw()
        self.assertEqual(
            content,
            'export DIR_dir3="{0}/dir3"\nexport DIR_dir1="{0}/dir2"\n'.format(
                TEST_PATH))
    def test_method_get_entries(self):
        entries = ShellmarkEntries(path=os.path.join('test', 'files', 'sdirs'))
        path = os.path.abspath(os.path.join('test', 'files', 'dir1'))

        result = entries.get_entries(mark='dir1')
        self.assertEqual(result[0].mark, 'dir1')

        result = entries.get_entries(path=path)
        self.assertEqual(result[0].mark, 'dir1')

        result = entries.get_entries(mark='dir1', path=path)
        self.assertEqual(result[0].mark, 'dir1')

        with self.assertRaises(ValueError) as cm:
            entries.get_entries(mark='dir2', path=path)
        self.assertIn('mark (dir2) and path', str(cm.exception))

        # Get an entry which doesn’t exist by mark.
        self.assertEqual(entries.get_entries(mark='lol'), [])

        # Get an entry which doesn’t exist by path.
        self.assertEqual(entries.get_entries(path='lol'), [])
 def test_method_update_entries(self):
     entries = ShellmarkEntries(path=os.path.join('test', 'files', 'sdirs'))
     entries.update_entries(old_mark='dir1', new_mark='new1')
     result = entries.get_entries(mark='new1')
     self.assertEqual(result[0].path, DIR1)