Ticket #868: no_autoflush_deletes.diff

File no_autoflush_deletes.diff, 3.3 KB (added by kindly@…, 3 years ago)

This is a patch so that we do not need to monkeypatch sqlalchemy dialects

  • ckan/lib/create_test_data.py

    diff -r 336570412918 ckan/lib/create_test_data.py
    a b  
    415415                model.Session.execute(sql) 
    416416        model.repo.commit_and_remove() 
    417417        for pkg_name in self.pkg_names: 
     418            model.Session().autoflush = False 
    418419            pkg = model.Package.by_name(unicode(pkg_name)) 
    419420            if pkg: 
    420421                pkg.purge() 
     
    432433                pkg.purge() 
    433434            for grp in rev.groups: 
    434435                grp.purge() 
     436            model.Session.commit() 
    435437            model.Session.delete(rev) 
    436438        for user_name in self.user_names: 
    437439            user = model.User.by_name(unicode(user_name)) 
  • ckan/model/domain_object.py

    diff -r 336570412918 ckan/model/domain_object.py
    a b  
    7575        self.Session.delete(self) 
    7676 
    7777    def purge(self): 
     78        self.Session().autoflush = False 
    7879        if hasattr(self, '__revisioned__'): # only for versioned objects ... 
    7980            # this actually should auto occur due to cascade relationships but 
    8081            # ... 
  • ckan/tests/forms/test_group.py

    diff -r 336570412918 ckan/tests/forms/test_group.py
    a b  
    1010 
    1111    @classmethod 
    1212    def teardown_class(self): 
    13         ckan.tests.CreateTestData.delete() 
     13        model.repo.clean_db() 
    1414 
    1515    def test_1(self): 
    1616        group = model.Group.by_name(u'roger') 
  • ckan/tests/functional/api/test_model.py

    diff -r 336570412918 ckan/tests/functional/api/test_model.py
    a b  
    363363    def teardown(self): 
    364364        for relationship in self.anna.get_relationships(): 
    365365            relationship.purge() 
     366        model.Session.commit() 
    366367        relationships = self.anna.get_relationships() 
    367368        assert relationships == [], "There are still some relationships: %s" % relationships 
    368369 
  • ckan/tests/functional/test_group.py

    diff -r 336570412918 ckan/tests/functional/test_group.py
    a b  
    3939 
    4040    @classmethod 
    4141    def teardown_class(self): 
    42         CreateTestData.delete() 
     42        model.repo.clean_db() 
    4343 
    4444    def test_mainmenu(self): 
    4545        offset = url_for(controller='home', action='index') 
  • ckan/tests/models/test_harvesting.py

    diff -r 336570412918 ckan/tests/models/test_harvesting.py
    a b  
    2222        self.gemini = GeminiExamples() 
    2323 
    2424    def teardown(self): 
    25         if self.document: 
    26             self.delete(self.document) 
    27         for document in HarvestedDocument.filter(): 
    28             document.delete() 
    29         if self.job: 
    30             self.delete(self.job) 
    31         if self.source: 
    32             self.delete(self.source) 
    33         self.commit_remove() 
    34         self.purge_package_by_name('00a743bf-cca4-4c19-a8e5-e64f7edbcadd') 
    35         super(HarvesterTestCase, self).teardown() 
    3625        model.repo.clean_db() 
    3726 
    3827    def create_fixture(self, domain_type, **kwds):