def test_failsafe_add(self):
        d1 = NamedDocument(name=u'add_and_commit_test', title=u"Test")
        d1a = failsafe_add(self.session, d1, name=u'add_and_commit_test')
        self.assertTrue(d1a is d1)  # We got back what we created, so the commit succeeded

        d2 = NamedDocument(name=u'add_and_commit_test', title=u"Test")
        d2a = failsafe_add(self.session, d2, name=u'add_and_commit_test')
        self.assertFalse(d2a is d2)  # This time we got back d1 instead of d2
        self.assertTrue(d2a is d1)
failsafe_add gracefully handles IntegrityError from dupe entries
dataset/ETHPy150Open hasgeek/coaster/tests/test_models.py/TestCoasterModels.test_failsafe_add