示例#1
0
 def test_sync_full_name(self):
     name = 'Ricky Bowwood'
     self.user.set_full_name(name)
     sync_user_cases(self.user)
     case = get_case_by_domain_hq_user_id(TEST_DOMAIN, self.user._id, include_docs=True)
     self.assertIsNotNone(case)
     self.assertEquals(case.name, name)
示例#2
0
    def setUpClass(cls):
        domain_name = "cc_test_case_sharing"
        cls.domain = create_domain(domain_name)
        cls.supervisor = CommCareUser.create(domain_name, "supervisor@" + domain_name, "***")

        cls.domain.call_center_config.enabled = True
        cls.domain.call_center_config.case_owner_id = cls.supervisor.get_id
        cls.domain.call_center_config.case_type = "cc_flw"
        cls.domain.save()

        cls.user = CommCareUser.create(domain_name, "user@" + domain_name, "***")
        sync_user_cases(cls.user)

        cls.group = Group(domain=domain_name, name="case sharing group", case_sharing=True, users=[cls.user.user_id])
        cls.group.save()

        load_data(
            domain_name,
            cls.user.user_id,
            "not this user",
            cls.group.get_id,
            case_opened_by=cls.user.user_id,
            case_closed_by=cls.user.user_id,
        )

        # create one case of each type so that we get the indicators where there is no data for the period
        create_cases_for_types(domain_name, ["person", "dog"])
示例#3
0
    def setUpClass(cls):
        domain_name = 'cc_test_case_sharing'
        cls.domain = create_domain(domain_name)
        cls.supervisor = CommCareUser.create(domain_name, 'supervisor@' + domain_name, '***')

        cls.domain.call_center_config.enabled = True
        cls.domain.call_center_config.case_owner_id = cls.supervisor.get_id
        cls.domain.call_center_config.case_type = 'cc_flw'
        cls.domain.save()

        cls.user = CommCareUser.create(domain_name, 'user@' + domain_name, '***')
        sync_user_cases(cls.user)

        cls.group = Group(
            domain=domain_name,
            name='case sharing group',
            case_sharing=True,
            users=[cls.user.user_id]
        )
        cls.group.save()

        load_data(
            domain_name,
            cls.user.user_id,
            'not this user',
            cls.group.get_id,
            case_opened_by=cls.user.user_id,
            case_closed_by=cls.user.user_id)

        # create one case of each type so that we get the indicators where there is no data for the period
        create_cases_for_types(domain_name, ['person', 'dog'])
示例#4
0
 def test_sync(self):
     sync_user_cases(self.user)
     case = get_case_by_domain_hq_user_id(TEST_DOMAIN, self.user._id, include_docs=True)
     self.assertIsNotNone(case)
     self.assertEquals(case.name, self.user.username)
     self.assertEquals(case.username, self.user.raw_username)
     self.assertIsNotNone(case.language)
     self.assertIsNotNone(case.phone_number)
示例#5
0
    def test_sync_retired(self):
        sync_user_cases(self.user)
        case = get_case_by_domain_hq_user_id(TEST_DOMAIN, self.user._id, include_docs=True)
        self.assertIsNotNone(case)

        self.user.base_doc += DELETED_SUFFIX
        sync_user_cases(self.user)
        case = get_case_by_domain_hq_user_id(TEST_DOMAIN, self.user._id, include_docs=True)
        self.assertTrue(case.closed)
示例#6
0
    def test_sync_inactive(self):
        sync_user_cases(self.user)
        case = get_case_by_domain_hq_user_id(TEST_DOMAIN, self.user._id, include_docs=True)
        self.assertIsNotNone(case)

        self.user.is_active = False
        sync_user_cases(self.user)
        case = get_case_by_domain_hq_user_id(TEST_DOMAIN, self.user._id, include_docs=True)
        self.assertTrue(case.closed)
示例#7
0
 def test_sync_full_name(self):
     name = 'Ricky Bowwood'
     self.user.set_full_name(name)
     sync_user_cases(self.user)
     case = get_case_by_domain_hq_user_id(TEST_DOMAIN,
                                          self.user._id,
                                          include_docs=True)
     self.assertIsNotNone(case)
     self.assertEquals(case.name, name)
示例#8
0
 def test_sync_custom_user_data(self):
     self.user.user_data = {'': 'blank_key', 'blank_val': '', 'ok': 'good'}
     sync_user_cases(self.user)
     case = get_case_by_domain_hq_user_id(TEST_DOMAIN,
                                          self.user._id,
                                          include_docs=True)
     self.assertIsNotNone(case)
     self.assertEquals(case.blank_val, '')
     self.assertEquals(case.ok, 'good')
示例#9
0
 def test_sync(self):
     sync_user_cases(self.user)
     case = get_case_by_domain_hq_user_id(TEST_DOMAIN,
                                          self.user._id,
                                          include_docs=True)
     self.assertIsNotNone(case)
     self.assertEquals(case.name, self.user.username)
     self.assertEquals(case.username, self.user.raw_username)
     self.assertIsNotNone(case.language)
     self.assertIsNotNone(case.phone_number)
def create_domain_and_user(domain_name, username):
    domain = create_domain(domain_name)
    user = CommCareUser.create(domain_name, username, '***')

    domain.call_center_config.enabled = True
    domain.call_center_config.case_owner_id = user.user_id
    domain.call_center_config.case_type = 'cc_flw'
    domain.save()

    sync_user_cases(user)
    return domain, user
示例#11
0
 def test_sync_custom_user_data(self):
     self.user.user_data = {
         '': 'blank_key',
         'blank_val': '',
         'ok': 'good'
     }
     sync_user_cases(self.user)
     case = get_case_by_domain_hq_user_id(TEST_DOMAIN, self.user._id, include_docs=True)
     self.assertIsNotNone(case)
     self.assertEquals(case.blank_val, '')
     self.assertEquals(case.ok, 'good')
示例#12
0
def create_domain_and_user(domain_name, username):
    domain = create_domain(domain_name)
    user = CommCareUser.create(domain_name, username, "***")

    domain.call_center_config.enabled = True
    domain.call_center_config.case_owner_id = user.user_id
    domain.call_center_config.case_type = "cc_flw"
    domain.save()

    sync_user_cases(user)
    return domain, user
示例#13
0
    def test_sync_retired(self):
        sync_user_cases(self.user)
        case = get_case_by_domain_hq_user_id(TEST_DOMAIN,
                                             self.user._id,
                                             include_docs=True)
        self.assertIsNotNone(case)

        self.user.base_doc += DELETED_SUFFIX
        sync_user_cases(self.user)
        case = get_case_by_domain_hq_user_id(TEST_DOMAIN,
                                             self.user._id,
                                             include_docs=True)
        self.assertTrue(case.closed)
示例#14
0
    def test_sync_inactive(self):
        sync_user_cases(self.user)
        case = get_case_by_domain_hq_user_id(TEST_DOMAIN,
                                             self.user._id,
                                             include_docs=True)
        self.assertIsNotNone(case)

        self.user.is_active = False
        sync_user_cases(self.user)
        case = get_case_by_domain_hq_user_id(TEST_DOMAIN,
                                             self.user._id,
                                             include_docs=True)
        self.assertTrue(case.closed)
示例#15
0
 def test_sync_custom_user_data(self):
     self.user.user_data = {
         "": "blank_key",
         "blank_val": "",
         "ok": "good",
         "name with spaces": "ok",
         "8starts_with_a_number": "0",
         "xml_starts_with_xml": "0",
         "._starts_with_punctuation": "0",
     }
     sync_user_cases(self.user)
     case = get_case_by_domain_hq_user_id(TEST_DOMAIN, self.user._id, include_docs=True)
     self.assertIsNotNone(case)
     self.assertEquals(case.blank_val, "")
     self.assertEquals(case.ok, "good")
示例#16
0
def sync_user_cases_signal(sender, **kwargs):
    return sync_user_cases(kwargs["couch_user"])
示例#17
0
def sync_user_cases_signal(sender, **kwargs):
    return sync_user_cases(kwargs["couch_user"])