commit
e67e7042db
|
|
@ -17,3 +17,4 @@ dist/
|
|||
docs/_build/
|
||||
htmlcov/
|
||||
venv/
|
||||
.venv/
|
||||
|
|
|
|||
|
|
@ -1450,6 +1450,13 @@ class Migration(migrations.Migration):
|
|||
to="tests.ParentModelWithManager",
|
||||
),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name="childmodelwithmanager",
|
||||
name="field1",
|
||||
field=models.CharField(
|
||||
max_length=10,
|
||||
),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name="childmodelwithmanager",
|
||||
name="polymorphic_ctype",
|
||||
|
|
|
|||
|
|
@ -222,6 +222,7 @@ class ParentModelWithManager(PolymorphicModel):
|
|||
|
||||
class ChildModelWithManager(PolymorphicModel):
|
||||
# Also test whether foreign keys receive the manager:
|
||||
field1 = models.CharField(max_length=10) # needed as MyManager uses it
|
||||
fk = models.ForeignKey(
|
||||
ParentModelWithManager, on_delete=models.CASCADE, related_name="childmodel_set"
|
||||
)
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ from polymorphic.tests.models import (
|
|||
|
||||
|
||||
class MultipleDatabasesTests(TestCase):
|
||||
multi_db = True
|
||||
databases = ["default", "secondary"]
|
||||
|
||||
def test_save_to_non_default_database(self):
|
||||
Model2A.objects.db_manager("secondary").create(field1="A1")
|
||||
|
|
|
|||
|
|
@ -481,21 +481,22 @@ class PolymorphicTests(TransactionTestCase):
|
|||
def test_foreignkey_field(self):
|
||||
self.create_model2abcd()
|
||||
|
||||
object2a = Model2A.base_objects.get(field1="C1")
|
||||
object2a = Model2A.objects.get(field1="C1")
|
||||
self.assertEqual(object2a.model2b.__class__, Model2B)
|
||||
|
||||
object2b = Model2B.base_objects.get(field1="C1")
|
||||
object2b = Model2B.objects.get(field1="C1")
|
||||
self.assertEqual(object2b.model2c.__class__, Model2C)
|
||||
|
||||
def test_onetoone_field(self):
|
||||
self.create_model2abcd()
|
||||
|
||||
# FIXME: We should not use base_objects here.
|
||||
a = Model2A.base_objects.get(field1="C1")
|
||||
b = One2OneRelatingModelDerived.objects.create(
|
||||
one2one=a, field1="f1", field2="f2"
|
||||
)
|
||||
|
||||
# this result is basically wrong, probably due to Django cacheing (we used base_objects), but should not be a problem
|
||||
# FIXME: this result is basically wrong, probably due to Django cacheing (we used base_objects), but should not be a problem
|
||||
self.assertEqual(b.one2one.__class__, Model2A)
|
||||
self.assertEqual(b.one2one_id, b.one2one.id)
|
||||
|
||||
|
|
@ -808,7 +809,6 @@ class PolymorphicTests(TransactionTestCase):
|
|||
|
||||
self.assertIs(type(ModelWithMyManager.objects), MyManager)
|
||||
self.assertIs(type(ModelWithMyManager._default_manager), MyManager)
|
||||
self.assertIs(type(ModelWithMyManager.base_objects), models.Manager)
|
||||
|
||||
def test_user_defined_manager_as_secondary(self):
|
||||
self.create_model2abcd()
|
||||
|
|
@ -831,7 +831,6 @@ class PolymorphicTests(TransactionTestCase):
|
|||
self.assertIs(
|
||||
type(ModelWithMyManagerNoDefault._default_manager), PolymorphicManager
|
||||
)
|
||||
self.assertIs(type(ModelWithMyManagerNoDefault.base_objects), models.Manager)
|
||||
|
||||
def test_user_objects_manager_as_secondary(self):
|
||||
self.create_model2abcd()
|
||||
|
|
@ -841,7 +840,6 @@ class PolymorphicTests(TransactionTestCase):
|
|||
self.assertIs(type(ModelWithMyManagerDefault.my_objects), MyManager)
|
||||
self.assertIs(type(ModelWithMyManagerDefault.objects), PolymorphicManager)
|
||||
self.assertIs(type(ModelWithMyManagerDefault._default_manager), MyManager)
|
||||
self.assertIs(type(ModelWithMyManagerDefault.base_objects), models.Manager)
|
||||
|
||||
def test_user_defined_queryset_as_manager(self):
|
||||
self.create_model2abcd()
|
||||
|
|
@ -864,7 +862,6 @@ class PolymorphicTests(TransactionTestCase):
|
|||
type(ModelWithMyManager2._default_manager).__name__,
|
||||
"PolymorphicManagerFromMyManagerQuerySet",
|
||||
)
|
||||
self.assertIs(type(ModelWithMyManager2.base_objects), models.Manager)
|
||||
|
||||
def test_manager_inheritance(self):
|
||||
# by choice of MRO, should be MyManager from MROBase1.
|
||||
|
|
|
|||
9
tox.ini
9
tox.ini
|
|
@ -1,9 +1,9 @@
|
|||
[tox]
|
||||
envlist =
|
||||
py35-django{21,22,master}
|
||||
py36-django{21,22,30,31,master}
|
||||
py37-django{21,22,30,31,master}
|
||||
py38-django{21,22,30,31,master}
|
||||
py35-django{21,22}
|
||||
py36-django{21,22,30,31}
|
||||
py37-django{21,22,30,31}
|
||||
py38-django{21,22,30,31}
|
||||
docs
|
||||
|
||||
[testenv]
|
||||
|
|
@ -12,6 +12,7 @@ setenv =
|
|||
postgres: DEFAULT_DATABASE = postgres:///default
|
||||
postgres: SECONDARY_DATABASE = postgres:///secondary
|
||||
deps =
|
||||
ipdb
|
||||
coverage
|
||||
dj-database-url
|
||||
django21: Django ~= 2.1
|
||||
|
|
|
|||
Loading…
Reference in New Issue