Removed model_package test dependency on contrib.sites
This commit is contained in:
parent
f233bf47dd
commit
f05b03f3d7
|
@ -1,7 +1,10 @@
|
||||||
from django.contrib.sites.models import Site
|
|
||||||
from django.db import models
|
from django.db import models
|
||||||
|
|
||||||
|
|
||||||
|
class Site(models.Model):
|
||||||
|
name = models.CharField(max_length=100)
|
||||||
|
|
||||||
|
|
||||||
class Article(models.Model):
|
class Article(models.Model):
|
||||||
sites = models.ManyToManyField(Site)
|
sites = models.ManyToManyField(Site)
|
||||||
headline = models.CharField(max_length=100)
|
headline = models.CharField(max_length=100)
|
||||||
|
|
|
@ -1,12 +1,11 @@
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
from django.contrib.sites.models import Site
|
|
||||||
from django.db import models, connection
|
from django.db import models, connection
|
||||||
from django.db.backends.utils import truncate_name
|
from django.db.backends.utils import truncate_name
|
||||||
from django.test import TestCase
|
from django.test import TestCase
|
||||||
|
|
||||||
from .models.publication import Publication
|
from .models.publication import Publication
|
||||||
from .models.article import Article
|
from .models.article import Article, Site
|
||||||
|
|
||||||
|
|
||||||
class Advertisement(models.Model):
|
class Advertisement(models.Model):
|
||||||
|
@ -16,13 +15,6 @@ class Advertisement(models.Model):
|
||||||
|
|
||||||
class ModelPackageTests(TestCase):
|
class ModelPackageTests(TestCase):
|
||||||
|
|
||||||
@classmethod
|
|
||||||
def setUpClass(cls):
|
|
||||||
super(ModelPackageTests, cls).setUpClass()
|
|
||||||
# This cleanup is necessary because contrib.sites cache
|
|
||||||
# makes tests interfere with each other, see #11505
|
|
||||||
Site.objects.clear_cache()
|
|
||||||
|
|
||||||
def test_m2m_tables_in_subpackage_models(self):
|
def test_m2m_tables_in_subpackage_models(self):
|
||||||
"""
|
"""
|
||||||
Regression for #12168: models split into subpackages still get M2M
|
Regression for #12168: models split into subpackages still get M2M
|
||||||
|
@ -30,12 +22,11 @@ class ModelPackageTests(TestCase):
|
||||||
"""
|
"""
|
||||||
p = Publication.objects.create(title="FooBar")
|
p = Publication.objects.create(title="FooBar")
|
||||||
|
|
||||||
current_site = Site.objects.get_current()
|
site = Site.objects.create(name="example.com")
|
||||||
self.assertEqual(current_site.domain, "example.com")
|
|
||||||
|
|
||||||
a = Article.objects.create(headline="a foo headline")
|
a = Article.objects.create(headline="a foo headline")
|
||||||
a.publications.add(p)
|
a.publications.add(p)
|
||||||
a.sites.add(current_site)
|
a.sites.add(site)
|
||||||
|
|
||||||
a = Article.objects.get(id=a.pk)
|
a = Article.objects.get(id=a.pk)
|
||||||
self.assertEqual(a.id, a.pk)
|
self.assertEqual(a.id, a.pk)
|
||||||
|
|
Loading…
Reference in New Issue