Example #1
0
    def test_hint_invalidation_extension_chain(self):
        other_owner_id = uuid.uuid4().hex
        self._owner_cleanliness_for_id(other_owner_id)
        host = CaseStructure(case_id=self.sample_case.case_id, attrs={'create': False})
        extension_1 = CaseStructure(
            case_id="extension1",
            attrs={'owner_id': UNOWNED_EXTENSION_OWNER_ID},
            indices=[
                CaseIndex(
                    host,
                    relationship=CASE_INDEX_EXTENSION,
                )
            ]
        )
        extension_2 = CaseStructure(
            case_id="extension2",
            attrs={'owner_id': other_owner_id},
            indices=[
                CaseIndex(
                    extension_1,
                    relationship=CASE_INDEX_EXTENSION,
                )
            ]
        )
        self.factory.create_or_update_case(extension_2)
        self.assert_owner_dirty()

        self._set_owner(extension_2.case_id, UNOWNED_EXTENSION_OWNER_ID)
        self.assertFalse(hint_still_valid(self.domain, self.owner_cleanliness.hint))
Example #2
0
    def test_hint_invalidation_extensions(self):
        other_owner_id = uuid.uuid4().hex
        [extension, host] = self.factory.create_or_update_case(
            CaseStructure(case_id='extension',
                          attrs={'owner_id': other_owner_id},
                          indices=[
                              CaseIndex(CaseStructure(case_id="host"),
                                        relationship=CASE_INDEX_EXTENSION)
                          ]))
        self.assert_owner_dirty()
        self.assertTrue(
            hint_still_valid(self.domain, self.owner_cleanliness.hint))

        self._set_owner(extension.case_id, UNOWNED_EXTENSION_OWNER_ID)
        self.assertFalse(
            hint_still_valid(self.domain, self.owner_cleanliness.hint))
Example #3
0
    def test_hint_invalidation_extension_chain(self):
        other_owner_id = uuid.uuid4().hex
        self._owner_cleanliness_for_id(other_owner_id)
        host = CaseStructure(case_id=self.sample_case.case_id, attrs={'create': False})
        extension_1 = CaseStructure(
            case_id="extension1",
            attrs={'owner_id': UNOWNED_EXTENSION_OWNER_ID},
            indices=[
                CaseIndex(
                    host,
                    relationship=CASE_INDEX_EXTENSION,
                )
            ]
        )
        extension_2 = CaseStructure(
            case_id="extension2",
            attrs={'owner_id': other_owner_id},
            indices=[
                CaseIndex(
                    extension_1,
                    relationship=CASE_INDEX_EXTENSION,
                )
            ]
        )
        self.factory.create_or_update_case(extension_2)
        self.assert_owner_dirty()

        self._set_owner(extension_2.case_id, UNOWNED_EXTENSION_OWNER_ID)
        self.assertFalse(hint_still_valid(self.domain, self.owner_cleanliness.hint))
Example #4
0
    def test_hint_invalidation_extensions(self):
        other_owner_id = uuid.uuid4().hex
        [extension, host] = self.factory.create_or_update_case(
            CaseStructure(
                case_id='extension',
                attrs={'owner_id': other_owner_id},
                indices=[
                    CaseIndex(
                        CaseStructure(case_id="host"),
                        relationship=CASE_INDEX_EXTENSION
                    )
                ]
            )
        )
        self.assert_owner_dirty()
        self.assertTrue(hint_still_valid(self.domain, self.owner_cleanliness.hint))

        self._set_owner(extension.case_id, UNOWNED_EXTENSION_OWNER_ID)
        self.assertFalse(hint_still_valid(self.domain, self.owner_cleanliness.hint))
Example #5
0
 def test_hint_invalidation(self):
     self.test_change_parent_owner_makes_dirty()
     self._set_owner(self.parent._id, self.owner_id)
     # after the submission the dirtiness flag should still be set
     # since it isn't invalidated right away
     self.assert_owner_dirty()
     # explicitly make sure the hint is no longer valid
     self.assertFalse(hint_still_valid(self.domain, self.owner_id, self.owner_cleanliness.hint))
     # reset the cleanliness flag and ensure it worked
     set_cleanliness_flags(self.domain, self.owner_id)
     self.assert_owner_clean()
     self.assertEqual(None, self.owner_cleanliness.hint)
Example #6
0
 def test_hint_invalidation(self):
     new_owner = uuid.uuid4().hex
     self._set_owner(self.parent.case_id, new_owner)
     self._set_owner(self.parent.case_id, self.owner_id)
     # after the submission the dirtiness flag should still be set
     # since it isn't invalidated right away
     self.assert_owner_dirty()
     # explicitly make sure the hint is no longer valid
     self.assertFalse(hint_still_valid(self.domain, self.owner_cleanliness.hint))
     # reset the cleanliness flag and ensure it worked
     set_cleanliness_flags(self.domain, self.owner_id)
     self.assert_owner_clean()
     self.assertEqual(None, self.owner_cleanliness.hint)
Example #7
0
 def _verify_set_cleanliness_flags(self):
     """
     Can be run at the end of any relevant test to check the current state of the
     OwnershipCleanliness object and verify that rebuilding it from scratch produces
     the same result
     """
     is_clean = self.owner_cleanliness.is_clean
     hint = self.owner_cleanliness.hint
     self.owner_cleanliness.delete()
     set_cleanliness_flags(self.domain, self.owner_id, force_full=True)
     new_cleanliness = OwnershipCleanlinessFlag.objects.get(owner_id=self.owner_id)
     self.assertEqual(is_clean, new_cleanliness.is_clean)
     self.assertEqual(hint, new_cleanliness.hint)
     if hint:
         self.assertTrue(hint_still_valid(self.domain, self.owner_id, hint))
Example #8
0
 def _verify_set_cleanliness_flags(self):
     """
     Can be run at the end of any relevant test to check the current state of the
     OwnershipCleanliness object and verify that rebuilding it from scratch produces
     the same result
     """
     is_clean = self.owner_cleanliness.is_clean
     hint = self.owner_cleanliness.hint
     self.owner_cleanliness.delete()
     set_cleanliness_flags(self.domain, self.owner_id, force_full=True)
     new_cleanliness = OwnershipCleanlinessFlag.objects.get(
         owner_id=self.owner_id)
     self.assertEqual(is_clean, new_cleanliness.is_clean)
     self.assertEqual(hint, new_cleanliness.hint)
     if hint:
         self.assertTrue(hint_still_valid(self.domain, self.owner_id, hint))