Esempio n. 1
0
    def assert_owner_temporarily_dirty(self):
        """
        Changing any case's owner makes the previous owner ID temporarily dirty, to allow
        syncs to happen, but the should become clean on a rebuild.

        This checks that workflow and rebuilds the cleanliness flag.
        """
        self.assertFalse(self.owner_cleanliness.is_clean)
        set_cleanliness_flags(self.domain, self.owner_id, force_full=True)
        self.assertTrue(self.owner_cleanliness.is_clean)
Esempio n. 2
0
    def assert_owner_temporarily_dirty(self):
        """
        Changing any case's owner makes the previous owner ID temporarily dirty, to allow
        syncs to happen, but the should become clean on a rebuild.

        This checks that workflow and rebuilds the cleanliness flag.
        """
        self.assertFalse(self.owner_cleanliness.is_clean)
        set_cleanliness_flags(self.domain, self.owner_id, force_full=True)
        self.assertTrue(self.owner_cleanliness.is_clean)
Esempio n. 3
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)
Esempio n. 4
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)
Esempio n. 5
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))
Esempio n. 6
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))
Esempio n. 7
0
 def test_set_bad_owner_ids(self):
     test_cases = [None, '', 'something-too-long' * 10]
     for invalid_owner in test_cases:
         with self.assertRaises(InvalidOwnerIdError):
             set_cleanliness_flags('whatever', invalid_owner)
Esempio n. 8
0
 def test_set_bad_domains(self):
     test_cases = [None, '', 'something-too-long' * 10]
     for invalid_domain in test_cases:
         with self.assertRaises(InvalidDomainError):
             set_cleanliness_flags(invalid_domain, 'whatever')
Esempio n. 9
0
 def test_set_flag_clean_no_data(self):
     unused_owner_id = uuid.uuid4().hex
     set_cleanliness_flags(self.domain, unused_owner_id)
     self.assertTrue(OwnershipCleanlinessFlag.objects.get(owner_id=unused_owner_id).is_clean)
Esempio n. 10
0
 def test_set_bad_owner_ids(self):
     test_cases = [None, '', 'something-too-long' * 10]
     for invalid_owner in test_cases:
         with self.assertRaises(InvalidOwnerIdError):
             set_cleanliness_flags('whatever', invalid_owner)
Esempio n. 11
0
 def test_set_bad_domains(self):
     test_cases = [None, '', 'something-too-long' * 10]
     for invalid_domain in test_cases:
         with self.assertRaises(InvalidDomainError):
             set_cleanliness_flags(invalid_domain, 'whatever')
Esempio n. 12
0
 def test_set_flag_clean_no_data(self):
     unused_owner_id = uuid.uuid4().hex
     set_cleanliness_flags(self.domain, unused_owner_id)
     self.assertTrue(OwnershipCleanlinessFlag.objects.get(owner_id=unused_owner_id).is_clean)