mirror of
https://github.com/Hopiu/django-cachalot.git
synced 2026-03-16 21:30:23 +00:00
Tests unmanaged models.
This commit is contained in:
parent
522cf930a4
commit
2a8f139acc
3 changed files with 15 additions and 1 deletions
|
|
@ -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));'),
|
||||
]
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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):
|
||||
|
|
|
|||
Loading…
Reference in a new issue