Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multidb testing for travis #1513

Merged
merged 29 commits into from Dec 20, 2012
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
873ac1f
Tentative multi-db testing strategy
yakky Oct 12, 2012
8bfcd6f
Merge branch 'develop' into yakky-feature/multidb_test
digi604 Nov 14, 2012
5a6c356
multi db testing
digi604 Nov 14, 2012
8ebdf7c
actually use the db env
digi604 Nov 14, 2012
7b3d65a
fixed a lot of tests for mysql
digi604 Nov 15, 2012
8f4d4ab
slqite fixed, mysql fixed (except too many queries)
digi604 Nov 16, 2012
38bcc65
all tests passing on: sqlite, mysql, postgres
digi604 Nov 16, 2012
e743264
django 1.3 and postgres fixes
digi604 Nov 16, 2012
7b98780
missed a file
digi604 Nov 16, 2012
f2aa4b2
cleanup
digi604 Nov 16, 2012
ba8b26a
cleanup2
digi604 Nov 16, 2012
7b5771f
using localhost for postgres
digi604 Nov 16, 2012
a4c52dd
Merge branch 'develop' into multidb_test
digi604 Nov 28, 2012
9de0131
fixed signals
digi604 Nov 29, 2012
2cb2e29
Merge branch 'develop' into multidb_test
digi604 Dec 17, 2012
7d57ccb
new database url scheme
digi604 Dec 17, 2012
c4eeead
fixed some postgres errors
digi604 Dec 17, 2012
679339a
python2.5 compat
digi604 Dec 17, 2012
a8d9176
cleanup
digi604 Dec 17, 2012
4399297
memory db for sqlite
digi604 Dec 18, 2012
58fd55a
Merge branch 'develop' into multidb_test
digi604 Dec 18, 2012
08de803
signal merge errors
digi604 Dec 18, 2012
42ae4bf
usage of db urls and cleanup
digi604 Dec 18, 2012
de89569
missing requirement
digi604 Dec 18, 2012
4b84a9d
cleanup2
digi604 Dec 18, 2012
89f09ac
travis error?
digi604 Dec 18, 2012
4cc8959
yaml syntax error
digi604 Dec 18, 2012
1acbc78
syntax fix
digi604 Dec 18, 2012
113e386
skip added
digi604 Dec 19, 2012
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
16 changes: 13 additions & 3 deletions .travis.yml
Expand Up @@ -4,12 +4,22 @@ python:
- "2.6"
- "2.7"
env:
- DJANGO=test_requirements/django-1.3.txt
- DJANGO=test_requirements/django-1.4.txt
- DJANGO=test_requirements/django-1.3.txt DB='sqlite://localhost/:memory:'
- DJANGO=test_requirements/django-1.3.txt DB='mysql://root@127.0.0.1/djangocms_test'
- DJANGO=test_requirements/django-1.3.txt DB='postgres://postgres@127.0.0.1/djangocms_test'
- DJANGO=test_requirements/django-1.4.txt DB='sqlite://localhost/:memory:'
- DJANGO=test_requirements/django-1.4.txt DB='mysql://root@127.0.0.1/djangocms_test'
- DJANGO=test_requirements/django-1.4.txt DB='postgres://postgres@127.0.0.1/djangocms_test'

before_script:
- sh -c "if [ '$DB' = 'postgres://postgres@127.0.0.1/djangocms_test' ]; then psql -c 'DROP DATABASE IF EXISTS djangocms_test;' -U postgres; fi"
- sh -c "if [ '$DB' = 'postgres://postgres@127.0.0.1/djangocms_test' ]; then psql -c 'create database djangocms_test;' -U postgres; fi"
- sh -c "if [ '$DB' = 'mysql://root@127.0.0.1/djangocms_test' ]; then mysql -e 'create database IF NOT EXISTS djangocms_test CHARACTER SET utf8 COLLATE utf8_general_ci;'; fi"

install:
- pip install -q -r $DJANGO --use-mirrors
script:
python runtests.py
python runtests.py --db $DB
notifications:
email:
recipients:
Expand Down
2 changes: 1 addition & 1 deletion cms/models/managers.py
Expand Up @@ -340,7 +340,7 @@ def for_page(self, page):
"""
# permissions should be managed on the draft page only
page = page.get_draft_object()
from cms.models import ACCESS_DESCENDANTS, ACCESS_CHILDREN,\
from cms.models import ACCESS_DESCENDANTS, ACCESS_CHILDREN, \
ACCESS_PAGE_AND_CHILDREN, ACCESS_PAGE_AND_DESCENDANTS
# code taken from
# https://github.com/divio/django-cms/issues/1113#issuecomment-3376790
Expand Down
29 changes: 18 additions & 11 deletions cms/models/pagemodel.py
Expand Up @@ -20,6 +20,7 @@
from menus.menu_pool import menu_pool
from mptt.models import MPTTModel
from os.path import join
from datetime import timedelta
import copy


Expand Down Expand Up @@ -71,8 +72,8 @@ class Page(MPTTModel):
# Publisher fields
moderator_state = models.SmallIntegerField(_('moderator state'), default=0, blank=True, editable=False)
publisher_is_draft = models.BooleanField(default=1, editable=False, db_index=True)
#This is misnamed - the one-to-one relation is populated on both ends
publisher_public = models.OneToOneField('self', related_name='publisher_draft', null=True, editable=False)
# This is misnamed - the one-to-one relation is populated on both ends
publisher_public = models.OneToOneField('self', related_name='publisher_draft', null=True, editable=False)
publisher_state = models.SmallIntegerField(default=0, editable=False, db_index=True)

# Managers
Expand Down Expand Up @@ -134,7 +135,7 @@ def move_page(self, target, position='first-child'):
import cms.signals as cms_signals
cms_signals.page_moved.send(sender=Page, instance=self) # titles get saved before moderation
self.save() # always save the page after move, because of publisher
moderator.page_changed(self, force_moderation_action = PageModeratorState.ACTION_MOVE)
moderator.page_changed(self, force_moderation_action=PageModeratorState.ACTION_MOVE)
# check the slugs
page_utils.check_title_slugs(self)

Expand Down Expand Up @@ -302,7 +303,7 @@ def copy_page(self, target, site, position='first-child',

# invalidate the menu for this site
menu_pool.clear(site_id=site.pk)
return page_copy # return the page_copy or None
return page_copy # return the page_copy or None

def save(self, no_signals=False, commit=True, **kwargs):
"""
Expand All @@ -318,7 +319,7 @@ def save(self, no_signals=False, commit=True, **kwargs):
# Published pages should always have a publication date
# if the page is published we set the publish date if not set yet.
if self.publication_date is None and self.published:
self.publication_date = timezone.now()
self.publication_date = timezone.now() - timedelta(seconds=5)

if self.reverse_id == "":
self.reverse_id = None
Expand Down Expand Up @@ -371,6 +372,8 @@ def publish(self):

if not self.pk:
self.save()
if not self.parent_id:
self.clear_home_pk_cache()
if self._publisher_can_publish():
if self.publisher_public_id:
# Ensure we have up to date mptt properties
Expand Down Expand Up @@ -462,7 +465,7 @@ def unpublish(self):
if not self.publisher_is_draft:
raise PublicIsUnmodifiable('The public instance cannot be unpublished. Use draft.')

#First, make sure we are in the correct state
# First, make sure we are in the correct state
self.published = False
self.save()
public_page = self.get_public_object()
Expand Down Expand Up @@ -533,7 +536,7 @@ def delete_with_public(self):
"""
descendants = list(self.get_descendants().order_by('level'))
descendants.reverse()
#TODO: Use a better exception class - PermissionDenied is not quite right
# TODO: Use a better exception class - PermissionDenied is not quite right
for page in descendants:
if not page.delete_requested():
raise PermissionDenied('There are descendant pages not marked for deletion')
Expand Down Expand Up @@ -593,7 +596,7 @@ def get_cached_ancestors(self, ascending=True):
self.ancestors_descending = list(self.get_ancestors(ascending))
return self.ancestors_descending

### Title object access
# ## Title object access

def get_title_obj(self, language=None, fallback=True, version_id=None, force_reload=False):
"""Helper function for accessing wanted / current title.
Expand Down Expand Up @@ -776,7 +779,7 @@ def has_view_permission(self, request):
return (user_perm or generic_perm)

else:
#anonymous user
# anonymous user
if is_restricted or not settings.CMS_PUBLIC_FOR == 'all':
# anyonymous user, page has restriction and global access is permitted
return False
Expand Down Expand Up @@ -860,15 +863,19 @@ def is_home(self):

def get_home_pk_cache(self):
attr = "%s_home_pk_cache_%s" % (self.publisher_is_draft and "draft" or "public", self.site_id)
if not hasattr(self, attr):
if getattr(self, attr, None) is None:
setattr(self, attr, self.get_object_queryset().get_home(self.site).pk)
return getattr(self, attr)

def set_home_pk_cache(self, value):

attr = "%s_home_pk_cache_%s" % (self.publisher_is_draft and "draft" or "public", self.site_id)
setattr(self, attr, value)
home_pk_cache = property(get_home_pk_cache, set_home_pk_cache)

def clear_home_pk_cache(self):
self.home_pk_cache = None

def get_media_path(self, filename):
"""
Returns path (relative to MEDIA_ROOT/MEDIA_URL) to directory for storing page-scope files.
Expand Down Expand Up @@ -1022,7 +1029,7 @@ def _publisher_save_public(self, obj):
prev_sibling = self.get_previous_filtered_sibling(**filters)
public_prev_sib = prev_sibling.publisher_public if prev_sibling else None

if not self.publisher_public_id: # first time published
if not self.publisher_public_id: # first time published
# is there anybody on left side?
if public_prev_sib:
obj.insert_at(public_prev_sib, position='right', save=False)
Expand Down
15 changes: 0 additions & 15 deletions cms/models/query.py
Expand Up @@ -68,21 +68,6 @@ def expired(self):
return self.on_site().filter(
publication_end_date__lte=timezone.now())

# - seems this is not used anymore...
# def get_pages_with_application(self, path, language):
# """Returns all pages containing application for current path, or
# any parrent. Returned list is sorted by path length, longer path first.
# """
# paths = levelize_path(path)
# q = Q()
# for path in paths:
# # build q for all the paths
# q |= Q(title_set__path=path, title_set__language=language)
# app_pages = self.published().filter(q & Q(title_set__application_urls__gt='')).distinct()
# # add proper ordering
# app_pages.query.order_by.extend(('LENGTH(`cms_title`.`path`) DESC',))
# return app_pages

def get_all_pages_with_application(self):
"""Returns all pages containing applications for all sites.

Expand Down
7 changes: 1 addition & 6 deletions cms/models/titlemodels.py
Expand Up @@ -31,12 +31,6 @@ class Meta:
def __unicode__(self):
return u"%s (%s, %s)" % (self.title, self.slug, self.language)

def save(self, *args, **kwargs):
# Update the path attribute before saving
# No longer needed since this is done in signals
#self.update_path()
super(Title, self).save(*args, **kwargs)

def update_path(self):
# Build path from parent page's path and slug
slug = u'%s' % self.slug
Expand All @@ -48,6 +42,7 @@ def update_path(self):
parent_title = Title.objects.get_title(parent_page, language=self.language, language_fallback=True)
if parent_title:
self.path = u'%s/%s' % (parent_title.path, slug)


@property
def overwrite_url(self):
Expand Down