Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Multidb testing for travis #1513

Merged
merged 29 commits into from

6 participants

@digi604
Collaborator

testing the db testing here and hopefully fixing the broken tests

@digi604
Collaborator

mysql: (failures=26, errors=103, skipped=1)
postgres: (failures=7, errors=4)

@digi604
Collaborator

Referencing some tickets: #1032, #1477

@ojii
Collaborator

As mentioned on #1477, is there a way to signal this through a single command line arg/env variable (DATABASE_URL?)?

On travis we should be able to just change the script to DATABSE_URL="$DB://root@localhost/djangocms_test" python runtests.py

Would make it a lot easier to run locally instead of having to pass (up to) 4 arguments to the script.

@ojii
Collaborator
cms/tests/menu.py
((6 lines not shown))
def test_show_menu_num_queries(self):
context = self.get_context()
# test standard show_menu
- with self.assertNumQueries(5):
- """
- The queries should be:
- get all pages
- get all page permissions
- get all titles
- get the menu cache key
- set the menu cache key
- """
- tpl = Template("{% load menu_tags %}{% show_menu %}")
- tpl.render(context)
+ if settings.DATABASES['default']['ENGINE'] == 'django.db.backends.sqlite':
@ojii Collaborator
ojii added a note

why this check?!

@digi604 Collaborator
digi604 added a note

mysql innodb and postgres have transaction queries.

@ojii Collaborator
ojii added a note

isn't this a Django bug then? Is this tracked somewhere?

Also since this test only does assertNumQueries (according to the name), why not use a conditional unittest.skip decorator?

@digi604 Collaborator
digi604 added a note

which would you use?

@digi604 Collaborator
digi604 added a note

@skipIfDBFeature('supports_transactions') does not work as it will skip for sqlite as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
cms/test_utils/cli.py
((5 lines not shown))
gettext = lambda s: s
urlpatterns = []
DJANGO_1_3 = LooseVersion(django.get_version()) < LooseVersion('1.4')
-def configure(**extra):
+def configure(db_url, **extra):
+ splits = db_url.split("://")
@ojii Collaborator
ojii added a note

why not use dj_database_url here? This looks just insane, no offense. At the very least use urlparse properly here.

@digi604 Collaborator
digi604 added a note

python 2.5 urlparse does not like custom url schemes... needed to do that this way

@ojii Collaborator
ojii added a note
jonas:~ python2.5
Python 2.5.6 (r256:88840, Dec 16 2011, 14:22:12) 
[GCC 4.6.1] on linux3
Type "help", "copyright", "credits" or "license" for more information.
>>> from dj_database_url import parse
>>> parse('postgres://user:password@host:1191/dbname')
{'ENGINE': 'django.db.backends.postgresql_psycopg2', 'NAME': 'dbname', 'HOST': 'host', 'USER': 'user', 'PASSWORD': 'password', 'PORT': 1191}

where's the problem?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
cms/models/pagemodel.py
@@ -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 not hasattr(self, attr) or getattr(self, attr) is None:

This could probably be simplified out to:

if getattr(self, attr, None) is None:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
cms/test_utils/cli.py
((40 lines not shown))
+ },
+ }
+ if db_splits.username:
+ DB['USER'] = db_splits.username
+ if db_splits.password:
+ DB['PASSWORD'] = db_splits.password
+ if db_splits.hostname:
+ DB['HOST'] = db_splits.hostname
+ try:
+ if db_splits.port:
+ DB['PORT'] = db_splits.port
+ except ValueError:
+ pass
+ else:
+ DB = {}
+ print DB

No prints in the test code, please

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@digi604
Collaborator

please check again

@digi604 digi604 merged commit 9c70a95 into divio:develop
@digi604 digi604 deleted the digi604:multidb_test branch
@coveralls

Coverage Status

Changes Unknown when pulling 113e386 on digi604:multidb_test into ** on divio:develop**.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Oct 12, 2012
  1. @yakky
Commits on Nov 14, 2012
  1. @digi604

    Merge branch 'develop' into yakky-feature/multidb_test

    digi604 authored
    Conflicts:
    	cms/test_utils/cli.py
    	runtests.py
  2. @digi604

    multi db testing

    digi604 authored
  3. @digi604

    actually use the db env

    digi604 authored
Commits on Nov 15, 2012
  1. @digi604
Commits on Nov 16, 2012
  1. @digi604
  2. @digi604
  3. @digi604
  4. @digi604

    missed a file

    digi604 authored
  5. @digi604

    cleanup

    digi604 authored
  6. @digi604

    cleanup2

    digi604 authored
  7. @digi604

    using localhost for postgres

    digi604 authored
Commits on Nov 28, 2012
  1. @digi604

    Merge branch 'develop' into multidb_test

    digi604 authored
    Conflicts:
    	cms/signals.py
    	cms/tests/page.py
Commits on Nov 29, 2012
  1. @digi604

    fixed signals

    digi604 authored
Commits on Dec 17, 2012
  1. @digi604

    Merge branch 'develop' into multidb_test

    digi604 authored
    Conflicts:
    	cms/tests/page.py
  2. @digi604

    new database url scheme

    digi604 authored
  3. @digi604

    fixed some postgres errors

    digi604 authored
  4. @digi604

    python2.5 compat

    digi604 authored
  5. @digi604

    cleanup

    digi604 authored
Commits on Dec 18, 2012
  1. @digi604

    memory db for sqlite

    digi604 authored
  2. @digi604

    Merge branch 'develop' into multidb_test

    digi604 authored
    Conflicts:
    	cms/models/pagemodel.py
    	cms/models/titlemodels.py
    	cms/signals.py
    	cms/tests/admin.py
  3. @digi604

    signal merge errors

    digi604 authored
  4. @digi604

    usage of db urls and cleanup

    digi604 authored
  5. @digi604

    missing requirement

    digi604 authored
  6. @digi604

    cleanup2

    digi604 authored
  7. @digi604

    travis error?

    digi604 authored
  8. @digi604

    yaml syntax error

    digi604 authored
  9. @digi604

    syntax fix

    digi604 authored
Commits on Dec 19, 2012
  1. @digi604

    skip added

    digi604 authored
Something went wrong with that request. Please try again.