def test_idempotent_unsubscribe(config):
    configure(config)
    with patch('h.notification.models.Subscriptions'
               '.get_templates_for_uri_and_type') as mock_subs:
        mock_db = Mock(add=Mock())
        mock_subscription = Mock(active=False)

        mock_subs.return_value = [mock_subscription]

        request = _unsubscribe_request()
        request.db = mock_db

        from h.notification.views import unsubscribe
        unsubscribe(request)

        assert mock_subscription.active is False
        assert not mock_db.add.called
if called a second time it should not update the model
dataset/ETHPy150Open hypothesis/h/h/notification/test/notification_views_test.py/test_idempotent_unsubscribe