Changeset - aaabe51804ca
[Not reviewed]
0 5 0
Lance Edgar (lance) - 11 years ago 2013-12-20 20:45:37
lance@edbob.org
Updated tests to work on Python 2.6.
5 files changed with 42 insertions and 42 deletions:
0 comments (0 inline, 0 general)
tests/db/sync/test_init.py
Show inline comments
 
@@ -15,8 +15,8 @@ class SynchronizerTests(SyncTestCase):
 

	
 
    def test_init(self):
 
        synchronizer = sync.Synchronizer(self.local_engine, self.remote_engines)
 
        self.assertIs(synchronizer.local_engine, self.local_engine)
 
        self.assertIs(synchronizer.remote_engines, self.remote_engines)
 
        self.assertTrue(synchronizer.local_engine is self.local_engine)
 
        self.assertTrue(synchronizer.remote_engines is self.remote_engines)
 

	
 
    def test_loop(self):
 

	
 
@@ -60,7 +60,7 @@ class SynchronizerTests(SyncTestCase):
 
            self.assertEqual(synchronize_changes.call_count, 1)
 
            # call_args is a tuple of (args, kwargs) - first element of args should be our 2 changes
 
            self.assertEqual(len(synchronize_changes.call_args[0][0]), 2)
 
            self.assertIsInstance(synchronize_changes.call_args[0][0][0], model.Change)
 
            self.assertTrue(isinstance(synchronize_changes.call_args[0][0][0], model.Change))
 

	
 
    def test_synchronize_changes(self):
 
        synchronizer = sync.Synchronizer(self.local_engine, self.remote_engines)
 
@@ -173,18 +173,18 @@ class SynchronizerTests(SyncTestCase):
 
            source_product = model.Product()
 
            local_session.add(source_product)
 
            local_session.flush()
 
            self.assertIsNone(source_product.regular_price_uuid)
 
            self.assertIsNone(source_product.regular_price)
 
            self.assertIsNone(source_product.current_price_uuid)
 
            self.assertIsNone(source_product.current_price)
 
            self.assertTrue(source_product.regular_price_uuid is None)
 
            self.assertTrue(source_product.regular_price is None)
 
            self.assertTrue(source_product.current_price_uuid is None)
 
            self.assertTrue(source_product.current_price is None)
 
            target_product = synchronizer.merge_Product(remote_session, source_product)
 
            self.assertIsNotNone(target_product)
 
            self.assertIsNot(source_product, target_product)
 
            self.assertFalse(target_product is None)
 
            self.assertFalse(source_product is target_product)
 
            self.assertEqual(source_product.uuid, target_product.uuid)
 
            self.assertIsNone(target_product.regular_price_uuid)
 
            self.assertIsNone(target_product.regular_price)
 
            self.assertIsNone(target_product.current_price_uuid)
 
            self.assertIsNone(target_product.current_price)
 
            self.assertTrue(target_product.regular_price_uuid is None)
 
            self.assertTrue(target_product.regular_price is None)
 
            self.assertTrue(target_product.current_price_uuid is None)
 
            self.assertTrue(target_product.current_price is None)
 
            local_session.rollback()
 
            local_session.close()
 
            remote_session.rollback()
 
@@ -199,11 +199,11 @@ class SynchronizerTests(SyncTestCase):
 
            source_product.regular_price = regular_price
 
            local_session.add(source_product)
 
            local_session.flush()
 
            self.assertIsNotNone(source_product.regular_price_uuid)
 
            self.assertIsNotNone(source_product.regular_price)
 
            self.assertFalse(source_product.regular_price_uuid is None)
 
            self.assertFalse(source_product.regular_price is None)
 
            target_product = synchronizer.merge_Product(remote_session, source_product)
 
            self.assertEqual(target_product.regular_price_uuid, source_product.regular_price_uuid)
 
            self.assertIsNotNone(target_product.regular_price)
 
            self.assertFalse(target_product.regular_price is None)
 
            local_session.rollback()
 
            local_session.close()
 
            remote_session.rollback()
 
@@ -218,11 +218,11 @@ class SynchronizerTests(SyncTestCase):
 
            source_product.current_price = current_price
 
            local_session.add(source_product)
 
            local_session.flush()
 
            self.assertIsNotNone(source_product.current_price_uuid)
 
            self.assertIsNotNone(source_product.current_price)
 
            self.assertFalse(source_product.current_price_uuid is None)
 
            self.assertFalse(source_product.current_price is None)
 
            target_product = synchronizer.merge_Product(remote_session, source_product)
 
            self.assertEqual(target_product.current_price_uuid, source_product.current_price_uuid)
 
            self.assertIsNotNone(target_product.current_price)
 
            self.assertFalse(target_product.current_price is None)
 
            local_session.rollback()
 
            local_session.close()
 
            remote_session.rollback()
 
@@ -269,7 +269,7 @@ class SynchronizerTests(SyncTestCase):
 
            synchronizer.delete_Department(session, department)
 
            self.assertEqual(session.query(model.Subdepartment).count(), 1)
 
            subdepartment = session.query(model.Subdepartment).one()
 
            self.assertIsNone(subdepartment.department_uuid)
 
            self.assertTrue(subdepartment.department_uuid is None)
 
            session.rollback()
 
            session.close()
 

	
 
@@ -282,7 +282,7 @@ class SynchronizerTests(SyncTestCase):
 
            self.assertEqual(product.department_uuid, department.uuid)
 
            synchronizer.delete_Department(session, department)
 
            product = session.query(model.Product).one()
 
            self.assertIsNone(product.department_uuid)
 
            self.assertTrue(product.department_uuid is None)
 
            session.rollback()
 
            session.close()
 

	
 
@@ -298,7 +298,7 @@ class SynchronizerTests(SyncTestCase):
 
        self.assertEqual(product.subdepartment_uuid, subdepartment.uuid)
 
        synchronizer.delete_Subdepartment(session, subdepartment)
 
        product = session.query(model.Product).one()
 
        self.assertIsNone(product.subdepartment_uuid)
 
        self.assertTrue(product.subdepartment_uuid is None)
 
        session.rollback()
 
        session.close()
 

	
 
@@ -314,7 +314,7 @@ class SynchronizerTests(SyncTestCase):
 
        self.assertEqual(product.family_uuid, family.uuid)
 
        synchronizer.delete_Family(session, family)
 
        product = session.query(model.Product).one()
 
        self.assertIsNone(product.family_uuid)
 
        self.assertTrue(product.family_uuid is None)
 
        session.rollback()
 
        session.close()
 

	
 
@@ -359,7 +359,7 @@ class ModuleTests(TestCase):
 

	
 
        # nothing configured
 
        edbob.config.get.return_value = None
 
        self.assertIsNone(sync.get_sync_engines())
 
        self.assertTrue(sync.get_sync_engines() is None)
 

	
 
        # fake config with 2 out of 3 engines synced
 
        get_engines.return_value = {
tests/db/test_changes.py
Show inline comments
 
@@ -104,7 +104,7 @@ class TestChangeRecorder(TestCase):
 
        uuid_column.foreign_keys = False
 
        get_uuid.return_value = 'another_uuid'
 
        product = Product()
 
        self.assertIsNone(product.uuid)
 
        self.assertTrue(product.uuid is None)
 
        recorder.ensure_uuid(product)
 
        get_uuid.assert_called_once_with()
 
        self.assertEqual(product.uuid, 'another_uuid')
tests/db/test_core.py
Show inline comments
 
@@ -9,15 +9,15 @@ class TestCore(TestCase):
 

	
 
    def test_uuid_column(self):
 
        column = core.uuid_column()
 
        self.assertIsInstance(column, Column)
 
        self.assertTrue(isinstance(column, Column))
 
        self.assertEqual(column.name, None)
 
        self.assertTrue(column.primary_key)
 
        self.assertFalse(column.nullable)
 
        self.assertIsNotNone(column.default)
 
        self.assertFalse(column.default is None)
 

	
 
    def test_uuid_column_no_default(self):
 
        column = core.uuid_column(default=None)
 
        self.assertIsNone(column.default)
 
        self.assertTrue(column.default is None)
 

	
 
    def test_uuid_column_nullable(self):
 
        column = core.uuid_column(nullable=True)
tests/db/test_model.py
Show inline comments
 
@@ -27,12 +27,12 @@ class TestBatch(TestCase):
 
        rowclass = batch.rowclass
 
        self.assertTrue(issubclass(rowclass, model.BatchRow))
 
        self.assertEqual(model.Batch._rowclasses.keys(), ['some_uuid'])
 
        self.assertIs(model.Batch._rowclasses['some_uuid'], rowclass)
 
        self.assertTrue(model.Batch._rowclasses['some_uuid'] is rowclass)
 
        self.assertFalse(object_session.flush.called)
 

	
 
        # make sure rowclass.batch works
 
        object_session.query.return_value.get.return_value = batch
 
        self.assertIs(rowclass().batch, batch)
 
        self.assertTrue(rowclass().batch is batch)
 
        object_session.query.return_value.get.assert_called_once_with('some_uuid')
 

	
 
        # row class with generated uuid and some columns
 
@@ -44,25 +44,25 @@ class TestBatch(TestCase):
 
        object_session.flush.side_effect = set_uuid
 
        rowclass = batch.rowclass
 
        object_session.flush.assert_called_once_with()
 
        self.assertItemsEqual(model.Batch._rowclasses.keys(), ['some_uuid', 'fresh_uuid'])
 
        self.assertIs(model.Batch._rowclasses['fresh_uuid'], rowclass)
 
        self.assertEqual(sorted(model.Batch._rowclasses.keys()), sorted(['some_uuid', 'fresh_uuid']))
 
        self.assertTrue(model.Batch._rowclasses['fresh_uuid'] is rowclass)
 

	
 
    def test_get_sqlalchemy_type(self):
 

	
 
        # gpc
 
        self.assertIsInstance(model.Batch.get_sqlalchemy_type('GPC(14)'), GPCType)
 
        self.assertTrue(isinstance(model.Batch.get_sqlalchemy_type('GPC(14)'), GPCType))
 

	
 
        # boolean
 
        self.assertIsInstance(model.Batch.get_sqlalchemy_type('FLAG(1)'), Boolean)
 
        self.assertTrue(isinstance(model.Batch.get_sqlalchemy_type('FLAG(1)'), Boolean))
 

	
 
        # string
 
        type_ = model.Batch.get_sqlalchemy_type('CHAR(20)')
 
        self.assertIsInstance(type_, String)
 
        self.assertTrue(isinstance(type_, String))
 
        self.assertEqual(type_.length, 20)
 

	
 
        # numeric
 
        type_ = model.Batch.get_sqlalchemy_type('NUMBER(9,3)')
 
        self.assertIsInstance(type_, Numeric)
 
        self.assertTrue(isinstance(type_, Numeric))
 
        self.assertEqual(type_.precision, 9)
 
        self.assertEqual(type_.scale, 3)
 

	
 
@@ -233,10 +233,10 @@ class TestLabelProfile(DataTestCase):
 
        profile = model.LabelProfile()
 
        self.session.add(profile)
 

	
 
        self.assertIsNone(profile.uuid)
 
        self.assertTrue(profile.uuid is None)
 
        setting = profile.get_printer_setting('some_setting')
 
        self.assertIsNone(setting)
 
        self.assertIsNone(profile.uuid)
 
        self.assertTrue(setting is None)
 
        self.assertTrue(profile.uuid is None)
 

	
 
        profile.uuid = 'some_uuid'
 
        self.session.add(model.Setting(
 
@@ -251,9 +251,9 @@ class TestLabelProfile(DataTestCase):
 
        profile = model.LabelProfile()
 
        self.session.add(profile)
 

	
 
        self.assertIsNone(profile.uuid)
 
        self.assertTrue(profile.uuid is None)
 
        profile.save_printer_setting('some_setting', 'some_value')
 
        self.assertIsNotNone(profile.uuid)
 
        self.assertFalse(profile.uuid is None)
 
        self.assertEqual(self.session.query(model.Setting).count(), 1)
 

	
 
        profile.uuid = 'some_uuid'
tests/test_core.py
Show inline comments
 
@@ -8,5 +8,5 @@ class TestCore(TestCase):
 

	
 
    def test_get_uuid(self):
 
        uuid = core.get_uuid()
 
        self.assertIsInstance(uuid, str)
 
        self.assertTrue(isinstance(uuid, str))
 
        self.assertEqual(len(uuid), 32)
0 comments (0 inline, 0 general)