<commit_before># coding=utf-8
from __future__ import unicode_literals

from dash.orgs.models import TaskState
from django.core.urlresolvers import reverse
from django.test.utils import override_settings
from mock import patch

from casepro.test import BaseCasesTest

from .models import Contact, Group, Field
from .tasks import pull_contacts


class ContactTest(BaseCasesTest):
    def setUp(self):
        super(ContactTest, self).setUp()

        self.ann = self.create_contact(self.unicef, '7b7dd838-4947-4e85-9b5c-0e8b1794080b', "Ann", [self.reporters],
                                       {'age': "32", 'state': "WA"})

    def test_save(self):
        # start with no data
        Contact.objects.all().delete()
        Group.objects.all().delete()
        Field.objects.all().delete()

        contact = Contact.objects.create(
            org=self.unicef,
            uuid="C-001",
            name="<NAME>",
            language="eng",
            is_stub=False,
            fields={'age': "34"},
            __data__groups=[("G-001", "Customers")],
            urns=["phone:0821234567"],
        )

        self.assertEqual(contact.uuid, "C-001")
        self.assertEqual(contact.name, "<NAME>")
        self.assertEqual(contact.language, "eng")
        self.assertEqual(contact.get_fields(), {"age": "34"})
        self.assertEqual(contact.urns, ["phone:0821234567"])

        customers = Group.objects.get(org=self.unicef, uuid="G-001", name="Customers")

        self.assertEqual(set(contact.groups.all()), {customers})

        contact = Contact.objects.select_related('org').prefetch_related('groups').get(uuid='C-001')<commit_msg>Change tests to check 'tel' urn rather than 'phone' urn<commit_after># coding=utf-8
from __future__ import unicode_literals

from dash.orgs.models import TaskState
from django.core.urlresolvers import reverse
from django.test.utils import override_settings
from mock import patch

from casepro.test import BaseCasesTest

from .models import Contact, Group, Field
from .tasks import pull_contacts


class ContactTest(BaseCasesTest):
    def setUp(self):
        super(ContactTest, self).setUp()

        self.ann = self.create_contact(self.unicef, '7b7dd838-4947-4e85-9b5c-0e8b1794080b', "Ann", [self.reporters],
                                       {'age': "32", 'state': "WA"})

    def test_save(self):
        # start with no data
        Contact.objects.all().delete()
        Group.objects.all().delete()
        Field.objects.all().delete()

        contact = Contact.objects.create(
            org=self.unicef,
            uuid="C-001",
            name="<NAME>",
            language="eng",
            is_stub=False,
            fields={'age': "34"},
            __data__groups=[("G-001", "Customers")],
            urns=["tel:0821234567"],
        )

        self.assertEqual(contact.uuid, "C-001")
        self.assertEqual(contact.name, "<NAME>")
        self.assertEqual(contact.language, "eng")
        self.assertEqual(contact.get_fields(), {"age": "34"})
        self.assertEqual(contact.urns, ["tel:0821234567"])

        customers = Group.objects.get(org=self.unicef, uuid="G-001", name="Customers")

        self.assertEqual(set(contact.groups.all()), {customers})

        contact = Contact.objects.select_related('org').prefetch_related('groups').get(uuid='C-001')
{'fraction_non_alphanumeric': 0.14268585131894485, 'fraction_numerical': 0.03896882494004796, 'mean_word_length': 2.7920454545454545, 'pattern_counts': {'":': 2, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5737587', 'n_tokens_mistral': 1089, 'n_tokens_neox': 997, 'n_words': 190}