def _test_cache_clear(self, refresh_each_time=True):
    "\n        A test to make sure that the cache clearing is working as expected.\n        This test gets run twice using different values for refresh_each_time.\n        This makes sure that the mechanism used for clearing the cache works\n        whether you're updating a document you just saved or getting a document\n        fresh from the database and updating it.\n        "
    created = PhoneNumber(domain='phone-number-test', owner_doc_type='CommCareCase', owner_id='fake-owner-id1', phone_number='99912341234', backend_id=None, ivr_backend_id=None, verified=True, pending_verification=False, is_two_way=True, contact_last_modified=datetime.utcnow())
    created.save()
    self.assertNoMatch('99952345234', '52345234', 'fake-owner-id2')
    self.assertMatch(created, '99912341234', '12341234', 'fake-owner-id1')
    if refresh_each_time:
        created = PhoneNumber.objects.get(pk=created.pk)
    created.phone_number = '99952345234'
    created.save()
    self.assertNoMatch('99912341234', '12341234', 'fake-owner-id2')
    self.assertMatch(created, '99952345234', '52345234', 'fake-owner-id1')
    if refresh_each_time:
        created = PhoneNumber.objects.get(pk=created.pk)
    created.owner_id = 'fake-owner-id2'
    created.save()
    self.assertNoMatch('99912341234', '12341234', 'fake-owner-id1')
    self.assertMatch(created, '99952345234', '52345234', 'fake-owner-id2')
    created.delete()
    self.assertNoMatch('99952345234', '52345234', 'fake-owner-id2')
A test to make sure that the cache clearing is working as expected.
This test gets run twice using different values for refresh_each_time.
This makes sure that the mechanism used for clearing the cache works
whether you're updating a document you just saved or getting a document
fresh from the database and updating it.
def _test_cache_clear(self, refresh_each_time=True):
    "\n        A test to make sure that the cache clearing is working as expected.\n        This test gets run twice using different values for refresh_each_time.\n        This makes sure that the mechanism used for clearing the cache works\n        whether you're updating a document you just saved or getting a document\n        fresh from the database and updating it.\n        "
    created = PhoneNumber(domain='phone-number-test', owner_doc_type='CommCareCase', owner_id='fake-owner-id1', phone_number='99912341234', backend_id=None, ivr_backend_id=None, verified=True, pending_verification=False, is_two_way=True, contact_last_modified=datetime.utcnow())
    created.save()
    self.assertNoMatch('99952345234', '52345234', 'fake-owner-id2')
    self.assertMatch(created, '99912341234', '12341234', 'fake-owner-id1')
    if refresh_each_time:
        created = PhoneNumber.objects.get(pk=created.pk)
    created.phone_number = '99952345234'
    created.save()
    self.assertNoMatch('99912341234', '12341234', 'fake-owner-id2')
    self.assertMatch(created, '99952345234', '52345234', 'fake-owner-id1')
    if refresh_each_time:
        created = PhoneNumber.objects.get(pk=created.pk)
    created.owner_id = 'fake-owner-id2'
    created.save()
    self.assertNoMatch('99912341234', '12341234', 'fake-owner-id1')
    self.assertMatch(created, '99952345234', '52345234', 'fake-owner-id2')
    created.delete()
    self.assertNoMatch('99952345234', '52345234', 'fake-owner-id2')