Tests unmanaged models.

This commit is contained in:
Bertrand Bordage 2018-07-27 14:15:06 +02:00
parent 522cf930a4
commit 2a8f139acc
3 changed files with 15 additions and 1 deletions

View file

@ -74,4 +74,6 @@ class Migration(migrations.Migration):
('datetime_range', DateTimeRangeField(null=True, blank=True)),
],
),
migrations.RunSQL('CREATE TABLE cachalot_unmanagedmodel '
'(id SERIAL PRIMARY KEY, name VARCHAR(50));'),
]

View file

@ -62,3 +62,10 @@ class PostgresModel(Model):
class Meta:
# Tests schema name in table name.
db_table = '"public"."cachalot_postgresmodel"'
class UnmanagedModel(Model):
name = CharField(max_length=50)
class Meta:
managed = False

View file

@ -20,7 +20,7 @@ from pytz import UTC
from ..settings import cachalot_settings
from ..utils import UncachableQuery
from .models import Test, TestChild, TestParent
from .models import Test, TestChild, TestParent, UnmanagedModel
from .test_utils import TestUtilsMixin
@ -698,6 +698,11 @@ class ReadTestCase(TestUtilsMixin, TransactionTestCase):
with connection.cursor() as cursor:
cursor.execute('DROP TABLE %s;' % table_name)
def test_unmanaged_model(self):
qs = UnmanagedModel.objects.all()
self.assert_tables(qs, UnmanagedModel)
self.assert_query_cached(qs)
class ParameterTypeTestCase(TestUtilsMixin, TransactionTestCase):
def test_tuple(self):