def test_accept_share(self):
        """Test accepting a direct share."""
        user1 = self.factory.make_user(username='sharer')
        root = StorageObject.objects.get_root(user1)
        share = self.factory.make_share(
            subtree=root, shared_to=self.user._user, name='Share',
            accepted=False)
        self.assertEqual(share.status, STATUS_LIVE)
        self.assertFalse(share.accepted)
        # this should succeed
        self.gw.accept_share(share.id)
        share.refresh_from_db()
        self.assertTrue(share.accepted)
        # cant be accepted twice
        self.assertRaises(errors.DoesNotExist, self.gw.accept_share, share.id)
        # if it's dead, it can't be accepted
        share.status = STATUS_DEAD
        share.save()
        self.assertRaises(errors.DoesNotExist, self.gw.accept_share, share.id)