Debian Codegraph @

tests/postgres_tests/test_introspection.py

raw
1 from io import StringIO
2
3 from django.core.management import call_command
4
5 from . import PostgreSQLTestCase
6
7
8 class InspectDBTests(PostgreSQLTestCase):
9 def assertFieldsInModel(self, model, field_outputs):
10 out = StringIO()
11 call_command(
12 "inspectdb",
13 table_name_filter=lambda tn: tn.startswith(model),
14 stdout=out,
15 )
16 output = out.getvalue()
17 for field_output in field_outputs:
18 self.assertIn(field_output, output)
19
20 def test_range_fields(self):
21 self.assertFieldsInModel(
22 "postgres_tests_rangesmodel",
23 [
24 "ints = django.contrib.postgres.fields.IntegerRangeField(blank=True, "
25 "null=True)",
26 "bigints = django.contrib.postgres.fields.BigIntegerRangeField("
27 "blank=True, null=True)",
28 "decimals = django.contrib.postgres.fields.DecimalRangeField("
29 "blank=True, null=True)",
30 "timestamps = django.contrib.postgres.fields.DateTimeRangeField("
31 "blank=True, null=True)",
32 "dates = django.contrib.postgres.fields.DateRangeField(blank=True, "
33 "null=True)",
34 ],
35 )