Changeset - b9a4def2ca08
[Not reviewed]
0 6 0
Lance Edgar - 8 years ago 2016-05-11 17:31:57
ledgar@sacfoodcoop.com
Clean up some imports within tests
6 files changed with 19 insertions and 29 deletions:
0 comments (0 inline, 0 general)
rattail/tests/db/__init__.py
Show inline comments
 
# -*- coding: utf-8 -*-
 

	
 
# TODO: Update references to this; should be importing from tests root.
 
from .. import DataTestCase
rattail/tests/db/batches/test_util.py
Show inline comments
 
# -*- 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)
rattail/tests/db/model/test_users.py
Show inline comments
 
# -*- 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):
rattail/tests/db/test_auth.py
Show inline comments
 
# -*- 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):
rattail/tests/db/test_model.py
Show inline comments
 
# -*- 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)
 

	
rattail/tests/test_commands.py
Show inline comments
 
@@ -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):
0 comments (0 inline, 0 general)