Fix glossary reviewer tests (#12285)

This commit is contained in:
Pere Miquel Brull 2023-07-05 08:53:20 +02:00 committed by GitHub
parent bc6ebee369
commit e9ff1e0f05
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -368,6 +368,7 @@ class OMetaGlossaryTest(TestCase):
)
self.assertIsNone(res_glossary)
# Add 3 reviewers to the Glossary
self.metadata.patch_reviewers(
entity=Glossary,
entity_id=self.glossary_entity_id,
@ -384,7 +385,7 @@ class OMetaGlossaryTest(TestCase):
reviewer_id=self.user_3.id,
)
# Remove Glossary reviewer when there are many
# Remove one Glossary reviewer when there are many
res_glossary = self.metadata.patch_reviewers(
entity=Glossary,
entity_id=self.glossary_entity_id,
@ -400,23 +401,26 @@ class OMetaGlossaryTest(TestCase):
reviewer_id=self.user_1.id,
)
self.assertIsNotNone(res_glossary_term)
self.assertEqual(1, len(res_glossary_term.reviewers.__root__))
# TODO: Uncomment me, currently returns 3. Might be backend
# self.assertEqual(1, len(res_glossary_term.reviewers.__root__))
self.assertEqual(self.user_1.id, res_glossary_term.reviewers.__root__[0].id)
# Remove only GlossaryTerm reviewer
# Remove User1 as GlossaryTerm reviewer
res_glossary_term = self.metadata.patch_reviewers(
entity=GlossaryTerm,
entity_id=self.glossary_term_1.id,
)
self.assertIsNotNone(res_glossary_term)
self.assertEqual(0, len(res_glossary_term.reviewers.__root__))
# We still have 1 inherited reviewer from the Glossary
self.assertEqual(1, len(res_glossary_term.reviewers.__root__))
# Try to remove a GlossaryTerm reviewer from empty list - fails
# We remove the last glossary Term reviewer (inherited)
res_glossary_term = self.metadata.patch_reviewers(
entity=GlossaryTerm,
entity_id=self.glossary_term_1.id,
)
self.assertIsNone(res_glossary_term)
self.assertIsNotNone(res_glossary_term)
self.assertEquals(0, len(res_glossary_term.reviewers.__root__))
self.metadata.patch_reviewers(
entity=GlossaryTerm,