def test_get_reporting_tables(self):
        """Test that the report schema is populated with a column map."""
        tables = self.accessor.get_base().classes
        report_schema = ReportSchema(tables, self.column_map)

        report_schema._set_reporting_tables(
            tables,
            self.accessor.column_map
        )

        for table in self.all_tables:
            self.assertIsNotNone(getattr(report_schema, table))

        self.assertTrue(hasattr(report_schema, 'column_types'))

        column_types = report_schema.column_types

        for table in self.all_tables:
            self.assertIn(table, column_types)

        table_types = column_types[random.choice(self.all_tables)]

        python_types = list(types.__builtins__.values())
        python_types.extend([datetime.datetime, Decimal])

        for table_type in table_types.values():
            self.assertIn(table_type, python_types)
Esempio n. 2
0
    def test_get_reporting_tables(self):
        """Test that the report schema is populated with a column map."""
        tables = django.apps.apps.get_models()
        report_schema = ReportSchema(tables)

        report_schema._set_reporting_tables(tables)

        for table in self.all_tables:
            self.assertIsNotNone(getattr(report_schema, table))

        self.assertTrue(hasattr(report_schema, "column_types"))

        column_types = report_schema.column_types

        for table in self.all_tables:
            self.assertIn(table, column_types)

        table_types = column_types[random.choice(self.all_tables)]

        django_field_types = [
            "IntegerField",
            "FloatField",
            "JSONField",
            "DateTimeField",
            "DecimalField",
            "CharField",
            "TextField",
            "PositiveIntegerField",
        ]
        for table_type in table_types.values():
            self.assertIn(table_type, django_field_types)
Esempio n. 3
0
    def __init__(self, schema, column_map):
        """Initialize the report object creation helpler."""
        self.schema = schema
        self.column_map = column_map

        self.report_schema = ReportSchema(django.apps.apps.get_models(), self.column_map)
        self.column_types = self.report_schema.column_types
    def test_init(self):
        """Test the initializer."""
        tables = self.accessor.get_base().classes
        report_schema = ReportSchema(tables, self.column_map)

        for table_name in self.all_tables:
            self.assertIsNotNone(getattr(report_schema, table_name))

        self.assertNotEqual(report_schema.column_types, {})
Esempio n. 5
0
    def test_init(self):
        """Test the initializer."""
        tables = django.apps.apps.get_models()
        report_schema = ReportSchema(tables)

        for table_name in self.all_tables:
            self.assertIsNotNone(getattr(report_schema, table_name))

        self.assertNotEqual(report_schema.column_types, {})