def test_new_text_has_correct_contact_when_contact_exists(self): """Test that incoming test gets matched to correct contact if contact already exists.""" new_contact = Contact() new_contact.number = "+11111111111" new_contact.name = "test" new_contact.save() self.client.post( reverse_lazy('text_hook'), { 'Body': 'ToCountry=US&ToState=&FromCity=SEATTLE&Body=Test&FromCountry=US&To=%2B1222222222&From=%2B11111111111&ApiVersion=2010-04-01' }) text = Text.objects.first() self.assertEqual(text.contact, new_contact)
def test_no_contact_is_added_when_text_from_contact_received(self): """Test that no new contact is added when receiving text from known number.""" new_contact = Contact() new_contact.number = "+11111111111" new_contact.name = "test" new_contact.save() contact_count = Contact.objects.count() self.client.post( reverse_lazy('text_hook'), { 'Body': 'ToCountry=US&ToState=&FromCity=SEATTLE&Body=Test&FromCountry=US&To=%2B1222222222&From=%2B11111111111&ApiVersion=2010-04-01' }) self.assertEqual(contact_count, Contact.objects.count())