change regluit.core.tests.BookLoaderTests.test_add_related to test whether every WorkRelation points back properly
parent
2e9ff2bf1c
commit
4405b4ee73
|
@ -194,13 +194,14 @@ class BookLoaderTests(TestCase):
|
||||||
self.assertTrue(edition.work.editions.count() > 9)
|
self.assertTrue(edition.work.editions.count() > 9)
|
||||||
self.assertTrue(edition.work.reverse_related.count() > 0)
|
self.assertTrue(edition.work.reverse_related.count() > 0)
|
||||||
|
|
||||||
# is edition.work found in the from_work of the to_work of edition.work?
|
# is edition.work found among the from_work of all the to_work of edition.work?
|
||||||
back_set = set()
|
back_point = True
|
||||||
to_works = [wr.to_work for wr in edition.work.works_related_from.all()]
|
to_works = [wr.to_work for wr in edition.work.works_related_from.all()]
|
||||||
for to_work in to_works:
|
for to_work in to_works:
|
||||||
back_set.update([wr1.from_work.id for wr1 in to_work.works_related_to.all()])
|
if edition.work.id not in [wr1.from_work.id for wr1 in to_work.works_related_to.all()]:
|
||||||
|
back_point = False
|
||||||
self.assertTrue(edition.work.id in back_set)
|
break
|
||||||
|
self.assertTrue(back_point)
|
||||||
|
|
||||||
|
|
||||||
def test_populate_edition(self):
|
def test_populate_edition(self):
|
||||||
|
|
Loading…
Reference in New Issue