Changeset - c3461507a792
[Not reviewed]
0 2 0
Lance Edgar - 8 years ago 2016-05-23 14:27:35
ledgar@sacfoodcoop.com
Fix delete behavior for `ToSQLAlchemy` importer, fix tests

No need to expunge the object when deleting, and that was making tests
break in a way that suggested production breakage also..?
2 files changed with 5 insertions and 4 deletions:
0 comments (0 inline, 0 general)
rattail/importing/sqlalchemy.py
Show inline comments
 
@@ -127,7 +127,6 @@ class ToSQLAlchemy(Importer):
 
        truly delete and expunge the local object from the session.
 
        """
 
        self.session.delete(obj)
 
        self.session.expunge(obj)
 
        return True
 

	
 
    def cache_model(self, model, **kwargs):
rattail/tests/importing/test_sqlalchemy.py
Show inline comments
 
@@ -102,8 +102,8 @@ class TestToSQLAlchemy(TestCase):
 
    def test_create_object(self):
 
        importer = self.make_importer(key='id', session=self.session)
 
        widget = importer.create_object((42,), {'id': 42, 'description': "Latest Widget"})
 
        self.assertFalse(self.session.new or self.session.dirty or self.session.deleted) # i.e. has been flushed
 
        self.assertIn(widget, self.session) # therefore widget has been flushed and would be committed
 
        self.assertIn(widget, self.session)
 
        self.assertIn(widget, self.session.new)
 
        self.assertEqual(widget.id, 42)
 
        self.assertEqual(widget.description, "Latest Widget")
 

	
 
@@ -112,7 +112,9 @@ class TestToSQLAlchemy(TestCase):
 
        self.assertIn(widget, self.session)
 
        importer = self.make_importer(session=self.session)
 
        self.assertTrue(importer.delete_object(widget))
 
        self.assertNotIn(widget, self.session)
 
        self.assertIn(widget, self.session)
 
        self.assertIn(widget, self.session.deleted)
 
        self.session.flush()
 
        self.assertIsNone(self.session.query(Widget).get(1))
 

	
 
    def test_cache_model(self):
0 comments (0 inline, 0 general)