Permalink
Browse files

Fixed a bunch more tests that were failing in Oracle due to false ass…

…umptions about the primary keys of objects.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@15789 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
1 parent 23103bd commit f17fc56602f8de37ef8c5565ddf04991e8c91442 @ikelly ikelly committed Mar 9, 2011
@@ -1,3 +1,4 @@
+from django.conf import settings
from django.contrib.flatpages.admin import FlatpageForm
from django.test import TestCase
@@ -6,7 +7,7 @@ def setUp(self):
self.form_data = {
'title': "A test page",
'content': "This is a test",
- 'sites': [1],
+ 'sites': [settings.SITE_ID],
}
def test_flatpage_admin_form_url_validation(self):
@@ -68,7 +68,7 @@ def test_view_flatpage_special_chars(self):
enable_comments=False,
registration_required=False,
)
- fp.sites.add(1)
+ fp.sites.add(settings.SITE_ID)
response = self.client.get('/flatpage_root/some.very_special~chars-here/')
self.assertEqual(response.status_code, 200)
@@ -55,7 +55,7 @@ def test_custom_field(self):
# Serialization works, too.
stream = serializers.serialize("json", MyModel.objects.all())
- self.assertEqual(stream, '[{"pk": 1, "model": "field_subclassing.mymodel", "fields": {"data": "12", "name": "m"}}]')
+ self.assertEqual(stream, '[{"pk": %d, "model": "field_subclassing.mymodel", "fields": {"data": "12", "name": "m"}}]' % m1.pk)
obj = list(serializers.deserialize("json", stream))[0]
self.assertEqual(obj.object, m)
@@ -2,6 +2,7 @@
import sys
from django.conf import settings
+from django.contrib.sites.models import Site
from django.core import management
from django.db import DEFAULT_DB_ALIAS
from django.test import TestCase, TransactionTestCase, skipUnlessDBFeature
@@ -45,6 +46,7 @@ def test_initial_data(self):
def test_loading_and_dumping(self):
new_io = StringIO.StringIO()
+ Site.objects.all().delete()
# Load fixture 1. Single JSON file, with two objects.
management.call_command('loaddata', 'fixture1.json', verbosity=0, commit=False)
self.assertQuerysetEqual(Article.objects.all(), [
@@ -159,6 +161,7 @@ def test_loading_and_dumping(self):
def test_dumpdata_with_excludes(self):
# Load fixture1 which has a site, two articles, and a category
+ Site.objects.all().delete()
management.call_command('loaddata', 'fixture1.json', verbosity=0, commit=False)
# Excluding fixtures app should only leave sites
@@ -200,15 +203,15 @@ def test_dumpdata_with_excludes(self):
exclude_list=['fixtures.FooModel'])
def test_dumpdata_with_filtering_manager(self):
- Spy(name='Paul').save()
- Spy(name='Alex', cover_blown=True).save()
+ spy1 = Spy.objects.create(name='Paul')
+ spy2 = Spy.objects.create(name='Alex', cover_blown=True)
self.assertQuerysetEqual(Spy.objects.all(),
['<Spy: Paul>'])
# Use the default manager
- self._dumpdata_assert(['fixtures.Spy'],'[{"pk": 1, "model": "fixtures.spy", "fields": {"cover_blown": false}}]')
+ self._dumpdata_assert(['fixtures.Spy'],'[{"pk": %d, "model": "fixtures.spy", "fields": {"cover_blown": false}}]' % spy1.pk)
# Dump using Django's base manager. Should return all objects,
# even those normally filtered by the manager
- self._dumpdata_assert(['fixtures.Spy'], '[{"pk": 2, "model": "fixtures.spy", "fields": {"cover_blown": true}}, {"pk": 1, "model": "fixtures.spy", "fields": {"cover_blown": false}}]', use_base_manager=True)
+ self._dumpdata_assert(['fixtures.Spy'], '[{"pk": %d, "model": "fixtures.spy", "fields": {"cover_blown": true}}, {"pk": %d, "model": "fixtures.spy", "fields": {"cover_blown": false}}]' % (spy2.pk, spy1.pk), use_base_manager=True)
def test_compress_format_loading(self):
# Load fixture 4 (compressed), using format specification
Oops, something went wrong.

0 comments on commit f17fc56

Please sign in to comment.