mirror of
https://github.com/arsenetar/dupeguru.git
synced 2026-01-22 06:37:17 +00:00
Don't allow dupes from ref folders to step down from their ref position during reprioritization.
This commit is contained in:
@@ -416,6 +416,8 @@ class TestCaseDupeGuru_renameSelected:
|
||||
fp = open(str(p + 'foo bar 3'),mode='w')
|
||||
fp.close()
|
||||
files = fs.get_files(p)
|
||||
for f in files:
|
||||
f.is_ref = False
|
||||
matches = engine.getmatches(files)
|
||||
groups = engine.get_groups(matches)
|
||||
g = groups[0]
|
||||
|
||||
@@ -599,6 +599,16 @@ class TestCaseGroup:
|
||||
g.switch_ref(NamedObject('',True))
|
||||
assert o2 is g.ref
|
||||
|
||||
def test_switch_ref_from_ref_dir(self):
|
||||
# When the ref dupe is from a ref dir, switch_ref() does nothing
|
||||
o1 = no(with_words=True)
|
||||
o2 = no(with_words=True)
|
||||
o1.is_ref = True
|
||||
g = Group()
|
||||
g.add_match(get_match(o1, o2))
|
||||
g.switch_ref(o2)
|
||||
assert o1 is g.ref
|
||||
|
||||
def test_get_match_of(self):
|
||||
g = Group()
|
||||
for m in get_match_triangle():
|
||||
@@ -684,6 +694,15 @@ class TestCaseGroup:
|
||||
g.prioritize(key_func, tie_breaker)
|
||||
assert g.ref is o2
|
||||
|
||||
def test_prioritize_with_ref_dupe(self):
|
||||
# when the ref dupe of a group is from a ref dir, make it stay on top.
|
||||
g = get_test_group()
|
||||
o1, o2, o3 = g
|
||||
o1.is_ref = True
|
||||
o2.size = 2
|
||||
g.prioritize(lambda x: -x.size)
|
||||
assert g.ref is o1
|
||||
|
||||
def test_list_like(self):
|
||||
g = Group()
|
||||
o1,o2 = (NamedObject("foo",True),NamedObject("bar",True))
|
||||
|
||||
@@ -794,14 +794,4 @@ class TestCaseResultsRefFile:
|
||||
def test_stat_line(self):
|
||||
expected = '0 / 2 (0.00 B / 2.00 B) duplicates marked.'
|
||||
eq_(expected, self.results.stat_line)
|
||||
|
||||
def test_make_ref(self):
|
||||
d = self.results.groups[0].dupes[1] #non-ref
|
||||
r = self.results.groups[0].ref
|
||||
self.results.make_ref(d)
|
||||
expected = '0 / 1 (0.00 B / 1.00 B) duplicates marked.'
|
||||
eq_(expected, self.results.stat_line)
|
||||
self.results.make_ref(r)
|
||||
expected = '0 / 2 (0.00 B / 2.00 B) duplicates marked.'
|
||||
eq_(expected, self.results.stat_line)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user