<commit_before>from django.test import TestCase
from corehq.apps.commtrack.tests.util import bootstrap_location_types
from corehq.apps.domain.shortcuts import create_domain
from corehq.apps.users.models import CommCareUser
from ..dbaccessors import (get_users_by_location_id, get_user_ids_by_location,
                           get_one_user_at_location, get_user_docs_by_location)
from .util import make_loc, delete_all_locations


class TestUsersByLocation(TestCase):
    @classmethod
    def setUpClass(cls):
        cls.domain = create_domain('test-domain')
        cls.domain.locations_enabled = True
        bootstrap_location_types(cls.domain.name)

        def make_user(name, location):
            user = CommCareUser.create(cls.domain.name, name, 'password')
            user.set_location(location)
            return user

        cls.meereen = make_loc('meereen', type='outlet', domain=cls.domain.name)
        cls.pentos = make_loc('pentos', type='outlet', domain=cls.domain.name)

        cls.varys = make_user('Varys', cls.pentos)
        cls.tyrion = make_user('Tyrion', cls.meereen)
        cls.daenerys = make_user('Daenerys', cls.meereen)

    @classmethod
    def tearDownClass(cls):
        cls.domain.delete()
        delete_all_locations()

    def test_get_users_by_location_id(self):
        users = get_users_by_location_id(self.meereen._id)
        self.assertItemsEqual([u._id for u in users],
                              [self.tyrion._id, self.daenerys._id])

    def test_get_user_ids_by_location(self):
        user_ids = get_user_ids_by_location(self.meereen._id)
        self.assertItemsEqual(user_ids, [self.tyrion._id, self.daenerys._id])

    def test_get_one_user_at_location(self):
        user = get_one_user_at_location(self.meereen._id)
        self.assertIn(user._id, [self.tyrion._id, self.daenerys._id])

    def test_get_user_docs_by_location(self):
        users = get_user_docs_by_location(self.meereen._id)
        import ipdb; ipdb.set_trace()
        self.assertItemsEqual([u['doc'] for u in users],
                              [self.tyrion.to_json(), self.daenerys.to_json()])<commit_msg>Don't debug in prod...<commit_after>from django.test import TestCase
from corehq.apps.commtrack.tests.util import bootstrap_location_types
from corehq.apps.domain.shortcuts import create_domain
from corehq.apps.users.models import CommCareUser
from ..dbaccessors import (get_users_by_location_id, get_user_ids_by_location,
                           get_one_user_at_location, get_user_docs_by_location)
from .util import make_loc, delete_all_locations


class TestUsersByLocation(TestCase):
    @classmethod
    def setUpClass(cls):
        cls.domain = create_domain('test-domain')
        cls.domain.locations_enabled = True
        bootstrap_location_types(cls.domain.name)

        def make_user(name, location):
            user = CommCareUser.create(cls.domain.name, name, 'password')
            user.set_location(location)
            return user

        cls.meereen = make_loc('meereen', type='outlet', domain=cls.domain.name)
        cls.pentos = make_loc('pentos', type='outlet', domain=cls.domain.name)

        cls.varys = make_user('Varys', cls.pentos)
        cls.tyrion = make_user('Tyrion', cls.meereen)
        cls.daenerys = make_user('Daenerys', cls.meereen)

    @classmethod
    def tearDownClass(cls):
        cls.domain.delete()
        delete_all_locations()

    def test_get_users_by_location_id(self):
        users = get_users_by_location_id(self.meereen._id)
        self.assertItemsEqual([u._id for u in users],
                              [self.tyrion._id, self.daenerys._id])

    def test_get_user_ids_by_location(self):
        user_ids = get_user_ids_by_location(self.meereen._id)
        self.assertItemsEqual(user_ids, [self.tyrion._id, self.daenerys._id])

    def test_get_one_user_at_location(self):
        user = get_one_user_at_location(self.meereen._id)
        self.assertIn(user._id, [self.tyrion._id, self.daenerys._id])

    def test_get_user_docs_by_location(self):
        users = get_user_docs_by_location(self.meereen._id)
        self.assertItemsEqual([u['doc'] for u in users],
                              [self.tyrion.to_json(), self.daenerys.to_json()])
{'fraction_non_alphanumeric': 0.10190185489551538, 'fraction_numerical': 0.0, 'mean_word_length': 3.164222873900293, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3010067', 'n_tokens_mistral': 1422, 'n_tokens_neox': 1390, 'n_words': 217}