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


Python factory.IndicatorFactory类代码示例

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


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

示例1: testBadFilterType

 def testBadFilterType(self):
     with self.assertRaises(BadSpecError):
         IndicatorFactory.from_spec({
             'type': 'boolean',
             'column_id': 'col',
             'filter': 'wrong type',
         })
开发者ID:jmaina,项目名称:commcare-hq,代码行数:7,代码来源:test_indicators.py

示例2: testEmptyFilter

 def testEmptyFilter(self):
     with self.assertRaises(BadSpecError):
         IndicatorFactory.from_spec({
             'type': 'boolean',
             'column_id': 'col',
             'filter': None,
         })
开发者ID:jmaina,项目名称:commcare-hq,代码行数:7,代码来源:test_indicators.py

示例3: default_indicators

    def default_indicators(self):
        default_indicators = [IndicatorFactory.from_spec({
            "column_id": "doc_id",
            "type": "expression",
            "display_name": "document id",
            "datatype": "string",
            "is_nullable": False,
            "is_primary_key": True,
            "expression": {
                "type": "root_doc",
                "expression": {
                    "type": "property_name",
                    "property_name": "_id"
                }
            }
        }, self._get_factory_context())]

        default_indicators.append(IndicatorFactory.from_spec({
            "type": "inserted_at",
        }, self._get_factory_context()))

        if self.base_item_expression:
            default_indicators.append(IndicatorFactory.from_spec({
                "type": "repeat_iteration",
            }, self._get_factory_context()))

        return default_indicators
开发者ID:bazuzi,项目名称:commcare-hq,代码行数:27,代码来源:models.py

示例4: indicators

    def indicators(self):
        default_indicators = [IndicatorFactory.from_spec({
            "column_id": "doc_id",
            "type": "expression",
            "display_name": "document id",
            "datatype": "string",
            "is_nullable": False,
            "is_primary_key": True,
            "expression": {
                "type": "root_doc",
                "expression": {
                    "type": "property_name",
                    "property_name": "_id"
                }
            }
        }, self.named_filter_objects)]

        default_indicators.append(IndicatorFactory.from_spec({
            "type": "inserted_at",
        }, self.named_filter_objects))

        if self.base_item_expression:
            default_indicators.append(IndicatorFactory.from_spec({
                "type": "repeat_iteration",
            }, self.named_filter_objects))
        return CompoundIndicator(
            self.display_name,
            default_indicators + [
                IndicatorFactory.from_spec(indicator, self.named_filter_objects)
                for indicator in self.configured_indicators
            ]
        )
开发者ID:johan--,项目名称:commcare-hq,代码行数:32,代码来源:models.py

示例5: testNoColumnId

 def testNoColumnId(self):
     with self.assertRaises(BadSpecError):
         IndicatorFactory.from_spec({
             'type': 'boolean',
             'filter': {
                 'type': 'property_match',
                 'property_name': 'foo',
                 'property_value': 'bar',
             }
         })
开发者ID:jmaina,项目名称:commcare-hq,代码行数:10,代码来源:test_indicators.py

示例6: testInvalidFilter

 def testInvalidFilter(self):
     with self.assertRaises(BadSpecError):
         IndicatorFactory.from_spec({
             'type': 'boolean',
             'column_id': 'col',
             'filter': {
                 'type': 'property_match',
                 'property_value': 'bar',
             }
         })
开发者ID:jmaina,项目名称:commcare-hq,代码行数:10,代码来源:test_indicators.py

示例7: testEmptyColumnId

 def testEmptyColumnId(self):
     with self.assertRaises(BadSpecError):
         IndicatorFactory.from_spec({
             'type': self.indicator_type,
             'column_id': '',
             'filter': {
                 'type': 'property_match',
                 'property_name': 'foo',
                 'property_value': 'bar',
             }
         })
开发者ID:dimagi,项目名称:commcare-hq,代码行数:11,代码来源:test_indicators.py

示例8: complex_indicator

 def complex_indicator(self):
     # this expression is the equivalent to:
     #   doc.true_value if doc.test == 'match' else doc.false_value
     return IndicatorFactory.from_spec({
         "type": "expression",
         "expression": {
             'type': 'conditional',
             'test': {
                 'type': 'boolean_expression',
                 'expression': {
                     'type': 'property_name',
                     'property_name': 'test',
                 },
                 'operator': 'eq',
                 'property_value': 'match',
             },
             'expression_if_true': {
                 'type': 'property_name',
                 'property_name': 'true_value',
             },
             'expression_if_false': {
                 'type': 'property_name',
                 'property_name': 'false_value',
             },
         },
         "column_id": "foo",
         "datatype": "string",
         "display_name": "expression foos",
     })
开发者ID:jmaina,项目名称:commcare-hq,代码行数:29,代码来源:test_indicators.py

示例9: test_not_null_filter_root_doc

 def test_not_null_filter_root_doc(self):
     indicator = IndicatorFactory.from_spec(
         {
             "filter": {
                 "filter": {
                     "operator": "in",
                     "expression": {
                         "expression": {
                             "datatype": None,
                             "type": "property_name",
                             "property_name": "ccs_opened_date"
                         },
                         "type": "root_doc"
                     },
                     "type": "boolean_expression",
                     "property_value": [
                         "",
                         None
                     ]
                 },
                 "type": "not"
             },
             "type": self.indicator_type,
             "display_name": None,
             "column_id": "prop1_not_null"
         }
     )
     self._check_result(indicator, {}, 1, EvaluationContext(root_doc=dict(ccs_opened_date='not_null')))
     self._check_result(indicator, {}, 1, EvaluationContext(root_doc=dict(ccs_opened_date=' ')))
     self._check_result(indicator, {}, 0, EvaluationContext(root_doc=dict(ccs_opened_date='')))
     self._check_result(indicator, {}, 0, EvaluationContext(root_doc=dict(ccs_opened_date=None)))
     self._check_result(indicator, {}, 0, EvaluationContext(root_doc=dict()))
开发者ID:dimagi,项目名称:commcare-hq,代码行数:32,代码来源:test_indicators.py

示例10: testCount

 def testCount(self):
     indicator = IndicatorFactory.from_spec({
         "type": "count",
         "column_id": "count",
         "display_name": "Count"
     })
     self._check_result(indicator, dict(), 1)
开发者ID:jmaina,项目名称:commcare-hq,代码行数:7,代码来源:test_indicators.py

示例11: testComplexStructure

    def testComplexStructure(self):
        # in slightly more compact format:
        # ((foo=bar) or (foo1=bar1 and foo2=bar2 and (foo3=bar3 or foo4=bar4)))
        indicator = IndicatorFactory.from_spec({
            "type": "boolean",
            "column_id": "col",
            "filter": {
                "type": "or",
                "filters": [
                    {
                        "type": "property_match",
                        "property_name": "foo",
                        "property_value": "bar"
                    },
                    {
                        "type": "and",
                        "filters": [
                            {
                                "type": "property_match",
                                "property_name": "foo1",
                                "property_value": "bar1"
                            },
                            {
                                "type": "property_match",
                                "property_name": "foo2",
                                "property_value": "bar2"
                            },
                            {
                                "type": "or",
                                "filters": [
                                    {
                                        "type": "property_match",
                                        "property_name": "foo3",
                                        "property_value": "bar3"
                                    },
                                    {
                                        "type": "property_match",
                                        "property_name": "foo4",
                                        "property_value": "bar4"
                                    }
                                ]
                            },
                        ]
                    },
                ]
            }
        })
        # first level or
        self._check_result(indicator, dict(foo='bar'), 1)
        # first level and with both or's
        self._check_result(indicator, dict(foo1='bar1', foo2='bar2', foo3='bar3'), 1)
        self._check_result(indicator, dict(foo1='bar1', foo2='bar2', foo4='bar4'), 1)

        # first and not right
        self._check_result(indicator, dict(foo1='not bar1', foo2='bar2', foo3='bar3'), 0)
        # second and not right
        self._check_result(indicator, dict(foo1='bar1', foo2='not bar2', foo3='bar3'), 0)
        # last and not right
        self._check_result(indicator, dict(foo1='bar1', foo2='bar2', foo3='not bar3', foo4='not bar4'), 0)
开发者ID:jmaina,项目名称:commcare-hq,代码行数:59,代码来源:test_indicators.py

示例12: test_literal

 def test_literal(self):
     indicator = IndicatorFactory.from_spec({
         "type": "expression",
         "expression": 10,
         "column_id": "foo",
         "datatype": "integer"
     })
     self._check_result(indicator, {}, 10)
     self._check_result(indicator, {'foo': 'bar'}, 10)
     indicator = IndicatorFactory.from_spec({
         "type": "expression",
         "expression": 10,
         "column_id": "foo",
         "datatype": "small_integer"
     })
     self._check_result(indicator, {}, 10)
     self._check_result(indicator, {'foo': 'bar'}, 10)
开发者ID:dimagi,项目名称:commcare-hq,代码行数:17,代码来源:test_indicators.py

示例13: _default_nested_indicator

 def _default_nested_indicator(self, path):
     return IndicatorFactory.from_spec({
         "type": "raw",
         "column_id": "foo",
         "datatype": "string",
         "property_path": path,
         "display_name": "indexed",
     })
开发者ID:jmaina,项目名称:commcare-hq,代码行数:8,代码来源:test_indicators.py

示例14: indicators

 def indicators(self):
     doc_id_indicator = IndicatorFactory.from_spec({
         "column_id": "doc_id",
         "type": "raw",
         "display_name": "document id",
         "datatype": "string",
         "property_name": "_id",
         "is_nullable": False,
         "is_primary_key": True,
     }, self.named_filter_objects)
     return CompoundIndicator(
         self.display_name,
         [doc_id_indicator] + [
             IndicatorFactory.from_spec(indicator, self.named_filter_objects)
             for indicator in self.configured_indicators
         ]
     )
开发者ID:bradmerlin,项目名称:commcare-hq,代码行数:17,代码来源:models.py

示例15: testSingleSelectIndicators

 def testSingleSelectIndicators(self):
     indicator = IndicatorFactory.from_spec(self.spec)
     self._check_vals(indicator, dict(category='bug'), [1, 0, 0, 0])
     self._check_vals(indicator, dict(category='feature'), [0, 1, 0, 0])
     self._check_vals(indicator, dict(category='app'), [0, 0, 1, 0])
     self._check_vals(indicator, dict(category='schedule'), [0, 0, 0, 1])
     self._check_vals(indicator, dict(category='nomatch'), [0, 0, 0, 0])
     self._check_vals(indicator, dict(category=''), [0, 0, 0, 0])
     self._check_vals(indicator, dict(nocategory='bug'), [0, 0, 0, 0])
开发者ID:jmaina,项目名称:commcare-hq,代码行数:9,代码来源:test_indicators.py


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