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_delete_entries_duplicates(self): entries = ShellmarkEntries(path=tmp_file()) entries.add_entry(mark='dir1', path=DIR1) entries.add_entry(mark='dir1', path=DIR1) entries.add_entry(mark='dir1', path=DIR1) self.assertEqual(len(entries.entries), 3) entries.delete_entries(mark='dir1') self.assertEqual(len(entries.entries), 0)
def test_property_changes(self): entries = ShellmarkEntries(path=os.path.join('test', 'files', 'sdirs')) self.assertEqual(entries.changes, []) entries.delete_entries(mark='dir1') self.assertEqual(entries.changes, [{ 'action': 'delete', 'mark': 'dir1', 'path': DIR1 }])
def test_method_delete_entries(self): entries = ShellmarkEntries(path=os.path.join('test', 'files', 'sdirs')) entries.delete_entries(mark='dir1') self.assertEqual(len(entries.entries), 2) entries.delete_entries(path=DIR2) self.assertEqual(len(entries.entries), 1) entries.delete_entries(mark='dir3', path=DIR3) self.assertEqual(len(entries.entries), 0) # Delete entries which don’t exist by mark. self.assertEqual(entries.delete_entries(mark='lol'), False) # Delete entries which don’t exist by path. self.assertEqual(entries.delete_entries(path='lol'), False)