Skip to content
Permalink
Browse files

Skipped some tests for MsSQL and changed travis to run jobs in two st…

…eps and avoid timeout during MsSQL jobs (#128)

Updated the configuration of travis to use marker to split unittest in case of MsSQL, because the time of execution is too long
  • Loading branch information...
GohuHQ authored and jssuzanne committed Sep 25, 2019
1 parent dcb88a6 commit 80bd38a7f8aabb0655214cfb165882cfeeef78f9
@@ -5,7 +5,6 @@ addons:
postgresql: "9.6"

python:
- "3.5"
- "3.6"
- "3.7"
- "3.7-dev"
@@ -15,17 +14,28 @@ python:
env:
global:
- ANYBLOK_DATABASE_NAME=travis_ci_test
- MARKERS=''
matrix:
- ANYBLOK_DATABASE_DRIVER=postgresql ANYBLOK_DATABASE_USER=postgres SQLSERVER='psql -c' SQLPYCLIENT='psycopg2-binary'
- ANYBLOK_DATABASE_DRIVER=mysql ANYBLOK_DATABASE_USER=travis SQLSERVER='mysql -e' SQLPYCLIENT='mysqlclient'
- |-
ANYBLOK_DATABASE_HOST=localhost \
ANYBLOK_DATABASE_PORT=1433 \
ANYBLOK_DATABASE_DRIVER=mssql+pymssql \
ANYBLOK_DATABASE_USER=sa \
ANYBLOK_DATABASE_PASSWORD=AnyBl@k2019 \
SQLSERVER='docker exec mssql /opt/mssql-tools/bin/sqlcmd -U sa -P AnyBl@k2019 -Q'
SQLPYCLIENT='pymssql'
ANYBLOK_DATABASE_HOST=localhost \
ANYBLOK_DATABASE_PORT=1433 \
ANYBLOK_DATABASE_DRIVER=mssql+pymssql \
ANYBLOK_DATABASE_USER=sa \
ANYBLOK_DATABASE_PASSWORD=AnyBl@k2019 \
SQLSERVER='docker exec mssql /opt/mssql-tools/bin/sqlcmd -U sa -P AnyBl@k2019 -Q' \
SQLPYCLIENT='pymssql' \
MARKERS='field or column or relationship'
- |-
ANYBLOK_DATABASE_HOST=localhost \
ANYBLOK_DATABASE_PORT=1433 \
ANYBLOK_DATABASE_DRIVER=mssql+pymssql \
ANYBLOK_DATABASE_USER=sa \
ANYBLOK_DATABASE_PASSWORD=AnyBl@k2019 \
SQLSERVER='docker exec mssql /opt/mssql-tools/bin/sqlcmd -U sa -P AnyBl@k2019 -Q' \
SQLPYCLIENT='pymssql' \
MARKERS='not field and not column and not relationship'
matrix:
allow_failures:
@@ -36,9 +46,10 @@ matrix:
include:
- python: "pypy3.5"
env: ANYBLOK_DATABASE_DRIVER=postgresql+psycopg2cffi ANYBLOK_DATABASE_USER=postgres SQLSERVER='psql -c' SQLPYCLIENT='psycopg2cffi'
exclude:
include:
- python: "3.5"
env: ANYBLOK_DATABASE_DRIVER=mysql ANYBLOK_DATABASE_USER=travis SQLSERVER='mysql -e' SQLPYCLIENT='mysqlclient'
env: ANYBLOK_DATABASE_DRIVER=postgresql ANYBLOK_DATABASE_USER=postgres SQLSERVER='psql -c' SQLPYCLIENT='psycopg2-binary'
fast_finish: true

virtualenv:
system_site_packages: false
@@ -51,7 +62,8 @@ services:
before_install:
- sudo apt-get update
- sudo apt-get install graphviz
- if [[ $ANYBLOK_DATABASE_DRIVER == 'mssql+pymssql' ]]; then docker run -e 'ACCEPT_EULA=Y' -e 'SA_PASSWORD=AnyBl@k2019' -p 1433:1433 -d --name mssql mcr.microsoft.com/mssql/server; fi
- if [[ $ANYBLOK_DATABASE_DRIVER == 'mssql+pymssql' ]]; then docker pull mcr.microsoft.com/mssql/server:2019-latest; fi
- if [[ $ANYBLOK_DATABASE_DRIVER == 'mssql+pymssql' ]]; then docker run -e 'ACCEPT_EULA=Y' -e 'SA_PASSWORD=AnyBl@k2019' -p 1433:1433 -d --name mssql mcr.microsoft.com/mssql/server:2019-latest; fi

install:
- pip install -U pip
@@ -69,10 +81,11 @@ script:
- flake8 anyblok --exclude=*/tests/*
- python3 update_env.py
- $SQLSERVER 'create database travis_ci_test;'
- if [[ $TRAVIS_PYTHON_VERSION != 'pypy3.5' ]]; then py.test --cov-report= --cov=anyblok anyblok/tests; fi
- if [[ $TRAVIS_PYTHON_VERSION != 'pypy3.5' ]] && [[ $MARKERS == '' ]]; then pytest --cov-report= --cov=anyblok anyblok/tests; fi
- if [[ $TRAVIS_PYTHON_VERSION != 'pypy3.5' ]] && [[ $MARKERS != '' ]]; then pytest -m "$MARKERS" --cov-report= --cov=anyblok anyblok/tests; fi
- $SQLSERVER 'drop database travis_ci_test;'
- anyblok_createdb --install-all-bloks
- py.test --cov-report= --cov=anyblok anyblok/bloks
- pytest --cov-report= --cov=anyblok anyblok/bloks

after_success:
coveralls --data_file=.coverage --config_file=.coveragerc
@@ -9,7 +9,7 @@
from anyblok.testing import sgdb_in


@pytest.mark.skipif(sgdb_in(['MySQL', 'MariaDB']), reason='ISSUE #89')
@pytest.mark.skipif(sgdb_in(['MySQL', 'MariaDB', 'MsSQL']), reason='ISSUE #89')
@pytest.mark.usefixtures('rollback_registry')
class TestSystemSequence:

@@ -45,6 +45,8 @@ def assert_pristine_registry(self):
self.assertEqual(Grant.query().count(), 0)


@unittest.skipIf(sgdb_in(['MySQL', 'MariaDB', 'MsSQL']),
"ShareDataTestCase doesn't work, issue #96")
class TestSharedDataTestCaseException(unittest.TestCase):
"""Test class with an exception in setUpSharedData.
@@ -109,8 +111,6 @@ def test_class_rollbacked(self):
self.assertFalse(result.failures)
self.assertFalse(result.errors)

@unittest.skipIf(sgdb_in(['MySQL', 'MariaDB', 'MsSQL']),
"ShareDataTestCase doesn't work, issue #96")
def test_setup_error(self):
"""Test rollback of test case and class with error in setUp"""

@@ -29,7 +29,13 @@
Password, UUID, URL, PhoneNumber, Email, Country, TimeStamp)


@pytest.fixture(params=[DateTime, TimeStamp])
time_params = [DateTime]

if not sgdb_in(['MsSQL']):
time_params.append(TimeStamp)


@pytest.fixture(params=time_params)
def dt_column_type(request):
return request.param

@@ -44,8 +50,6 @@ def dt_column_type(request):
(Date, datetime.date.today(), {}),
(DateTime, datetime.datetime.now().replace(
tzinfo=pytz.timezone(time.tzname[0])), {}),
(TimeStamp, datetime.datetime.now().replace(
tzinfo=pytz.timezone(time.tzname[0])), {}),
(Time, datetime.time(), {}),
(Float, 1., {}),
(Integer, 1, {}),
@@ -59,25 +63,10 @@ def dt_column_type(request):
if not sgdb_in(['MySQL', 'MariaDB']):
COLUMNS.append((UUID, uuid1(), {}))

if not sgdb_in(['MsSQL']):
COLUMNS.append((TimeStamp, datetime.datetime.now().replace(
tzinfo=pytz.timezone(time.tzname[0])), {}))

COLUMNS = [
(Selection, 'test', {'selections': {'test': 'test'}}),
(Boolean, True, {}),
(Boolean, False, {}),
(String, 'test', {}),
(BigInteger, 1, {}),
(Text, 'Test', {}),
(Date, datetime.date.today(), {}),
(DateTime, datetime.datetime.now().replace(
tzinfo=pytz.timezone(time.tzname[0])), {}),
(Time, datetime.time(), {}),
(Float, 1., {}),
(Integer, 1, {}),
(Email, 'jhon@doe.com', {}),
]

if not sgdb_in(['MySQL', 'MariaDB']):
COLUMNS.append((UUID, uuid1(), {}))

try:
import cryptography # noqa
@@ -222,6 +211,7 @@ class Test2:
test = String(foreign_key=Model.Test.use('name'))


@pytest.mark.column
class TestColumns:

@pytest.fixture(autouse=True)
@@ -9,7 +9,6 @@
import pytest
from anyblok.field import Field, FieldException, Function, JsonRelated
from anyblok.column import Integer, String, Json
from anyblok.testing import sgdb_in
from anyblok import Declarations
from sqlalchemy import func, types
from .conftest import init_registry
@@ -68,6 +67,7 @@ def registry_field_function(request, bloks_loaded):
return registry


@pytest.mark.field
class TestFieldFunction:

@pytest.fixture(autouse=True)
@@ -119,6 +119,7 @@ def registry_json_related(request, bloks_loaded):

@pytest.mark.skipif(sgdb_in(['MariaDB']),
reason='JSON is not existing in this SGDB')
@pytest.mark.field
class TestJsonRelated:

@pytest.fixture(autouse=True)
@@ -228,6 +229,7 @@ def registry_json_related2(request, bloks_loaded):

@pytest.mark.skipif(sgdb_in(['MariaDB']),
reason='JSON is not existing in this SGDB')
@pytest.mark.field
class TestJsonRelated2:

@pytest.fixture(autouse=True)
@@ -275,6 +277,7 @@ class Test:
field = OneField()


@pytest.mark.field
class TestField2:

@pytest.fixture(autouse=True)
@@ -152,6 +152,7 @@ def registry_many2many(request, bloks_loaded, db_schema):
return registry


@pytest.mark.relationship
class TestMany2ManyComplete:

@pytest.fixture(autouse=True)
@@ -342,6 +343,7 @@ class Address:
join_table='join_person_and_address_for_addresses')


@pytest.mark.relationship
class TestMany2Many:

@pytest.fixture(autouse=True)
@@ -1114,54 +1116,6 @@ class Person:
assert personaddress.create_at
assert personaddress.foo == 'bar'

def test_rich_many2many_minimum_config_on_join_model_with_di_schema2(
self, db_schema
):

def add_in_registry():

@register(Model)
class Address:
__db_schema__ = 'test_db_m2m_schema1'

id = Integer(primary_key=True)
street = String()
zip = String()
city = String()

@register(Model)
class PersonAddress:
__db_schema__ = 'test_db_m2m_schema2'

id = Integer(primary_key=True)
a_id = Integer(
foreign_key=Model.Address.use('id'), nullable=False)
p_name = String(
foreign_key='Model.Person=>name', nullable=False)
create_at = DateTime(default=datetime.now)
foo = String(default='bar')

@register(Model)
class Person:
__db_schema__ = 'test_db_m2m_schema3'

name = String(primary_key=True)
addresses = Many2Many(model=Model.Address,
join_model=Model.PersonAddress,
many2many="persons")

registry = self.init_registry(add_in_registry)
person = registry.Person.insert(name='jssuzanne')
address = registry.Address.insert(
street='somewhere', zip="75001", city="Paris")
person.addresses.append(address)
personaddress = registry.PersonAddress.query().one()
assert personaddress.a_id == address.id
assert personaddress.p_name == person.name
assert personaddress.id
assert personaddress.create_at
assert personaddress.foo == 'bar'

def test_rich_many2many_minimum_config_on_join_model_with_di_schema2(
self, db_schema
):
@@ -16,13 +16,61 @@
from anyblok.field import FieldException
from anyblok.column import (
Integer, String, BigInteger, Float, Decimal, Boolean, DateTime, Date, Time,
Sequence, Email, UUID, URL, Country, Color, PhoneNumber, Selection)
Sequence, Email, UUID, URL, Country, Color, PhoneNumber, Selection,
TimeStamp)
from anyblok.relationship import Many2One
from sqlalchemy import ForeignKeyConstraint
from sqlalchemy.engine.reflection import Inspector
from .conftest import init_registry_with_bloks, init_registry, reset_db


COLUMNS = [
Integer,
BigInteger,
Float,
Decimal,
String,
Boolean,
Date,
Time,
Email,
UUID,
Country,
Selection,
]


if not sgdb_in(['MySQL', 'MariaDB', 'MsSQL']):
COLUMNS.extend([DateTime, TimeStamp])


try:
import colour # noqa
COLUMNS.append(Color)
except Exception:
pass

try:
import furl # noqa
if not sgdb_in(['MySQL', 'MariaDB', 'MsSQL']):
COLUMNS.append(URL)
except Exception:
pass


try:
import phonenumbers # noqa
COLUMNS.append(PhoneNumber)
except Exception:
pass

try:
import pycountry # noqa
COLUMNS.append(Country)
except Exception:
pass


register = Declarations.register
Model = Declarations.Model
Mixin = Declarations.Mixin
@@ -238,6 +286,7 @@ def registry_many2one(request, bloks_loaded, db_schema):
return registry, request.param[1], request.param[2]


@pytest.mark.relationship
class TestMany2One:

@pytest.fixture(autouse=True)
@@ -288,29 +337,7 @@ class Person:
address = Many2One(model=Model.Address)


params = [
Integer,
BigInteger,
Float,
Decimal,
String,
Boolean,
Date,
Time,
Email,
UUID,
Color,
Country,
PhoneNumber,
Selection,
]

if not sgdb_in(['MySQL', 'MariaDB']):
params.append(DateTime)
params.append(URL)


@pytest.fixture(scope="class", params=params)
@pytest.fixture(scope="class", params=COLUMNS)
def registry_many2one_auto_detect(request, bloks_loaded):
reset_db()
registry = init_registry_with_bloks(
@@ -319,6 +346,7 @@ def registry_many2one_auto_detect(request, bloks_loaded):
return registry


@pytest.mark.relationship
class TestMany2OneAutoDetectColumn:

@pytest.fixture(autouse=True)
@@ -382,6 +410,7 @@ class Test2:
test = Many2One(model=Model.Test)


@pytest.mark.relationship
class TestMany2OneOld:

@pytest.fixture(autouse=True)

0 comments on commit 80bd38a

Please sign in to comment.
You can’t perform that action at this time.