Permalink
Browse files

almost done with venv stuff (=tons of failing tests :D)

  • Loading branch information...
ojii committed Jun 7, 2012
1 parent c81e780 commit 595d9092d95ceb45ae666b78a86a4c71ed395396
Showing with 1,389 additions and 9 deletions.
  1. +1 −0 .gitignore
  2. +192 −0 cms/test_utils/cli.py
  3. +1 −1 cms/test_utils/fixtures/fakemlng.py
  4. 0 cms/test_utils/project/__init__.py
  5. +25 −0 cms/test_utils/project/cms_urls_for_apphook_tests.py
  6. 0 cms/test_utils/project/fakemlng/__init__.py
  7. +1 −0 cms/test_utils/project/fakemlng/fixtures/fakemlng.json
  8. +14 −0 cms/test_utils/project/fakemlng/models.py
  9. 0 cms/test_utils/project/fileapp/__init__.py
  10. +7 −0 cms/test_utils/project/fileapp/models.py
  11. 0 cms/test_utils/project/models.py
  12. +13 −0 cms/test_utils/project/noadmin_urls.py
  13. +14 −0 cms/test_utils/project/nonroot_urls.py
  14. 0 cms/test_utils/project/placeholderapp/__init__.py
  15. +87 −0 cms/test_utils/project/placeholderapp/admin.py
  16. +38 −0 cms/test_utils/project/placeholderapp/models.py
  17. +9 −0 cms/test_utils/project/placeholderapp/views.py
  18. 0 cms/test_utils/project/pluginapp/__init__.py
  19. +15 −0 cms/test_utils/project/pluginapp/models.py
  20. 0 cms/test_utils/project/pluginapp/plugins/__init__.py
  21. 0 cms/test_utils/project/pluginapp/plugins/manytomany_rel/__init__.py
  22. +24 −0 cms/test_utils/project/pluginapp/plugins/manytomany_rel/cms_plugins.py
  23. +16 −0 cms/test_utils/project/pluginapp/plugins/manytomany_rel/models.py
  24. 0 cms/test_utils/project/sampleapp/__init__.py
  25. +11 −0 cms/test_utils/project/sampleapp/admin.py
  26. +11 −0 cms/test_utils/project/sampleapp/cms_app.py
  27. BIN cms/test_utils/project/sampleapp/media/sampleapp/img/gift.jpg
  28. +62 −0 cms/test_utils/project/sampleapp/menu.py
  29. +27 −0 cms/test_utils/project/sampleapp/models.py
  30. +5 −0 cms/test_utils/project/sampleapp/templates/sampleapp/category_view.html
  31. +21 −0 cms/test_utils/project/sampleapp/templates/sampleapp/home.html
  32. +14 −0 cms/test_utils/project/sampleapp/urls.py
  33. +17 −0 cms/test_utils/project/sampleapp/views.py
  34. +25 −0 cms/test_utils/project/second_cms_urls_for_apphook_tests.py
  35. +16 −0 cms/test_utils/project/second_urls_for_apphook_tests.py
  36. +11 −0 cms/test_utils/project/templates/404.html
  37. +3 −0 cms/test_utils/project/templates/add_placeholder.html
  38. +43 −0 cms/test_utils/project/templates/base.html
  39. +32 −0 cms/test_utils/project/templates/col_three.html
  40. +24 −0 cms/test_utils/project/templates/col_two.html
  41. +1 −0 cms/test_utils/project/templates/extra_context.html
  42. +41 −0 cms/test_utils/project/templates/fail.html
  43. +3 −0 cms/test_utils/project/templates/menu/breadcrumb.html
  44. +4 −0 cms/test_utils/project/templates/menu/language_chooser.html
  45. +22 −0 cms/test_utils/project/templates/menu/menu.html
  46. +1 −0 cms/test_utils/project/templates/menu/sub_menu.html
  47. +1 −0 cms/test_utils/project/templates/menu/test_language_chooser.html
  48. +165 −0 cms/test_utils/project/templates/nav_playground.html
  49. +13 −0 cms/test_utils/project/templates/placeholder_tests/base.html
  50. +3 −0 cms/test_utils/project/templates/placeholder_tests/child.html
  51. +7 −0 cms/test_utils/project/templates/placeholder_tests/nested_super_level1.html
  52. +7 −0 cms/test_utils/project/templates/placeholder_tests/nested_super_level2.html
  53. +7 −0 cms/test_utils/project/templates/placeholder_tests/nested_super_level3.html
  54. +5 −0 cms/test_utils/project/templates/placeholder_tests/nested_super_level4.html
  55. +14 −0 cms/test_utils/project/templates/placeholder_tests/outside.html
  56. +11 −0 cms/test_utils/project/templates/placeholder_tests/outside_base.html
  57. +1 −0 cms/test_utils/project/templates/placeholder_tests/outside_nested.html
  58. +5 −0 cms/test_utils/project/templates/placeholder_tests/test_eleven.html
  59. +21 −0 cms/test_utils/project/templates/placeholder_tests/test_five.html
  60. +22 −0 cms/test_utils/project/templates/placeholder_tests/test_four.html
  61. +16 −0 cms/test_utils/project/templates/placeholder_tests/test_one.html
  62. +17 −0 cms/test_utils/project/templates/placeholder_tests/test_seven.html
  63. +25 −0 cms/test_utils/project/templates/placeholder_tests/test_six.html
  64. +17 −0 cms/test_utils/project/templates/placeholder_tests/test_three.html
  65. +17 −0 cms/test_utils/project/templates/placeholder_tests/test_two.html
  66. +9 −0 cms/test_utils/project/templates/placeholderapp.html
  67. +3 −0 cms/test_utils/project/templates/sidebar_submenu.html
  68. +9 −0 cms/test_utils/project/templates/sidebar_submenu_root.html
  69. +1 −0 cms/test_utils/project/templates/subdir/template.html
  70. +3 −0 cms/test_utils/project/templates/unicode_placeholder.html
  71. +18 −0 cms/test_utils/project/urls.py
  72. +16 −0 cms/test_utils/project/urls_for_apphook_tests.py
  73. +51 −0 cms/test_utils/runners.py
  74. +7 −0 cms/test_utils/util/urls.py
  75. +4 −5 cms/tests/placeholder.py
  76. +3 −2 cms/tests/plugins.py
  77. +1 −1 cms/tests/reversion_tests.py
  78. +39 −0 runtests.py
View
@@ -7,6 +7,7 @@ cms/django
*.svn
.*
*.xml
+/*env*/
cms.sqlite
cms/media/cms_page_media/
cms/docs/build
View
@@ -0,0 +1,192 @@
+# -*- coding: utf-8 -*-
+import os
+
+gettext = lambda s: s
+
+
+urlpatterns = []
+
+
+def configure(**extra):
+ from django.conf import settings
+ os.environ['DJANGO_SETTINGS_MODULE'] = 'cms.test_utils.cli'
+ defaults = dict(
+ CACHE_BACKEND = 'locmem:///',
+ DEBUG = True,
+ TEMPLATE_DEBUG = True,
+ DATABASE_SUPPORTS_TRANSACTIONS = True,
+ DATABASES = {
+ 'default': {
+ 'ENGINE': 'django.db.backends.postgresql_psycopg2',
+ 'NAME': 'cmstest',
+ 'USER': 'cmstest',
+ 'PASSWORD': 'cmstest',
+ 'PORT': 5433,
+ }
+ },
+ SITE_ID = 1,
+ USE_I18N = True,
+ MEDIA_ROOT = '/media/',
+ STATIC_ROOT = '/static/',
+ CMS_MEDIA_ROOT = '/cms-media/',
+ CMS_MEDIA_URL = '/cms-media/',
+ MEDIA_URL = '/media/',
+ STATIC_URL = '/static/',
+ ADMIN_MEDIA_PREFIX = '/static/admin/',
+ EMAIL_BACKEND = 'django.core.mail.backends.locmem.EmailBackend',
+ SECRET_KEY = 'key',
+ TEMPLATE_LOADERS = (
+ 'django.template.loaders.filesystem.Loader',
+ 'django.template.loaders.app_directories.Loader',
+ 'django.template.loaders.eggs.Loader',
+ ),
+ TEMPLATE_CONTEXT_PROCESSORS = [
+ "django.contrib.auth.context_processors.auth",
+ "django.core.context_processors.i18n",
+ "django.core.context_processors.debug",
+ "django.core.context_processors.request",
+ "django.core.context_processors.media",
+ 'django.core.context_processors.csrf',
+ "cms.context_processors.media",
+ "sekizai.context_processors.sekizai",
+ "django.core.context_processors.static",
+ ],
+ TEMPLATE_DIRS = [
+ os.path.abspath(os.path.join(os.path.dirname(__file__), 'project', 'templates'))
+ ],
+ MIDDLEWARE_CLASSES = [
+ 'django.contrib.sessions.middleware.SessionMiddleware',
+ 'cms.middleware.multilingual.MultilingualURLMiddleware',
+ 'django.contrib.auth.middleware.AuthenticationMiddleware',
+ 'django.contrib.messages.middleware.MessageMiddleware',
+ 'django.middleware.common.CommonMiddleware',
+ 'django.middleware.doc.XViewMiddleware',
+ 'django.middleware.csrf.CsrfViewMiddleware',
+ 'cms.middleware.user.CurrentUserMiddleware',
+ 'cms.middleware.page.CurrentPageMiddleware',
+ 'cms.middleware.toolbar.ToolbarMiddleware',
+ ],
+ INSTALLED_APPS = [
+ 'django.contrib.auth',
+ 'django.contrib.contenttypes',
+ 'django.contrib.sessions',
+ 'django.contrib.admin',
+ 'django.contrib.sites',
+ 'django.contrib.staticfiles',
+ 'cms',
+ 'menus',
+ 'mptt',
+ 'cms.plugins.text',
+ 'cms.plugins.picture',
+ 'cms.plugins.file',
+ 'cms.plugins.flash',
+ 'cms.plugins.link',
+ 'cms.plugins.snippet',
+ 'cms.plugins.googlemap',
+ 'cms.plugins.teaser',
+ 'cms.plugins.video',
+ 'cms.plugins.twitter',
+ 'cms.plugins.inherit',
+ 'cms.test_utils.project.sampleapp',
+ 'cms.test_utils.project.placeholderapp',
+ 'cms.test_utils.project.pluginapp',
+ 'cms.test_utils.project.pluginapp.plugins.manytomany_rel',
+ 'cms.test_utils.project.fakemlng',
+ 'cms.test_utils.project.fileapp',
+ 'south',
+ 'reversion',
+ 'sekizai',
+ ],
+ LANGUAGE_CODE = "en",
+ LANGUAGES = (
+ ('en', gettext('English')),
+ ('fr', gettext('French')),
+ ('de', gettext('German')),
+ ('pt-BR', gettext("Brazil")),
+ ('nl', gettext("Dutch")),
+ ),
+ CMS_LANGUAGES = (
+ ('en', gettext('English')),
+ ('fr', gettext('French')),
+ ('de', gettext('German')),
+ ('pt-BR', gettext("Brazil")),
+ ('nl', gettext("Dutch")),
+ ),
+ CMS_LANGUAGE_CONF = {
+ 'de':['fr', 'en'],
+ 'en':['fr', 'de'],
+ },
+ CMS_TEMPLATES = (
+ ('col_two.html', gettext('two columns')),
+ ('col_three.html', gettext('three columns')),
+ ('nav_playground.html', gettext('navigation examples')),
+ ),
+ CMS_PLACEHOLDER_CONF = {
+ 'col_sidebar': {
+ 'plugins': ('FilePlugin', 'FlashPlugin', 'LinkPlugin', 'PicturePlugin',
+ 'TextPlugin', 'SnippetPlugin'),
+ 'name': gettext("sidebar column")
+ },
+
+ 'col_left': {
+ 'plugins': ('FilePlugin', 'FlashPlugin', 'LinkPlugin', 'PicturePlugin',
+ 'TextPlugin', 'SnippetPlugin','GoogleMapPlugin',),
+ 'name': gettext("left column")
+ },
+
+ 'col_right': {
+ 'plugins': ('FilePlugin', 'FlashPlugin', 'LinkPlugin', 'PicturePlugin',
+ 'TextPlugin', 'SnippetPlugin','GoogleMapPlugin',),
+ 'name': gettext("right column")
+ },
+ 'extra_context': {
+ "plugins": ('TextPlugin',),
+ "extra_context": {"width": 250},
+ "name": "extra context"
+ },
+ },
+ CMS_SOFTROOT = True,
+ CMS_MODERATOR = True,
+ CMS_PERMISSION = True,
+ CMS_PUBLIC_FOR = 'all',
+ CMS_CACHE_DURATIONS = {
+ 'menus': 0,
+ 'content': 0,
+ 'permissions': 0,
+ },
+ CMS_APPHOOKS=[],
+ CMS_REDIRECTS = True,
+ CMS_SEO_FIELDS = True,
+ CMS_FLAT_URLS = False,
+ CMS_MENU_TITLE_OVERWRITE = True,
+ CMS_HIDE_UNTRANSLATED = False,
+ CMS_URL_OVERWRITE = True,
+ CMS_SHOW_END_DATE = True,
+ CMS_SHOW_START_DATE = True,
+ CMS_PLUGIN_PROCESSORS = tuple(),
+ CMS_PLUGIN_CONTEXT_PROCESSORS = tuple(),
+ CMS_SITE_CHOICES_CACHE_KEY = 'CMS:site_choices',
+ CMS_PAGE_CHOICES_CACHE_KEY = 'CMS:page_choices',
+ SOUTH_TESTS_MIGRATE = False,
+ CMS_NAVIGATION_EXTENDERS = (
+ ('cms.test_utils.project.sampleapp.menu_extender.get_nodes', 'SampleApp Menu'),
+ ),
+ TEST_RUNNER = 'cms.test_utils.runners.NormalTestRUnner',
+ JUNIT_OUTPUT_DIR = '.',
+ TIME_TESTS = False,
+ ROOT_URLCONF = 'cms.test_utils.cli',
+ )
+ defaults.update(extra)
+ settings.configure(**defaults)
+ from cms.conf import patch_settings
+ patch_settings()
+ from south.management.commands import patch_for_test_db_setup
+ patch_for_test_db_setup()
+ from django.core.urlresolvers import set_urlconf
+ from django.utils.importlib import import_module
+ from django.contrib import admin
+ admin.autodiscover()
+ set_urlconf(settings.ROOT_URLCONF)
+ module = import_module(__name__)
+ for key, value in defaults.items():
+ setattr(module, key, value)
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
from cms.api import add_plugin
-from project.fakemlng.models import MainModel, Translations
+from cms.test_utils.project.fakemlng.models import MainModel, Translations
class FakemlngFixtures(object):
def create_fixtures(self):
No changes.
@@ -0,0 +1,25 @@
+from cms.apphook_pool import apphook_pool
+from cms.views import details
+from django.conf import settings
+from django.conf.urls.defaults import url, patterns
+
+if settings.APPEND_SLASH:
+ reg = url(r'^(?P<slug>[0-9A-Za-z-_.//]+)/$', details, name='pages-details-by-slug')
+else:
+ reg = url(r'^(?P<slug>[0-9A-Za-z-_.//]+)$', details, name='pages-details-by-slug')
+
+urlpatterns = [
+ # Public pages
+ url(r'^$', details, {'slug':''}, name='pages-root'),
+ reg,
+]
+
+if apphook_pool.get_apphooks():
+ """If there are some application urls, add special resolver, so we will
+ have standard reverse support.
+ """
+ from cms.appresolver import get_app_patterns
+ urlpatterns = get_app_patterns() + urlpatterns
+ #urlpatterns = (dynamic_app_regex_url_resolver, ) + urlpatterns
+
+urlpatterns = patterns('', *urlpatterns)
@@ -0,0 +1 @@
+[{"pk": 1, "model": "cms.placeholder", "fields": {"slot": "translated", "default_width": null}}, {"pk": 2, "model": "cms.placeholder", "fields": {"slot": "translated", "default_width": null}}, {"pk": 3, "model": "cms.placeholder", "fields": {"slot": "translated", "default_width": null}}, {"pk": 4, "model": "cms.placeholder", "fields": {"slot": "translated", "default_width": null}}, {"pk": 5, "model": "cms.placeholder", "fields": {"slot": "translated", "default_width": null}}, {"pk": 6, "model": "cms.placeholder", "fields": {"slot": "translated", "default_width": null}}, {"pk": 7, "model": "cms.placeholder", "fields": {"slot": "translated", "default_width": null}}, {"pk": 1, "model": "cms.cmsplugin", "fields": {"rght": 2, "parent": null, "language": "en", "level": 0, "creation_date": "2011-01-04 08:52:59", "lft": 1, "tree_id": 1, "position": null, "placeholder": 6, "plugin_type": "TextPlugin"}}, {"pk": 2, "model": "cms.cmsplugin", "fields": {"rght": 2, "parent": null, "language": "en", "level": 0, "creation_date": "2011-01-04 08:53:28", "lft": 1, "tree_id": 2, "position": null, "placeholder": 5, "plugin_type": "TextPlugin"}}, {"pk": 1, "model": "text.text", "fields": {"body": "<p>FRENCH!</p>", "cmsplugin_ptr": 1}}, {"pk": 2, "model": "text.text", "fields": {"body": "<p>ENGLISH</p>", "cmsplugin_ptr": 2}}, {"pk": 1, "model": "fakemlng.mainmodel", "fields": {}}, {"pk": 1, "model": "fakemlng.translations", "fields": {"placeholder": 4, "master": 1, "language_code": "de"}}, {"pk": 2, "model": "fakemlng.translations", "fields": {"placeholder": 5, "master": 1, "language_code": "en"}}, {"pk": 3, "model": "fakemlng.translations", "fields": {"placeholder": 6, "master": 1, "language_code": "fr"}}, {"pk": 4, "model": "fakemlng.translations", "fields": {"placeholder": null, "master": 1, "language_code": "nl"}}]
@@ -0,0 +1,14 @@
+from cms.models.fields import PlaceholderField
+from django.db import models
+
+
+class MainModel(models.Model):
+ pass
+
+class Translations(models.Model):
+ master = models.ForeignKey(MainModel)
+ language_code = models.CharField(max_length=15, db_index=True)
+ placeholder = PlaceholderField('translated', null=True)
+
+ class Meta:
+ unique_together = [('master', 'language_code')]
No changes.
@@ -0,0 +1,7 @@
+from cms.utils.helpers import reversion_register
+from django.db import models
+
+class FileModel(models.Model):
+ test_file = models.FileField(upload_to='fileapp/', blank=True, null=True)
+
+reversion_register(FileModel)
No changes.
@@ -0,0 +1,13 @@
+from django.conf import settings
+from django.conf.urls.defaults import handler500, handler404, patterns, include, \
+ url
+
+
+urlpatterns = patterns('',
+ url(r'^jsi18n/(?P<packages>\S+?)/$', 'django.views.i18n.javascript_catalog'),
+ url(r'^media/cms/(?P<path>.*)$', 'django.views.static.serve',
+ {'document_root': settings.CMS_MEDIA_ROOT, 'show_indexes': True}),
+ url(r'^media/(?P<path>.*)$', 'django.views.static.serve',
+ {'document_root': settings.MEDIA_ROOT, 'show_indexes': True}),
+ url(r'^', include('cms.urls')),
+)
@@ -0,0 +1,14 @@
+from django.conf import settings
+from django.conf.urls.defaults import handler500, handler404, patterns, include, \
+ url
+from django.contrib import admin
+
+admin.autodiscover()
+
+urlpatterns = patterns('',
+ (r'^admin/', include(admin.site.urls)),
+ (r'^jsi18n/(?P<packages>\S+?)/$', 'django.views.i18n.javascript_catalog'),
+ url(r'^media/cms/(?P<path>.*)$', 'django.views.static.serve', {'document_root': settings.CMS_MEDIA_ROOT, 'show_indexes': True}),
+ url(r'^media/(?P<path>.*)$', 'django.views.static.serve', {'document_root': settings.MEDIA_ROOT, 'show_indexes': True}),
+ url(r'^content/', include('cms.urls')),
+)
@@ -0,0 +1,87 @@
+from cms.admin.placeholderadmin import PlaceholderAdmin
+from cms.test_utils.project.placeholderapp.models import (Example1, Example2,
+ Example3, Example4, Example5)
+from django.contrib import admin
+
+
+class MixinAdmin(admin.ModelAdmin):
+ def formfield_for_dbfield(self, db_field, **kwargs):
+ """
+ Hook for specifying the form Field instance for a given database Field
+ instance.
+
+ If kwargs are given, they're passed to the form Field's constructor.
+ """
+ # silly test that placeholderadmin doesn't fuck stuff up
+ request = kwargs.pop('request', None)
+ return super(MixinAdmin, self).formfield_for_dbfield(db_field, request=request, **kwargs)
+
+
+class Example1Admin(PlaceholderAdmin, MixinAdmin):
+ pass
+
+class Example2Admin(PlaceholderAdmin):
+ fieldsets = (
+ ('Placeholder + more fields', {
+ 'classes': ('wide',),
+ 'fields': ('char_1', 'placeholder', 'char_2',)
+ }),
+ ('Other fields', {
+ 'classes': ('wide',),
+ 'fields': ('char_3', 'char_4',)
+ }),
+ )
+
+class Example3Admin(PlaceholderAdmin):
+ fieldsets = (
+ ('Only chars', {
+ 'classes': ('wide',),
+ 'fields': ('char_1', 'char_2',)
+ }),
+ (u'Only Placeholder with rigth classes', {
+ 'classes': ('plugin-holder', 'plugin-holder-nopage',),
+ 'fields': ('placeholder',)
+ }),
+ ('Only chars', {
+ 'classes': ('wide',),
+ 'fields': ('char_3', 'char_4',)
+ }),
+ )
+
+class Example4Admin(PlaceholderAdmin):
+ fieldsets = (
+ ('Only chars', {
+ 'classes': ('wide',),
+ 'fields': ('char_1', 'char_2',)
+ }),
+ (u'Only Placeholder, with wrong classes', {
+ 'classes': ('wide', 'plugin-holder-nopage',),
+ 'fields': ('placeholder',)
+ }),
+ ('Only chars', {
+ 'classes': ('wide',),
+ 'fields': ('char_3', 'char_4',)
+ }),
+ )
+
+class Example5Admin(PlaceholderAdmin):
+ fieldsets = (
+ ('Only chars', {
+ 'classes': ('wide',),
+ 'fields': ('char_1', 'char_2',)
+ }),
+ (u'Two Placeholder, with right classes', {
+ 'classes': ('plugin', 'plugin-holder-nopage',),
+ 'fields': ('placeholder_1', 'placeholder_2',)
+ }),
+ ('Only chars', {
+ 'classes': ('wide',),
+ 'fields': ('char_3', 'char_4',)
+ }),
+ )
+
+admin.site.register(Example1, Example1Admin)
+admin.site.register(Example2, Example2Admin)
+admin.site.register(Example3, Example3Admin)
+admin.site.register(Example4, Example4Admin)
+admin.site.register(Example5, Example5Admin)
Oops, something went wrong.

0 comments on commit 595d909

Please sign in to comment.