From b9a4def2ca08ee59a6bc774abe220af8bcbb215f 2016-05-11 17:31:57 From: Lance Edgar Date: 2016-05-11 17:31:57 Subject: [PATCH] Clean up some imports within tests --- diff --git a/rattail/tests/db/__init__.py b/rattail/tests/db/__init__.py index e1d9afffae8a3c5ac87dcd49e0b0fd772dd70f81..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 100644 --- a/rattail/tests/db/__init__.py +++ b/rattail/tests/db/__init__.py @@ -1,4 +0,0 @@ -# -*- coding: utf-8 -*- - -# TODO: Update references to this; should be importing from tests root. -from .. import DataTestCase diff --git a/rattail/tests/db/batches/test_util.py b/rattail/tests/db/batches/test_util.py index d05a55591232490e81020aa14316bad865f2f98d..8246b986013ebe8efc8663f2ffe0aaf1a09f421f 100644 --- a/rattail/tests/db/batches/test_util.py +++ b/rattail/tests/db/batches/test_util.py @@ -1,16 +1,14 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals +from __future__ import unicode_literals, absolute_import import datetime -from sqlalchemy import func -from sqlalchemy import MetaData +import sqlalchemy as sa -from ... import DataTestCase - -from rattail.db.batches import util from rattail.db import model +from rattail.db.batches import util +from rattail.tests import DataTestCase class TestPurgeBatches(DataTestCase): @@ -41,7 +39,7 @@ class TestPurgeBatches(DataTestCase): def get_batch_tables_metadata(self): def batch_tables(name, metadata): return util.batch_pattern.match(name) - metadata = MetaData(bind=self.engine) + metadata = sa.MetaData(bind=self.engine) metadata.reflect(only=batch_tables) return metadata @@ -49,7 +47,7 @@ class TestPurgeBatches(DataTestCase): self.assertEqual(self.session.query(model.Batch).count(), 3) self.assertEqual(util.purge_batches(effective_date=datetime.date(2014, 1, 15)), 1) self.assertEqual(self.session.query(model.Batch).count(), 2) - self.assertEqual(self.session.query(func.min(model.Batch.purge)).scalar(), datetime.date(2014, 2, 1)) + self.assertEqual(self.session.query(sa.func.min(model.Batch.purge)).scalar(), datetime.date(2014, 2, 1)) def test_purging_everything_does_just_that(self): self.assertEqual(self.session.query(model.Batch).count(), 3) diff --git a/rattail/tests/db/model/test_users.py b/rattail/tests/db/model/test_users.py index 0e180fa1141d3b4885bee929e4d32d3e3ea9fa89..77c073754e2dbbde18be390ec54ab6d569814c0b 100644 --- a/rattail/tests/db/model/test_users.py +++ b/rattail/tests/db/model/test_users.py @@ -1,10 +1,9 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals - -from ... import DataTestCase +from __future__ import unicode_literals, absolute_import from rattail.db import model +from rattail.tests import DataTestCase class TestUserEmailAddress(DataTestCase): diff --git a/rattail/tests/db/test_auth.py b/rattail/tests/db/test_auth.py index f7992bcc09775a9273f31e38d7d9e790cf9b49e9..caa280b131246c83236a5f23c39411befdd32140 100644 --- a/rattail/tests/db/test_auth.py +++ b/rattail/tests/db/test_auth.py @@ -1,11 +1,9 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals +from __future__ import unicode_literals, absolute_import -from .. import DataTestCase - -from rattail.db import auth -from rattail.db import model +from rattail.db import auth, model +from rattail.tests import DataTestCase class TestAuthenticateUser(DataTestCase): diff --git a/rattail/tests/db/test_model.py b/rattail/tests/db/test_model.py index 7c7ca10fca4e0545619461899a70c3193799c9d8..bde261e94d23107a7d128f40f6962ad42721233e 100644 --- a/rattail/tests/db/test_model.py +++ b/rattail/tests/db/test_model.py @@ -1,17 +1,17 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals +from __future__ import unicode_literals, absolute_import from unittest import TestCase -from . import DataTestCase from mock import patch, DEFAULT, Mock, MagicMock -from sqlalchemy import String, Boolean, Numeric +import sqlalchemy as sa from sqlalchemy.exc import IntegrityError from rattail.db import model from rattail.db.types import GPCType from rattail.db.changes import record_changes +from rattail.tests import DataTestCase class SAErrorHelper(object): @@ -91,16 +91,16 @@ class TestBatch(TestCase): self.assertTrue(isinstance(model.Batch.get_sqlalchemy_type('GPC(14)'), GPCType)) # boolean - self.assertTrue(isinstance(model.Batch.get_sqlalchemy_type('FLAG(1)'), Boolean)) + self.assertTrue(isinstance(model.Batch.get_sqlalchemy_type('FLAG(1)'), sa.Boolean)) # string type_ = model.Batch.get_sqlalchemy_type('CHAR(20)') - self.assertTrue(isinstance(type_, String)) + self.assertTrue(isinstance(type_, sa.String)) self.assertEqual(type_.length, 20) # numeric type_ = model.Batch.get_sqlalchemy_type('NUMBER(9,3)') - self.assertTrue(isinstance(type_, Numeric)) + self.assertTrue(isinstance(type_, sa.Numeric)) self.assertEqual(type_.precision, 9) self.assertEqual(type_.scale, 3) diff --git a/rattail/tests/test_commands.py b/rattail/tests/test_commands.py index d1f363566a0fbb3a4fff6a4349bc4df48dd8b8bb..4964f033863610f591b2cfd5af72a0d248fa3e3f 100644 --- a/rattail/tests/test_commands.py +++ b/rattail/tests/test_commands.py @@ -15,12 +15,11 @@ from fixture import TempIO from sqlalchemy import create_engine from sqlalchemy import func -from . import DataTestCase from rattail import commands from rattail.commands.core import ArgumentParser, date_argument -from rattail.db import Session -from rattail.db import model +from rattail.db import Session, model from rattail.db.auth import authenticate_user +from rattail.tests import DataTestCase class TestArgumentParser(TestCase):