示例#1
0
    def run_db_tests(self, suite):
        print("Running {0} tests with database".format(suite.countTestCases()))
        old_config = self.setup_databases()
        result = self.run_suite(suite)

        from corehq.sql_db.connections import Session, connection_manager
        Session.remove()
        connection_manager.dispose_all()


        self.teardown_databases(old_config)
        return self.suite_result(suite, result)
示例#2
0
 def tearDownClass(cls):
     cls.couch_user.delete(DOMAIN, deleted_by=None)
     Session.remove()
     super(BaseReportTest, cls).tearDownClass()
示例#3
0
 def tearDown(self):
     self._delete_everything()
     # todo: understand why this is necessary. the view call uses the session and the
     # signal doesn't fire to kill it.
     Session.remove()
     super(ConfigurableReportViewTest, self).tearDown()
示例#4
0
 def tearDownClass(cls):
     Session.remove()
示例#5
0
 def tearDownClass(cls):
     cls.case.delete()
     # todo: understand why this is necessary. the view call uses the session and the
     # signal doesn't fire to kill it.
     Session.remove()
     super(ConfigurableReportViewTest, cls).tearDownClass()
示例#6
0
 def tearDownClass(cls):
     Session.remove()
     super(ReportAPITest, cls).tearDownClass()
示例#7
0
 def tearDownClass(cls):
     cls.couch_user.delete()
     Session.remove()
示例#8
0
 def tearDown(self):
     self._delete_everything()
     # todo: understand why this is necessary. the view call uses the session and the
     # signal doesn't fire to kill it.
     Session.remove()
     super(ConfigurableReportViewTest, self).tearDown()
示例#9
0
 def tearDownClass(cls):
     cls.case.delete()
     # todo: understand why this is necessary. the view call uses the session and the
     # signal doesn't fire to kill it.
     Session.remove()
     super(ConfigurableReportViewTest, cls).tearDownClass()
示例#10
0
 def tearDownClass(cls):
     cls.couch_user.delete()
     Session.remove()
     super(BaseReportTest, cls).tearDownClass()
示例#11
0
 def tearDownClass(cls):
     cls.couch_user.delete()
     Session.remove()
     super(BaseReportTest, cls).tearDownClass()
示例#12
0
 def tearDownClass(cls):
     cls._delete_everything()
     # todo: understand why this is necessary. the view call uses the session and the
     # signal doesn't fire to kill it.
     Session.remove()
示例#13
0
 def tearDownClass(cls):
     Session.remove()
示例#14
0
class ConfigurableReportViewTest(ConfigurableReportTestMixin, TestCase):
    def _build_report_and_view(self, request=HttpRequest()):
        # Create report
        data_source_config = DataSourceConfiguration(
            domain=self.domain,
            display_name='foo',
            referenced_doc_type='CommCareCase',
            table_id="woop_woop",
            configured_filter={
                "type": "boolean_expression",
                "operator": "eq",
                "expression": {
                    "type": "property_name",
                    "property_name": "type"
                },
                "property_value": self.case_type,
            },
            configured_indicators=[
                {
                    "type": "expression",
                    "expression": {
                        "type": "property_name",
                        "property_name": 'fruit'
                    },
                    "column_id": 'indicator_col_id_fruit',
                    "display_name": 'indicator_display_name_fruit',
                    "datatype": "string"
                },
                {
                    "type": "expression",
                    "expression": {
                        "type": "property_name",
                        "property_name": 'num1'
                    },
                    "column_id": 'indicator_col_id_num1',
                    "datatype": "integer"
                },
                {
                    "type": "expression",
                    "expression": {
                        "type": "property_name",
                        "property_name": 'num2'
                    },
                    "column_id": 'indicator_col_id_num2',
                    "datatype": "integer"
                },
            ],
        )
        data_source_config.validate()
        data_source_config.save()
        self.addCleanup(data_source_config.delete)
        tasks.rebuild_indicators(data_source_config._id)

        report_config = ReportConfiguration(
            domain=self.domain,
            config_id=data_source_config._id,
            title='foo',
            aggregation_columns=['doc_id'],
            columns=[{
                "type": "field",
                "display": "report_column_display_fruit",
                "field": 'indicator_col_id_fruit',
                'column_id': 'report_column_col_id_fruit',
                'aggregation': 'simple'
            }, {
                "type": "percent",
                "display": "report_column_display_percent",
                'column_id': 'report_column_col_id_percent',
                'format': 'percent',
                "denominator": {
                    "type": "field",
                    "aggregation": "sum",
                    "field": "indicator_col_id_num1",
                    "column_id": "report_column_col_id_percent_num1"
                },
                "numerator": {
                    "type": "field",
                    "aggregation": "sum",
                    "field": "indicator_col_id_num2",
                    "column_id": "report_column_col_id_percent_num2"
                }
            }, {
                "type": "expanded",
                "display": "report_column_display_expanded_num1",
                "field": 'indicator_col_id_num1',
                'column_id': 'report_column_col_id_expanded_num1',
            }],
            configured_charts=[
                {
                    "type": 'pie',
                    "value_column": 'count',
                    "aggregation_column": 'fruit',
                    "title": 'Fruits'
                },
                {
                    "type":
                    'multibar',
                    "title":
                    'Fruit Properties',
                    "x_axis_column":
                    'fruit',
                    "y_axis_columns": [{
                        "column_id": "report_column_col_id_expanded_num1",
                        "display": "Num1 values"
                    }]
                },
            ])
        report_config.save()
        self.addCleanup(report_config.delete)

        view = ConfigurableReportView(request=request)
        view._domain = self.domain
        view._lang = "en"
        view._report_config_id = report_config._id

        return report_config, view

    @classmethod
    def tearDownClass(cls):
        for case in cls.cases:
            case.delete()
        # todo: understand why this is necessary. the view call uses the session and the
        # signal doesn't fire to kill it.
        Session.remove()
        super(ConfigurableReportViewTest, cls).tearDownClass()