Skip to content

Commit

Permalink
travis: start testing mysql
Browse files Browse the repository at this point in the history
  • Loading branch information
ergo committed Oct 23, 2016
1 parent a84473f commit e56401a
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 8 deletions.
5 changes: 5 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ matrix:
- python: "3.4"
env: BCRYPT="enabled" DB_STRING="postgres://postgres@127.0.0.1:5432/test"

- python: "3.4"
env: BCRYPT="enabled" DB_STRING="mysql+mysqlconnector://travis@localhost/test" MYSQL=1

- python: "3.5"
env: BCRYPT="enabled" DB_STRING="postgres://postgres@127.0.0.1:5432/test"

Expand All @@ -43,13 +46,15 @@ install:

before_script:
- psql -c 'create database test;' -U postgres
- if [ -n "$MYSQL" ]; then mysql -e 'create database test;'; fi

script:
- python setup.py develop
- if [ -n "$BCRYPT" ]; then pip install bcrypt; fi
- if [ -n "$PYBCRYPT" ]; then pip install py-bcrypt; fi
- if [ -n "$BCRYPT" ]; then pip install psycopg2; fi
- if [ -n "$PYBCRYPT" ]; then pip install psycopg2cffi; fi
- if [ -n "$MYSQL" ]; then pip install mysql-connector-python; fi
- py.test ziggurat_foundations/tests/

# flake8 and rstcheck
Expand Down
9 changes: 6 additions & 3 deletions ziggurat_foundations/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,18 @@
from ziggurat_foundations.models.group_permission import GroupPermissionMixin
from ziggurat_foundations.models.user_permission import UserPermissionMixin
from ziggurat_foundations.models.user_group import UserGroupMixin
from ziggurat_foundations.models.user_resource_permission import UserResourcePermissionMixin
from ziggurat_foundations.models.group_resource_permission import GroupResourcePermissionMixin
from ziggurat_foundations.models.user_resource_permission import \
UserResourcePermissionMixin
from ziggurat_foundations.models.group_resource_permission import \
GroupResourcePermissionMixin
from ziggurat_foundations.models.resource import ResourceMixin
from ziggurat_foundations.models.external_identity import ExternalIdentityMixin

is_mysql = 'mysql' in os.environ.get("DB_STRING", '').lower()

Base = declarative_base()


class Group(GroupMixin, Base):
__possible_permissions__ = ('root_administration',
'administration',
Expand Down Expand Up @@ -86,7 +90,6 @@ class User(UserMixin, Base):
ExternalIdentity)



@pytest.fixture
def db_session(request):
sql_str = os.environ.get("DB_STRING", 'sqlite://', )
Expand Down
8 changes: 3 additions & 5 deletions ziggurat_foundations/tests/test_resource.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,14 @@
from __future__ import with_statement, unicode_literals
import pytest

from ziggurat_foundations.permissions import PermissionTuple, ALL_PERMISSIONS

from ziggurat_foundations.tests import (
add_user, check_one_in_other, add_resource, add_resource_b, add_group,
BaseTestCase)
from ziggurat_foundations.tests.conftest import Resource
add_resource, BaseTestCase)
from ziggurat_foundations.tests.conftest import Resource, is_mysql
from ziggurat_foundations.models.services.resource import ResourceService


class TestResources(BaseTestCase):
@pytest.mark.skipif(is_mysql, reason="requires postgres")
def test_nesting(self, db_session):
root = add_resource(
db_session, -1, 'root', ordering=1)
Expand Down

0 comments on commit e56401a

Please sign in to comment.