diff --git a/.travis.yml b/.travis.yml index da8d666..1dd475f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,19 +5,20 @@ python: - 2.7 - - 3.4 - - 3.5 - 3.6 + - 3.7 + - 3.8 + - 3.9 services: - postgresql addons: - postgresql: "9.6" + postgresql: "13.6" install: - gem install taskjuggler - - pip install sqlalchemy "psycopg2-binary<=2.8.3" jinja2 alembic Mako MarkupSafe python-editor pytz tzlocal pytest pytest-xdist pytest-cov codeclimate-test-reporter + - pip install sqlalchemy psycopg2-binary jinja2 alembic Mako MarkupSafe python-editor pytz tzlocal pytest pytest-xdist pytest-cov codeclimate-test-reporter - pip install pytest --upgrade before_script: diff --git a/CHANGELOG.rst b/CHANGELOG.rst index c1604e2..34f1b70 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -2,6 +2,13 @@ Stalker Changes =============== +0.2.25 +====== + +* **Update:** Stalker is now compatible with SQLAlchemy 1.4, + psycopg2-binary 2.86 and Python 3.9+. But more work still needs to be done to + make it SQLAlchemy 2.0 compatible. + 0.2.24.3 ======== diff --git a/setup.py b/setup.py index d2529ec..cefc860 100644 --- a/setup.py +++ b/setup.py @@ -10,10 +10,10 @@ 'houdini', 'nuke', 'fusion', 'softimage', 'blender', 'vue'] CLASSIFIERS = ["Programming Language :: Python", "Programming Language :: Python :: 2.7", - "Programming Language :: Python :: 3.3", - "Programming Language :: Python :: 3.4", - "Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.6", + "Programming Language :: Python :: 3.7", + "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", "License :: OSI Approved :: GNU Lesser General Public License v3 (LGPLv3)", "Operating System :: OS Independent", "Development Status :: 5 - Production/Stable", @@ -23,7 +23,7 @@ "Topic :: Utilities", "Topic :: Office/Business :: Scheduling", ] INSTALL_REQUIRES = [ - 'psycopg2-binary<=2.8.3', 'sqlalchemy', 'alembic', 'jinja2', 'pytz', 'tzlocal', + 'psycopg2-binary', 'sqlalchemy', 'alembic', 'jinja2', 'pytz', 'tzlocal', ] TESTS_REQUIRE = ['pytest', 'pytest-xdist', 'pytest-cov', 'coverage'] DATA_FILES = [( @@ -35,8 +35,7 @@ def read(*parts): - """ - Build an absolute path from *parts* and and return the contents of the + """Build an absolute path from *parts* and and return the contents of the resulting file. Assume UTF-8 encoding. """ with codecs.open(os.path.join(HERE, *parts), "rb", "utf-8") as f: @@ -49,8 +48,7 @@ def read(*parts): def find_meta(meta): - """ - Extract __*meta*__ from META_FILE. + """Extract __*meta*__ from META_FILE. """ import re meta_match = re.search( @@ -82,4 +80,3 @@ def find_meta(meta): install_requires=INSTALL_REQUIRES, tests_require=TESTS_REQUIRE ) - diff --git a/stalker/__init__.py b/stalker/__init__.py index fcc54c1..335ac90 100644 --- a/stalker/__init__.py +++ b/stalker/__init__.py @@ -7,12 +7,12 @@ import sys -__version__ = '0.2.24.3' +__version__ = '0.2.25' __title__ = "stalker" __description__ = 'A Production Asset Management (ProdAM) System' __uri__ = 'http://github.com/eoyilmaz/stalker' -__doc__ = __description__ + " <" + __uri__ + ">" +__doc__ = "%s <%s>" % (__description__, __uri__) __author__ = "Erkan Ozgur Yilmaz" __email__ = 'eoyilmaz@gmail.com' @@ -33,11 +33,9 @@ from stalker import config defaults = config.Config() -from stalker.models.auth import (Group, Permission, User, LocalSession, Role, - AuthenticationLog) +from stalker.models.auth import Group, Permission, User, LocalSession, Role, AuthenticationLog from stalker.models.asset import Asset -from stalker.models.budget import (Budget, BudgetEntry, Good, PriceList, - Invoice, Payment) +from stalker.models.budget import Budget, BudgetEntry, Good, PriceList, Invoice, Payment from stalker.models.client import Client, ClientUser from stalker.models.department import Department, DepartmentUser from stalker.models.entity import SimpleEntity, Entity, EntityGroup @@ -50,8 +48,7 @@ TargetEntityTypeMixin, UnitMixin, WorkingHoursMixin) from stalker.models.note import Note -from stalker.models.project import (Project, ProjectUser, ProjectClient, - ProjectRepository) +from stalker.models.project import Project, ProjectUser, ProjectClient, ProjectRepository from stalker.models.review import Review, Daily, DailyLink from stalker.models.repository import Repository from stalker.models.scene import Scene diff --git a/stalker/config.py b/stalker/config.py index 6826148..1917760 100644 --- a/stalker/config.py +++ b/stalker/config.py @@ -110,6 +110,7 @@ class Config(ConfigBase): database_engine_settings={ "sqlalchemy.url": "sqlite://", "sqlalchemy.echo": False, + # "sqlalchemy.pool_pre_ping": True, }, database_session_settings={}, diff --git a/stalker/db/__init__.py b/stalker/db/__init__.py index c91debd..a7d4ffb 100644 --- a/stalker/db/__init__.py +++ b/stalker/db/__init__.py @@ -43,10 +43,7 @@ def setup(settings=None): # create the Session class from stalker.db.session import DBSession DBSession.remove() - DBSession.configure( - bind=engine, - extension=None - ) + DBSession.configure(bind=engine) # check alembic versions of the database # and raise an error if it is not matching with the system @@ -192,10 +189,11 @@ def get_alembic_version(): conn = DBSession.connection() engine = conn.engine if engine.dialect.has_table(conn, 'alembic_version'): - sql_query = 'select version_num from alembic_version' + sql_query = "select version_num from alembic_version" + from sqlalchemy import text from sqlalchemy.exc import OperationalError, ProgrammingError try: - return DBSession.connection().execute(sql_query).fetchone()[0] + return DBSession.connection().execute(text(sql_query)).fetchone()[0] except (OperationalError, ProgrammingError, TypeError): DBSession.rollback() return None @@ -257,10 +255,10 @@ def create_alembic_table(): Base.metadata.create_all(engine) # first try to query the version value - sql_query = 'select version_num from alembic_version' + from sqlalchemy import text + sql_query = "select version_num from alembic_version" try: - version_num = \ - DBSession.connection().execute(sql_query).fetchone()[0] + version_num = DBSession.connection().execute(text(sql_query)).fetchone()[0] except TypeError: logger.debug('inserting %s to alembic_version table' % version_num) # the table is there but there is no value so insert it @@ -279,6 +277,7 @@ def __create_admin__(): """creates the admin """ from stalker import defaults + from stalker.db.session import DBSession from stalker.models.auth import User from stalker.models.department import Department @@ -291,7 +290,6 @@ def __create_admin__(): if not admin_department: admin_department = Department(name=defaults.admin_department_name) - from stalker.db.session import DBSession DBSession.add(admin_department) # create the admins group @@ -392,17 +390,20 @@ def create_ticket_statuses(): logger.debug("Ticket Types are created successfully") -def create_entity_statuses(entity_type='', status_names=None, - status_codes=None, user=None): +def create_entity_statuses(entity_type='', status_names=None, status_codes=None, user=None): """creates the default task statuses """ + from stalker.db.session import DBSession if not entity_type: + DBSession.rollback() raise ValueError('Please supply entity_type') if not status_names: + DBSession.rollback() raise ValueError('Please supply status names') if not status_codes: + DBSession.rollback() raise ValueError('Please supply status codes') # create statuses for entity @@ -410,7 +411,9 @@ def create_entity_statuses(entity_type='', status_names=None, logger.debug("Creating %s Statuses" % entity_type) - statuses = Status.query.filter(Status.name.in_(status_names)).all() + with DBSession.no_autoflush: + statuses = Status.query.filter(Status.name.in_(status_names)).all() + logger.debug('status_names: %s' % status_names) logger.debug('statuses: %s' % statuses) status_names_in_db = list(map(lambda x: x.name, statuses)) @@ -434,8 +437,8 @@ def create_entity_statuses(entity_type='', status_names=None, ) # create the Status List - status_list = StatusList.query\ - .filter(StatusList.target_entity_type == entity_type)\ + status_list = StatusList.query \ + .filter(StatusList.target_entity_type == entity_type) \ .first() if status_list is None: @@ -453,10 +456,10 @@ def create_entity_statuses(entity_type='', status_names=None, status_list.statuses = statuses DBSession.add(status_list) - from sqlalchemy.exc import IntegrityError + from sqlalchemy.exc import IntegrityError, OperationalError try: DBSession.commit() - except IntegrityError as e: + except (IntegrityError, OperationalError) as e: logger.debug("error in DBSession.commit, rolling back: %s" % e) DBSession.rollback() else: diff --git a/stalker/db/session.py b/stalker/db/session.py index 4f7b462..bb6846c 100644 --- a/stalker/db/session.py +++ b/stalker/db/session.py @@ -18,6 +18,7 @@ def save(self, data=None): self.commit() -DBSession = ExtendedScopedSession( - sessionmaker(extension=None) -) +# try: +# DBSession = ExtendedScopedSession(sessionmaker(extension=None)) +# except TypeError: +DBSession = ExtendedScopedSession(sessionmaker()) diff --git a/stalker/models/entity.py b/stalker/models/entity.py index ac54aa8..95d06c9 100644 --- a/stalker/models/entity.py +++ b/stalker/models/entity.py @@ -286,8 +286,9 @@ def __repr__(self): def __eq__(self, other): """the equality operator """ - return isinstance(other, SimpleEntity) and \ - self.name == other.name + from stalker.db.session import DBSession + with DBSession.no_autoflush: + return isinstance(other, SimpleEntity) and self.name == other.name def __ne__(self, other): """the inequality operator diff --git a/stalker/models/mixins.py b/stalker/models/mixins.py index 936940a..bc30e15 100644 --- a/stalker/models/mixins.py +++ b/stalker/models/mixins.py @@ -457,7 +457,9 @@ def _end_getter(self): will also set the end, so the timedelta between them is preserved, default value is 10 days """ - return self._end + from stalker.db.session import DBSession + with DBSession.no_autoflush: + return self._end def _end_setter(self, end_in): self._start, self._end, self._duration = \ @@ -489,7 +491,9 @@ def _start_getter(self): class:`datetime.datetime` and the default value is :func:`datetime.datetime.now(pytz.utc)` """ - return self._start + from stalker.db.session import DBSession + with DBSession.no_autoflush: + return self._start def _start_setter(self, start_in): self._start, self._end, self._duration = \ @@ -510,7 +514,9 @@ def _duration(cls): return Column('duration', Interval) def _duration_getter(self): - return self._duration + from stalker.db.session import DBSession + with DBSession.no_autoflush: + return self._duration def _duration_setter(self, duration_in): if duration_in is not None: diff --git a/stalker/models/project.py b/stalker/models/project.py index 047d3a0..448102e 100644 --- a/stalker/models/project.py +++ b/stalker/models/project.py @@ -191,6 +191,7 @@ class Project(Entity, ReferenceMixin, StatusMixin, DateRangeMixin, CodeMixin): "inherit_condition": project_id == Entity.entity_id } + # TODO: Remove this attribute, because we have the statuses to control if a project is active or not active = Column(Boolean, default=True) clients = association_proxy( @@ -603,7 +604,9 @@ def _validate_user(self, key, user): ) # also update rate attribute - self.rate = user.rate + from stalker.db.session import DBSession + with DBSession.no_autoflush: + self.rate = user.rate return user diff --git a/stalker/models/task.py b/stalker/models/task.py index 1f2142d..93e58b2 100644 --- a/stalker/models/task.py +++ b/stalker/models/task.py @@ -6,8 +6,7 @@ from sqlalchemy import (Table, Column, Integer, ForeignKey, Boolean, Enum, Float, event, CheckConstraint) -from sqlalchemy.exc import UnboundExecutionError, OperationalError, \ - InvalidRequestError +from sqlalchemy.exc import UnboundExecutionError, OperationalError, InvalidRequestError, ProgrammingError from sqlalchemy.ext.associationproxy import association_proxy from sqlalchemy.orm import relationship, validates, synonym, reconstructor @@ -1878,7 +1877,7 @@ def _total_logged_seconds_getter(self): engine = DBSession.connection().engine result = engine.execute(text(sql), task_id=self.id).fetchone() return result[0] if result[0] else 0 - except (UnboundExecutionError, OperationalError) as e: + except (UnboundExecutionError, OperationalError, ProgrammingError) as e: # no database connection # fallback to Python logger.debug('No session found! Falling back to Python') @@ -3191,7 +3190,7 @@ def add_exclude_constraint(table, connection, **kwargs): """adds the PostgreSQL specific ExcludeConstraint """ from sqlalchemy import DDL - from sqlalchemy.exc import ProgrammingError + from sqlalchemy.exc import ProgrammingError, InternalError if connection.engine.dialect.name == 'postgresql': logger.debug('add_exclude_constraint is Running!') @@ -3201,7 +3200,7 @@ def add_exclude_constraint(table, connection, **kwargs): logger.debug('running "btree_gist" extension creation!') create_extension.execute(bind=connection) logger.debug('successfully created "btree_gist" extension!') - except ProgrammingError as e: + except (ProgrammingError, InternalError) as e: logger.debug('add_exclude_constraint: %s' % e) # create the ts_to_box sql function @@ -3225,7 +3224,7 @@ def add_exclude_constraint(table, connection, **kwargs): logger.debug( 'successfully created ts_to_box function' ) - except ProgrammingError as e: + except (ProgrammingError, InternalError) as e: logger.debug( 'failed creating ts_to_box function!: %s' % e ) @@ -3246,7 +3245,7 @@ def add_exclude_constraint(table, connection, **kwargs): logger.debug( 'successfully created ExcludeConstraint for "TimeLogs" table!' ) - except ProgrammingError as e: + except (ProgrammingError, InternalError) as e: logger.debug( 'failed creating ExcludeConstraint for TimeLogs table!: %s' % e ) diff --git a/stalker/testing.py b/stalker/testing.py index 0d257c1..2558d20 100644 --- a/stalker/testing.py +++ b/stalker/testing.py @@ -34,9 +34,8 @@ def create_random_db(): """ # create a new database for this test only import uuid - database_name = 'stalker_test_%s' % uuid.uuid4().hex[:4] - database_url = \ - 'postgresql://stalker_admin:stalker@localhost/%s' % database_name + database_name = 'stalker_test_%s' % uuid.uuid4().hex[:8] + database_url = 'postgresql://stalker_admin:stalker@localhost/%s' % database_name create_db(database_name) return database_url, database_name @@ -74,33 +73,34 @@ class UnitTestDBBase(unittest.TestCase): """the base for Stalker Pyramid Views unit tests """ - config = {} - database_url = None - database_name = None + def __init__(self, *args, **kwargs): + super(UnitTestDBBase, self).__init__(*args, **kwargs) + self.config = {} + self.database_url = None + self.database_name = None - @classmethod - def setUpClass(cls): + def setUp(self): """setup once """ # create a new database for this test only - cls.database_url, cls.database_name = create_random_db() + from subprocess import CalledProcessError + + while True: + try: + self.database_url, self.database_name = create_random_db() + except CalledProcessError: + # in very rare cases the create_random_db generates an already + # existing database name + # call it again + pass + else: + break # update the config - cls.config['sqlalchemy.url'] = cls.database_url + self.config['sqlalchemy.url'] = self.database_url from sqlalchemy.pool import NullPool - cls.config['sqlalchemy.poolclass'] = NullPool + self.config['sqlalchemy.poolclass'] = NullPool - @classmethod - def tearDownClass(cls): - """tear down once - """ - from stalker.db.session import DBSession - DBSession.close_all() - drop_db(cls.database_name) - - def setUp(self): - """setup test - """ import os from stalker.config import Config try: @@ -136,10 +136,16 @@ def tearDown(self): engine = connection.engine connection.close() - Base.metadata.drop_all(engine, checkfirst=True) - DBSession.remove() - - defaults.timing_resolution = datetime.timedelta(hours=1) + from sqlalchemy.exc import OperationalError + try: + Base.metadata.drop_all(engine, checkfirst=True) + DBSession.remove() + DBSession.close_all() + drop_db(self.database_name) + except OperationalError: + pass + finally: + defaults.timing_resolution = datetime.timedelta(hours=1) @property def admin(self): diff --git a/tests/benchmarks/task_total_logged_seonds.py b/tests/benchmarks/task_total_logged_seonds.py index 35e5e5d..31315aa 100644 --- a/tests/benchmarks/task_total_logged_seonds.py +++ b/tests/benchmarks/task_total_logged_seonds.py @@ -9,15 +9,16 @@ import logging from stalker import log -log.logging_level = logging.INFO import stalker +from stalker.db.session import DBSession from stalker.config import Config from stalker import (db, Repository, Project, Status, StatusList, Task, Type, TimeLog, User) from stalker.db.declarative import Base from stalker.testing import create_random_db, drop_db +log.logging_level = logging.INFO logging.getLogger('stalker.models.task').setLevel(logging.INFO) @@ -165,9 +166,8 @@ } -from stalker.db.session import DBSession DBSession.add_all([ - test_project_status_list, test_movie_project_type, + test_movie_project_type, test_repository_type, test_repository, test_user1, test_user2, test_user3, test_user4, test_user5, test_project1, test_dependent_task1, @@ -199,7 +199,7 @@ ten_minutes = datetime.timedelta(minutes=10) resource = kwargs['resources'][0] print('creating %s TimeLogs' % tl_count) -for i in xrange(tl_count): +for i in range(tl_count): end = start + ten_minutes tl = TimeLog( resource=resource, diff --git a/tests/conftest.py b/tests/conftest.py index d23faa8..252a8a0 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -3,7 +3,7 @@ import pytest -@pytest.fixture('module') +@pytest.fixture(scope='module') def setup_sqlite3(): """setup in memory SQLite3 database for tests """ diff --git a/tests/db/test_db.py b/tests/db/test_db.py index 72f43a0..6ceaab9 100644 --- a/tests/db/test_db.py +++ b/tests/db/test_db.py @@ -129,20 +129,38 @@ def test_no_default_admin_creation(self): """testing if there is no user if stalker.config.Conf.auto_create_admin is False """ + self.tearDown() + # turn down auto admin creation from stalker import db, defaults defaults.auto_create_admin = False - # create a clean database - self.tearDown() + # Setup + # update the config + from stalker.testing import create_random_db + self.database_url, self.database_name = create_random_db() + + self.config['sqlalchemy.url'] = self.database_url + from sqlalchemy.pool import NullPool + self.config['sqlalchemy.poolclass'] = NullPool + + import os + from stalker.config import Config + try: + os.environ.pop(Config.env_key) + except KeyError: + # already removed + pass + + # regenerate the defaults + import stalker + import datetime + stalker.defaults.timing_resolution = datetime.timedelta(hours=1) # init the db db.setup(self.config) db.init() - # Restore auto admin creation - defaults.auto_create_admin = True - # check if there is a use with name admin from stalker import User assert User.query.filter_by(name=defaults.admin_name).first() is None @@ -150,8 +168,8 @@ def test_no_default_admin_creation(self): # check if there is a admins department from stalker import Department assert Department.query\ - .filter_by(name=defaults.admin_department_name)\ - .first() is None + .filter_by(name=defaults.admin_department_name)\ + .first() is None def test_non_unique_names_on_different_entity_type(self): """testing if there can be non-unique names for different entity types @@ -798,8 +816,7 @@ def test_initialization_of_alembic_version_table(self): """ from stalker.db.session import DBSession sql_query = 'select version_num from "alembic_version"' - version_num = \ - DBSession.connection().execute(sql_query).fetchone()[0] + version_num = DBSession.connection().execute(sql_query).fetchone()[0] assert 'bf67e6a234b4' == version_num def test_initialization_of_alembic_version_table_multiple_times(self): @@ -818,8 +835,7 @@ def test_initialization_of_alembic_version_table_multiple_times(self): db.init() db.init() - version_nums = \ - DBSession.connection().execute(sql_query).fetchall() + version_nums = DBSession.connection().execute(sql_query).fetchall() # no additional version is created assert len(version_nums) == 1 @@ -851,17 +867,16 @@ def test_alembic_version_mismatch(self): with pytest.raises(ValueError) as cm: db.setup(self.config) - assert str(cm.value) == 'Please update the database to version: ' \ - '%s' % db.alembic_version + assert str(cm.value) == 'Please update the database to version: %s' % db.alembic_version # also it is not possible to continue with the current DBSession - from sqlalchemy.exc import StatementError + from sqlalchemy.exc import PendingRollbackError from stalker import User - with pytest.raises(StatementError) as cm: + with pytest.raises(PendingRollbackError) as cm: DBSession.query(User.id).all() - assert "(sqlalchemy.exc.InvalidRequestError) Can't reconnect until " \ - "invalid transaction is rolled back" in str(cm.value) + assert "Can't reconnect until invalid transaction is rolled back. " \ + "(Background on this error at: http://sqlalche.me/e/14/8s2b)" in str(cm.value) # rollback and reconnect to the database DBSession.rollback() @@ -1050,7 +1065,7 @@ def test_setup_with_settings(self): """testing if db.setup() function will use the given settings if no setting is supplied """ - self.tearDown() + # self.tearDown() # the default setup is already using the from stalker import db diff --git a/tests/models/test_project.py b/tests/models/test_project.py index 477a6ea..cd2a244 100644 --- a/tests/models/test_project.py +++ b/tests/models/test_project.py @@ -176,6 +176,11 @@ def setUp(self): name='Test Company', users=[self.test_user_client] ) + DBSession.save([ + self.test_image_format, self.test_project_type, self.test_project_type2, + self.test_structure_type1, self.test_structure_type2, self.test_project_structure, + self.test_project_structure2, self.test_repo1, self.test_repo2, self.test_client + ]) # create a project object self.kwargs = { @@ -1259,25 +1264,17 @@ def test_users_argument_is_working_properly(self): """testing if the users argument value is passed to the users attribute properly """ - self.kwargs['users'] = [self.test_user1, - self.test_user2, - self.test_user3] + self.kwargs['users'] = [self.test_user1, self.test_user2, self.test_user3] from stalker import Project new_proj = Project(**self.kwargs) - assert \ - sorted(self.kwargs['users'], key=lambda x: x.name) == \ - sorted(new_proj.users, key=lambda x: x.name) + assert sorted(self.kwargs['users'], key=lambda x: x.name) == sorted(new_proj.users, key=lambda x: x.name) def test_users_attribute_is_working_properly(self): """testing if the users attribute is working properly """ - users = [self.test_user1, - self.test_user2, - self.test_user3] + users = [self.test_user1, self.test_user2, self.test_user3] self.test_project.users = users - assert \ - sorted(users, key=lambda x: x.name) == \ - sorted(self.test_project.users, key=lambda x: x.name) + assert sorted(users, key=lambda x: x.name) == sorted(self.test_project.users, key=lambda x: x.name) def test_tjp_id_is_working_properly(self): """testing if the tjp_id attribute is working properly diff --git a/tests/models/test_task_dependency.py b/tests/models/test_task_dependency.py index bfabd56..9add14a 100644 --- a/tests/models/test_task_dependency.py +++ b/tests/models/test_task_dependency.py @@ -113,8 +113,8 @@ def test_task_argument_is_skipped_raises_error_on_commit(self): with pytest.warns(SAWarning) as cm2: DBSession.commit() - assert '(psycopg2.errors.NotNullViolation) null value in column ' \ - '"task_id" violates not-null constraint' in str(cm.value) + assert '(psycopg2.errors.NotNullViolation) null value in column "task_id" of relation "Task_Dependencies" ' \ + 'violates not-null constraint' in str(cm.value) def test_task_argument_is_not_a_task_instance(self): """testing if a TypeError will be raised when the task argument value @@ -173,9 +173,8 @@ def test_depends_to_argument_is_skipped_raises_error_on_commit(self): with pytest.warns(SAWarning) as cm2: DBSession.commit() - assert '(psycopg2.errors.NotNullViolation) null value in ' \ - 'column "depends_to_id" violates not-null ' \ - 'constraint' in str(cm.value) + assert '(psycopg2.errors.NotNullViolation) null value in column "depends_to_id" of relation ' \ + '"Task_Dependencies" violates not-null constraint' in str(cm.value) def test_depends_to_argument_is_not_a_task_instance(self): """testing if a TypeError will be raised when the depends_to argument diff --git a/tests/models/test_task_status_workflow.py b/tests/models/test_task_status_workflow.py index 5dee69f..ee35526 100644 --- a/tests/models/test_task_status_workflow.py +++ b/tests/models/test_task_status_workflow.py @@ -24,11 +24,7 @@ class TaskStatusWorkflowTestCase(unittest.TestCase): # from sqlalchemy.orm import scoped_session, sessionmaker # from stalker.db import session # # SQLAlchemy session manager - # session.DBSession = scoped_session( - # sessionmaker( - # extension=None - # ) - # ) + # session.DBSession = scoped_session(sessionmaker()) def setUp(self): """setup the test diff --git a/tests/models/test_time_log.py b/tests/models/test_time_log.py index a9aa5ee..4ec04ee 100644 --- a/tests/models/test_time_log.py +++ b/tests/models/test_time_log.py @@ -360,8 +360,7 @@ def test_OverbookedError_1(self): import copy kwargs = copy.copy(self.kwargs) kwargs["resource"] = self.test_resource2 - kwargs["start"] = \ - datetime.datetime(2013, 3, 22, 4, 0, tzinfo=pytz.utc), + kwargs["start"] = datetime.datetime(2013, 3, 22, 4, 0, tzinfo=pytz.utc), kwargs["duration"] = datetime.timedelta(10) time_log1 = TimeLog(**kwargs)