当前位置: 首页>>代码示例>>Python>>正文


Python indicator_sets.CallCenterIndicators类代码示例

本文整理汇总了Python中corehq.apps.callcenter.indicator_sets.CallCenterIndicators的典型用法代码示例。如果您正苦于以下问题:Python CallCenterIndicators类的具体用法?Python CallCenterIndicators怎么用?Python CallCenterIndicators使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了CallCenterIndicators类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_custom_indicators

    def test_custom_indicators(self, mock):
        mock.return_value = set()
        expected = {'totalCases': 0}
        expected.update(get_indicators('formsSubmitted', [3, 3, 9, 0], is_legacy=True))
        expected.update(get_indicators('forms_submitted', [3, 3, 9, 0]))
        expected.update(get_indicators('casesUpdated', [0, 0, 0, 0], is_legacy=True))
        expected.update(get_indicators('cases_total', [0, 0, 0, 0]))
        expected.update(get_indicators('cases_opened', [0, 0, 0, 0]))
        expected.update(get_indicators('cases_closed', [0, 0, 0, 0]))
        expected.update(get_indicators('cases_active', [0, 0, 0, 0]))

        # custom
        expected.update(get_indicators('motherForms', [3, 3, 9, 0], is_legacy=True))
        expected.update(get_indicators('childForms', [0, 0, 0, 0], is_legacy=True))
        expected.update(get_indicators('motherDuration', [3, 4, 4, 0], is_legacy=True))

        indicator_set = CallCenterIndicators(
            self.aarohi_domain.name,
            self.aarohi_domain.default_timezone,
            self.aarohi_domain.call_center_config.case_type,
            self.aarohi_user,
            custom_cache=locmem_cache,
        )
        self._test_indicators(
            self.aarohi_user,
            indicator_set.get_data(),
            expected
        )
开发者ID:dimagi,项目名称:commcare-hq,代码行数:28,代码来源:test_indicators.py

示例2: test_custom_indicators_limited

    def test_custom_indicators_limited(self, mock):
        expected = {}

        # custom
        expected.update(
            get_indicators('motherForms', [3, None, 9, None], is_legacy=True, limit_ranges=[WEEK0, MONTH0])
        )
        expected.update(
            get_indicators('childForms', [None, 0, None, None], is_legacy=True, limit_ranges=[WEEK1])
        )
        expected.update(
            get_indicators('motherDuration', [None, None, None, 0], is_legacy=True, limit_ranges=[MONTH1])
        )

        indicator_config = CallCenterIndicatorConfig()
        indicator_config.custom_form = [
            TypedIndicator(type='motherForms', date_range=WEEK0),
            TypedIndicator(type='motherForms', date_range=MONTH0),
            TypedIndicator(type='childForms', date_range=WEEK1),
            TypedIndicator(type='motherDuration', date_range=MONTH1),
        ]
        indicator_set = CallCenterIndicators(
            self.aarohi_domain.name,
            self.aarohi_domain.default_timezone,
            self.aarohi_domain.call_center_config.case_type,
            self.aarohi_user,
            custom_cache=locmem_cache,
            indicator_config=indicator_config
        )
        self._test_indicators(
            self.aarohi_user,
            indicator_set.get_data(),
            expected
        )
开发者ID:dimagi,项目名称:commcare-hq,代码行数:34,代码来源:test_indicators.py

示例3: test_standard_indicators

 def test_standard_indicators(self):
     indicator_set = CallCenterIndicators(self.cc_domain, self.cc_user, custom_cache=locmem_cache)
     self.assertEqual(
         set(indicator_set.user_to_case_map.keys()), set([self.cc_user.get_id, self.cc_user_no_data.get_id])
     )
     self.assertEqual(indicator_set.users_needing_data, set([self.cc_user.get_id, self.cc_user_no_data.get_id]))
     self.assertEqual(indicator_set.owners_needing_data, set([self.cc_user.get_id, self.cc_user_no_data.get_id]))
     self.check_cc_indicators(indicator_set.get_data(), expected_standard_indicators())
开发者ID:jmaina,项目名称:commcare-hq,代码行数:8,代码来源:test_indicators.py

示例4: test_no_cases_owned_by_user

 def test_no_cases_owned_by_user(self):
     """
     Test to verify that only data belonging to users managed by the supervisor is returned.
     """
     indicator_set = CallCenterIndicators(self.cc_domain, self.cc_user_no_data, custom_cache=locmem_cache)
     self.assertEqual(indicator_set.user_to_case_map.keys(), [])
     self.assertEqual(indicator_set.users_needing_data, set())
     self.assertEqual(indicator_set.owners_needing_data, set())
     self.assertEqual(indicator_set.get_data(), {})
开发者ID:jmaina,项目名称:commcare-hq,代码行数:9,代码来源:test_indicators.py

示例5: test_users_assigned_via_group

 def test_users_assigned_via_group(self):
     """
     Ensure that users who are assigned to the supervisor via a group are also included
     in final data set.
     """
     indicator_set = CallCenterIndicators(self.domain, self.supervisor, custom_cache=locmem_cache)
     self.assertEqual(indicator_set.user_to_case_map.keys(), [self.user.get_id])
     self.assertEqual(indicator_set.users_needing_data, set([self.user.get_id]))
     self.assertEqual(indicator_set.owners_needing_data, set([self.user.get_id]))
     self._test_indicators(self.user, indicator_set.get_data(), expected_standard_indicators())
开发者ID:jmaina,项目名称:commcare-hq,代码行数:10,代码来源:test_indicators.py

示例6: test_sync_log

    def test_sync_log(self):
        user_case = get_case_by_domain_hq_user_id(self.cc_domain.name, self.cc_user.get_id, include_docs=True)

        indicator_set = CallCenterIndicators(
            self.cc_domain, self.cc_user, custom_cache=locmem_cache, override_cases=[user_case]
        )
        self.assertEqual(indicator_set.user_to_case_map.keys(), [self.cc_user.get_id])
        self.assertEqual(indicator_set.users_needing_data, set([self.cc_user.get_id]))
        self.assertEqual(indicator_set.owners_needing_data, set([self.cc_user.get_id]))
        self._test_indicators(self.cc_user, indicator_set.get_data(), expected_standard_indicators())
开发者ID:jmaina,项目名称:commcare-hq,代码行数:10,代码来源:test_indicators.py

示例7: test_cases_owned_by_group

 def test_cases_owned_by_group(self):
     """
     Ensure that indicators include cases owned by a case sharing group the user is part of.
     """
     indicator_set = CallCenterIndicators(self.domain, self.supervisor, custom_cache=locmem_cache)
     self.assertEqual(indicator_set.user_to_case_map.keys(), [self.user.get_id])
     self.assertEqual(indicator_set.users_needing_data, set([self.user.get_id]))
     self.assertEqual(indicator_set.owners_needing_data, set([self.user.get_id, self.group.get_id]))
     expected = expected_standard_indicators()
     expected["totalCases"] = 0L  # no cases with user_id = self.user.get_id
     self._test_indicators(self.user, indicator_set.get_data(), expected)
开发者ID:jmaina,项目名称:commcare-hq,代码行数:11,代码来源:test_indicators.py

示例8: test_opened_closed

    def test_opened_closed(self):
        """
        Test that cases_closed and cases_opened indicators count based on the user that
        opened / closed the case and not the case owner.
        """
        indicator_set = CallCenterIndicators(self.domain, self.supervisor, custom_cache=locmem_cache)
        expected = expected_standard_indicators()

        # cases opened / closed by another user so expect 0
        for key in expected:
            if key.startswith("cases_opened") or key.startswith("cases_closed"):
                expected[key] = 0L
        self._test_indicators(self.user, indicator_set.get_data(), expected)
开发者ID:jmaina,项目名称:commcare-hq,代码行数:13,代码来源:test_indicators.py

示例9: test_users_assigned_via_group

 def test_users_assigned_via_group(self, mock):
     # Ensure that users who are assigned to the supervisor via a group are also included
     # in final data set.
     indicator_set = CallCenterIndicators(
         self.domain.name,
         self.domain.default_timezone,
         self.domain.call_center_config.case_type,
         self.supervisor,
         custom_cache=locmem_cache
     )
     self.assertEqual(list(indicator_set.user_to_case_map), [self.user.get_id])
     self.assertEqual(indicator_set.users_needing_data, set([self.user.get_id]))
     self.assertEqual(indicator_set.owners_needing_data, set([self.user.get_id]))
     self._test_indicators(self.user, indicator_set.get_data(), expected_standard_indicators())
开发者ID:dimagi,项目名称:commcare-hq,代码行数:14,代码来源:test_indicators.py

示例10: test_cases_owned_by_group

 def test_cases_owned_by_group(self, mock):
     # Ensure that indicators include cases owned by a case sharing group the user is part of.
     indicator_set = CallCenterIndicators(
         self.domain.name,
         self.domain.default_timezone,
         self.domain.call_center_config.case_type,
         self.supervisor,
         custom_cache=locmem_cache
     )
     self.assertEqual(list(indicator_set.user_to_case_map), [self.user.get_id])
     self.assertEqual(indicator_set.users_needing_data, set([self.user.get_id]))
     self.assertEqual(indicator_set.owners_needing_data, set([self.user.get_id, self.group.get_id]))
     expected = expected_standard_indicators()
     expected['totalCases'] = 0  # no cases with user_id = self.user.get_id
     self._test_indicators(self.user, indicator_set.get_data(), expected)
开发者ID:dimagi,项目名称:commcare-hq,代码行数:15,代码来源:test_indicators.py

示例11: test_no_cases_owned_by_user

 def test_no_cases_owned_by_user(self, mock):
     """
     Test to verify that only data belonging to users managed by the supervisor is returned.
     """
     indicator_set = CallCenterIndicators(
         self.cc_domain.name,
         self.cc_domain.default_timezone,
         self.cc_domain.call_center_config.case_type,
         self.cc_user_no_data,
         custom_cache=locmem_cache
     )
     self.assertEqual(list(indicator_set.user_to_case_map), [])
     self.assertEqual(indicator_set.users_needing_data, set())
     self.assertEqual(indicator_set.owners_needing_data, set())
     self.assertEqual(indicator_set.get_data(), {})
开发者ID:dimagi,项目名称:commcare-hq,代码行数:15,代码来源:test_indicators.py

示例12: test_caching

    def test_caching(self):
        user_case = get_case_by_domain_hq_user_id(self.cc_domain.name, self.cc_user._id, include_docs=True)
        expected_indicators = {'a': 1, 'b': 2}
        cached_data = CachedIndicators(
            user_id=self.cc_user.get_id,
            case_id=user_case.case_id,
            domain=self.cc_domain.name,
            indicators=expected_indicators
        )
        locmem_cache.set(cache_key(self.cc_user.get_id), cached_data.to_json())

        indicator_set = CallCenterIndicators(self.cc_domain, self.cc_user, custom_cache=locmem_cache)
        self.assertEqual(indicator_set.all_user_ids, set([self.cc_user.get_id, self.cc_user_no_data.get_id]))
        self.assertEquals(indicator_set.users_needing_data, set([self.cc_user_no_data.get_id]))
        self.assertEqual(indicator_set.owners_needing_data, set([self.cc_user_no_data.get_id]))
        self.check_cc_indicators(indicator_set.get_data(), expected_indicators)
开发者ID:kamilk161,项目名称:commcare-hq,代码行数:16,代码来源:test_indicators.py

示例13: test_standard_indicators_load_config_from_db

    def test_standard_indicators_load_config_from_db(self):
        config = CallCenterIndicatorConfig.default_config(self.cc_domain.name, include_legacy=False)
        config.save()

        self.addCleanup(config.delete)

        indicator_set = CallCenterIndicators(
            self.cc_domain.name,
            self.cc_domain.default_timezone,
            self.cc_domain.call_center_config.case_type,
            self.cc_user,
            custom_cache=locmem_cache,
        )
        self._test_indicators(
            self.cc_user,
            indicator_set.get_data(),
            expected_standard_indicators(include_legacy=False))
开发者ID:tlwakwella,项目名称:commcare-hq,代码行数:17,代码来源:test_indicators.py

示例14: callcenter_test

def callcenter_test(request):
    user_id = request.GET.get("user_id")
    date_param = request.GET.get("date")

    if not user_id:
        return render(request, "hqadmin/callcenter_test.html", {})

    error = None
    try:
        user = CommCareUser.get(user_id)
    except ResourceNotFound:
        user = None
        error = "User Not Found"

    try:
        query_date = dateutil.parser.parse(date_param)
    except ValueError:
        error = "Unable to parse date, using today"
        query_date = date.today()

    def view_data(case_id, indicators):
        new_dict = SortedDict()
        key_list = sorted(indicators.keys())
        for key in key_list:
            new_dict[key] = indicators[key]
        return {
            'indicators': new_dict,
            'case': CommCareCase.get(case_id),
        }

    if user:
        domain = user.project
        dummy_cache = cache.get_cache('django.core.cache.backends.dummy.DummyCache')
        cci = CallCenterIndicators(domain, user, custom_cache=dummy_cache, override_date=query_date)
        data = {case_id: view_data(case_id, values) for case_id, values in cci.get_data().items()}
    else:
        data = {}

    context = {
        "error": error,
        "mobile_user": user,
        "date": query_date.strftime("%Y-%m-%d"),
        "data": data,
    }
    return render(request, "hqadmin/callcenter_test.html", context)
开发者ID:kamilk161,项目名称:commcare-hq,代码行数:45,代码来源:views.py

示例15: test_opened_closed

    def test_opened_closed(self, mock):
        """
        Test that cases_closed and cases_opened indicators count based on the user that
        opened / closed the case and not the case owner.
        """
        indicator_set = CallCenterIndicators(
            self.domain.name,
            self.domain.default_timezone,
            self.domain.call_center_config.case_type,
            self.supervisor,
            custom_cache=locmem_cache
        )
        expected = expected_standard_indicators()

        # cases opened / closed by another user so expect 0
        for key in expected:
            if key.startswith('cases_opened') or key.startswith('cases_closed'):
                expected[key] = 0
        self._test_indicators(self.user, indicator_set.get_data(), expected)
开发者ID:dimagi,项目名称:commcare-hq,代码行数:19,代码来源:test_indicators.py


注:本文中的corehq.apps.callcenter.indicator_sets.CallCenterIndicators类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。