def testSync(self):
    extra_number = PhoneNumber.objects.create(domain=self.domain, owner_doc_type='X', owner_id='owner1', phone_number='999123', verified=True, pending_verification=False, is_two_way=True)
    user = self.mobile_worker1
    self.assertEqual(PhoneNumber.by_domain(self.domain).count(), 1)
    user.phone_numbers = ['9990001']
    user.save()
    self.assertEqual(PhoneNumber.by_domain(self.domain).count(), 2)
    self.assertPhoneEntries(user, ['9990001'])
    before = user.get_phone_entries()['9990001']
    user.phone_numbers = ['9990001', '9990002']
    user.save()
    self.assertEqual(PhoneNumber.by_domain(self.domain).count(), 3)
    self.assertPhoneEntries(user, ['9990001', '9990002'])
    after = user.get_phone_entries()['9990001']
    self.assertEqual(before.pk, after.pk)
    user.phone_numbers = ['9990002']
    user.save()
    self.assertEqual(PhoneNumber.by_domain(self.domain).count(), 2)
    self.assertPhoneEntries(user, ['9990002'])
    self.assertEqual(PhoneNumber.get_two_way_number('999123'), extra_number)
def testSync(self):
    extra_number = PhoneNumber.objects.create(domain=self.domain, owner_doc_type='X', owner_id='owner1', phone_number='999123', verified=True, pending_verification=False, is_two_way=True)
    user = self.mobile_worker1
    self.assertEqual(PhoneNumber.by_domain(self.domain).count(), 1)
    user.phone_numbers = ['9990001']
    user.save()
    self.assertEqual(PhoneNumber.by_domain(self.domain).count(), 2)
    self.assertPhoneEntries(user, ['9990001'])
    before = user.get_phone_entries()['9990001']
    user.phone_numbers = ['9990001', '9990002']
    user.save()
    self.assertEqual(PhoneNumber.by_domain(self.domain).count(), 3)
    self.assertPhoneEntries(user, ['9990001', '9990002'])
    after = user.get_phone_entries()['9990001']
    self.assertEqual(before.pk, after.pk)
    user.phone_numbers = ['9990002']
    user.save()
    self.assertEqual(PhoneNumber.by_domain(self.domain).count(), 2)
    self.assertPhoneEntries(user, ['9990002'])
    self.assertEqual(PhoneNumber.get_two_way_number('999123'), extra_number)