Opened 13 years ago

Closed 13 years ago

#18408 closed Bug (fixed)

flatpages - tests expect site 1 to be example.com

Reported by: jens@… Owned by: nobody
Component: contrib.flatpages Version: 1.4
Severity: Normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

There is a test failure in django.contrib.flatpages that occurs when a project has customized the domain for Sites.site 1.
See pull request 83 (https://github.com/django/django/pull/83) on GitHub with a proposed fix.

Steps to reproduce:

  1. Create a new project and app
  2. Make necessary configuration changes for flatpages, sites, and test app & syncdb
  3. Create initial_data fixture for site id 1 and update the domain to something other than example.com (for example: 127.0.0.1:8000)
  4. Run tests
    FAIL: test_flatpage_admin_form_url_uniqueness_validation (django.contrib.flatpages.tests.forms.FlatpageAdminFormTests)
    The flatpage admin form correctly enforces url uniqueness among flatpages of the same site
    ----------------------------------------------------------------------
    Traceback (most recent call last):
      File "/Users/jpage/Projects/Django/venv/src/django/django/contrib/flatpages/tests/forms.py", line 60, in test_flatpage_admin_form_url_uniqueness_validation
        {'__all__': [u'Flatpage with url /myflatpage1/ already exists for site example.com']})
    AssertionError: {'__all__': [u'Flatpage with url /myflatpage1/ already exists for site 127.0.0.1:8000']} != {'__all__': [u'Flatpage with url /myflatpage1/ already exists for site example.com']}
    
    ----------------------------------------------------------------------
    Ran 462 tests in 18.547s
    
    FAILED (failures=1, skipped=1)
    Destroying test database for alias 'default'...
    

The proposed fix adds an example_site test fixture to address the issue above. It also overrides the project's SITE_ID to 1 to address issues when running tests with a project's SITE_ID set to something other than 1. It also normalizes the use of the hard coded site id 1 to settings.SITE_ID for consistency.

Link to GitHub pull request:
https://github.com/django/django/pull/83

Let me know if there are any changes, I am just trying to do my part and give a little back.

Change History (1)

comment:1 by Claude Paroz <claude@…>, 13 years ago

Resolution: fixed
Status: newclosed

In [ba10be70322027074e5f9defc1423eb0cc77473c]:

Fixed #18408 -- Isolated flatpages tests from existing sites.

Resolves Flatpages test issues by:

  • Creating an example_site fixture
  • Overriding project SITE_ID setting to 1
  • Normalizing the use of the hardcoded (1) site_id to settings.SITE_ID
Note: See TracTickets for help on using tickets.
Back to Top