示例#1
0
def creativity_session_widget_post(request, test_session, discussion,
                                   participant1_user,
                                   creativity_session_widget,
                                   creativity_session_widget_new_idea):
    """A Post fixture with a bound to a creativity widget to a new idea and
    an idea content link"""

    from assembl.models import (Post, IdeaContentWidgetLink, LangString)
    p = Post(discussion=discussion,
             creator=participant1_user,
             subject=LangString.create(u"re: generated idea"),
             body=LangString.create(u"post body"),
             type="post",
             message_id="*****@*****.**")
    test_session.add(p)
    test_session.flush()
    icwl = IdeaContentWidgetLink(content=p,
                                 idea=creativity_session_widget_new_idea,
                                 creator=participant1_user)
    test_session.add(icwl)

    def fin():
        print("finalizer creativity_session_widget_post")
        test_session.delete(icwl)
        test_session.delete(p)
        test_session.flush()

    request.addfinalizer(fin)

    return p
示例#2
0
文件: ideas.py 项目: pierre56/assembl
def subidea_1_1_1_1_2_2(request, discussion, subidea_1_1_1_1_2, test_session):
    """An Idea fixture with a idealink to subidea_1_1_1_1_2 fixture::

        root_idea
            |-> subidea_1
                |-> subidea_1_1
                    |-> subidea_1_1_1
                        |-> subidea_1_1_1_1
                            |-> subidea_1_1_1_1
                            |-> subidea_1_1_1_2
                                |-> subidea_1_1_1_1_2_1
                                |-> subidea_1_1_1_1_2_2"""

    from assembl.models import Idea, IdeaLink, LangString
    i = Idea(title=LangString.create(u"Federal programs are ineffective",
                                     'en'),
             discussion=discussion,
             description=LangString.create("Some definition of an idea", 'en'))
    test_session.add(i)
    l_11112_111122 = IdeaLink(source=subidea_1_1_1_1_2, target=i)
    test_session.add(l_11112_111122)
    test_session.flush()

    def fin():
        print "finalizer subidea_1_1_1_1_2_2"
        test_session.delete(l_11112_111122)
        test_session.delete(i)
        test_session.flush()

    request.addfinalizer(fin)
    return i
示例#3
0
def creativity_session_widget_new_idea(request, test_session, discussion,
                                       subidea_1, creativity_session_widget,
                                       participant1_user):
    """An Idea fixture with an bound ideaLink,
    GeneratedIdeaWidgetLink, and a IdeaProposalPost"""

    from assembl.models import (Idea, IdeaLink, GeneratedIdeaWidgetLink,
                                IdeaProposalPost, LangString)
    i = Idea(discussion=discussion,
             title=LangString.create(u"generated idea", 'en'))
    test_session.add(i)
    l_1_wi = IdeaLink(source=subidea_1, target=i)
    test_session.add(l_1_wi)
    l_w_wi = GeneratedIdeaWidgetLink(widget=creativity_session_widget, idea=i)
    ipp = IdeaProposalPost(proposes_idea=i,
                           creator=participant1_user,
                           discussion=discussion,
                           message_id='*****@*****.**',
                           subject=LangString.create(u"propose idea"),
                           body=LangString.EMPTY(test_session))
    test_session.add(ipp)

    def fin():
        print("finalizer creativity_session_widget_new_idea")
        test_session.delete(ipp)
        test_session.delete(l_w_wi)
        test_session.delete(l_1_wi)
        test_session.delete(i)
        test_session.flush()

    request.addfinalizer(fin)

    return i
示例#4
0
def reply_deleted_post_4(request, participant2_user, discussion, reply_post_1,
                         test_session):
    """
    From participant2_user, in reply to reply_post_1
    """
    from assembl.models import Post, LangString, PublicationStates
    p = Post(discussion=discussion,
             creator=participant2_user,
             subject=LangString.create(u"re2: root post"),
             body=LangString.create(u"post body"),
             publication_state=PublicationStates.DELETED_BY_ADMIN,
             type="post",
             message_id="*****@*****.**")
    test_session.add(p)
    test_session.flush()
    p.set_parent(reply_post_1)
    test_session.flush()

    def fin():
        print("finalizer reply_deleted_post_4")
        test_session.delete(p)
        test_session.flush()

    request.addfinalizer(fin)
    return p
示例#5
0
def creativity_session_widget_new_idea(
        request, test_session, discussion, subidea_1,
        creativity_session_widget, participant1_user):
    """An Idea fixture with an bound ideaLink,
    GeneratedIdeaWidgetLink, and a IdeaProposalPost"""

    from assembl.models import (Idea, IdeaLink, GeneratedIdeaWidgetLink,
                                IdeaProposalPost, LangString)
    i = Idea(
        discussion=discussion,
        title=LangString.create(u"generated idea", 'en'))
    test_session.add(i)
    l_1_wi = IdeaLink(source=subidea_1, target=i)
    test_session.add(l_1_wi)
    l_w_wi = GeneratedIdeaWidgetLink(
        widget=creativity_session_widget,
        idea=i)
    ipp = IdeaProposalPost(
        proposes_idea=i, creator=participant1_user, discussion=discussion,
        message_id='*****@*****.**',
        subject=LangString.create(u"propose idea"),
        body=LangString.EMPTY(test_session))
    test_session.add(ipp)

    def fin():
        print "finalizer creativity_session_widget_new_idea"
        test_session.delete(ipp)
        test_session.delete(l_w_wi)
        test_session.delete(l_1_wi)
        test_session.delete(i)
        test_session.flush()
    request.addfinalizer(fin)

    return i
示例#6
0
def creativity_session_widget_post(
        request, test_session, discussion, participant1_user,
        creativity_session_widget, creativity_session_widget_new_idea):
    """A Post fixture with a bound to a creativity widget to a new idea and
    an idea content link"""

    from assembl.models import (Post, IdeaContentWidgetLink, LangString)
    p = Post(
        discussion=discussion, creator=participant1_user,
        subject=LangString.create(u"re: generated idea"),
        body=LangString.create(u"post body"),
        type="post", message_id="*****@*****.**")
    test_session.add(p)
    test_session.flush()
    icwl = IdeaContentWidgetLink(
        content=p, idea=creativity_session_widget_new_idea,
        creator=participant1_user)
    test_session.add(icwl)

    def fin():
        print "finalizer creativity_session_widget_post"
        test_session.delete(icwl)
        test_session.delete(p)
        test_session.flush()
    request.addfinalizer(fin)

    return p
示例#7
0
def test_add_discussion(test_session):
    d = Discussion(topic=u"Education",
                   slug="education",
                   subscribe_to_notifications_on_signup=False,
                   creator=None,
                   session=test_session)
    d.discussion_locales = ['en', 'fr', 'de']
    d.terms_and_conditions = LangString.create(
        u"Use the haptic JSON system, then you can quantify the cross-platform capacitor!",
        "en")
    d.legal_notice = LangString.create(
        u"Use the optical SCSI microchip, then you can generate the cross-platform pixel!",
        "en")
    test_session.flush()
    assert d.topic == u"Education"
    assert d.discussion_locales == ['en', 'fr', 'de']
    assert d.terms_and_conditions.entries[
        0].value == u"Use the haptic JSON system, then you can quantify the cross-platform capacitor!"  # noqa: E501
    assert d.legal_notice.entries[
        0].value == u"Use the optical SCSI microchip, then you can generate the cross-platform pixel!"  # noqa: E501
    test_session.delete(d.table_of_contents)
    test_session.delete(d.root_idea)
    test_session.delete(d.next_synthesis)
    preferences = d.preferences
    d.preferences = None
    d.preferences_id = None
    for ut in d.user_templates:
        for ns in ut.notification_subscriptions:
            ns.delete()
        ut.delete()
    test_session.delete(preferences)
    test_session.delete(d)
    test_session.flush()
示例#8
0
文件: posts.py 项目: shangxor/assembl
def post_body_locale_determined_by_import(
        request, test_session, discussion, admin_user, mailbox,
        undefined_locale, fr_locale, en_locale):
    from assembl.models import Email, LangString
    p = Email(
        discussion=discussion, creator=admin_user,
        subject=LangString.create(u"testa"),
        body=LangString.create(u"testa"),
        source=mailbox,
        body_mime_type="text/plain",
        sender="*****@*****.**",
        recipients="*****@*****.**",
        message_id="*****@*****.**",
        imported_blob="""Subject: testa
From: Mr. Administrator <*****@*****.**>
Content-Language: fr
Content-Type: text/plain; charset="iso-8859-1"

testa""")
    # must be done after the source is set
    p.source_post_id = "*****@*****.**"
    test_session.add(p)
    test_session.flush()

    def fin():
        print "finalizer post_subject_locale_determined_by_creator"
        test_session.delete(p)
        test_session.flush()
    request.addfinalizer(fin)
    return p
示例#9
0
文件: posts.py 项目: shangxor/assembl
def root_post_en_under_positive_column_of_idea(
        request, test_session, discussion, admin_user,
        idea_message_column_positive):
    from assembl.models import Post, LangString, IdeaRelatedPostLink
    idea = idea_message_column_positive.idea
    p = Post(
        discussion=discussion, creator=admin_user,
        subject=LangString.create(u"A simple positive subject"),
        body=LangString.create(u"A simple positive body"),
        type='post', message_id="*****@*****.**",
        message_classifier=idea_message_column_positive.message_classifier)

    idc = IdeaRelatedPostLink(
        idea=idea,
        creator=admin_user,
        content=p)

    test_session.add(p)
    test_session.add(idc)
    test_session.flush()

    def fin():
        print "finalizer root_post_en_under_positive_column_of_idea"
        test_session.delete(p)
        test_session.delete(idc)
        test_session.flush()

    request.addfinalizer(fin)
    return p
示例#10
0
def timeline_vote_session(request, test_session, discussion):
    from assembl.models import DiscussionPhase, LangString

    phase = DiscussionPhase(
        discussion=discussion,
        identifier='voteSession',
        title=LangString.create(u"voteSession phase title fixture", "en"),
        description=LangString.create(u"voteSession phase description fixture", "en"),
        start=datetime(2014, 12, 31, 9, 0, 0),
        end=datetime(2015, 12, 31, 9, 0, 0),
        interface_v1=False,
        image_url=u'https://example.net/image.jpg'
    )


    # Create the phase
    test_session.add(phase)
    test_session.flush()

    def fin():
        print "finalizer timeline"
        test_session.delete(phase)
        test_session.flush()

    request.addfinalizer(fin)
    return phase
示例#11
0
文件: ideas.py 项目: assembl/assembl
def subidea_1_1_1_1_1(request, discussion, subidea_1_1_1_1, test_session):
    """An Idea fixture with a idealink to subidea_1_1_1_1 fixture::

        root_idea
            |-> subidea_1
                |-> subidea_1_1
                    |-> subidea_1_1_1
                        |-> subidea_1_1_1_1
                            |-> subidea_1_1_1_1"""

    from assembl.models import Idea, IdeaLink, LangString
    i = Idea(title=LangString.create(u"Job loss", 'en'),
             discussion=discussion,
             description=LangString.create("Some definition of an idea", 'en'))
    test_session.add(i)
    l_1111_11111 = IdeaLink(source=subidea_1_1_1_1, target=i)
    test_session.add(l_1111_11111)
    test_session.flush()

    def fin():
        print "finalizer subidea_1_1_1_1_1_1"
        test_session.delete(l_1111_11111)
        test_session.delete(i)
        test_session.flush()
    request.addfinalizer(fin)
    return i
示例#12
0
文件: ideas.py 项目: assembl/assembl
def subidea_1_1_1_1_2_2(request, discussion, subidea_1_1_1_1_2, test_session):
    """An Idea fixture with a idealink to subidea_1_1_1_1_2 fixture::

        root_idea
            |-> subidea_1
                |-> subidea_1_1
                    |-> subidea_1_1_1
                        |-> subidea_1_1_1_1
                            |-> subidea_1_1_1_1
                            |-> subidea_1_1_1_2
                                |-> subidea_1_1_1_1_2_1
                                |-> subidea_1_1_1_1_2_2"""

    from assembl.models import Idea, IdeaLink, LangString
    i = Idea(title=LangString.create(u"Federal programs are ineffective", 'en'),
             discussion=discussion,
             description=LangString.create("Some definition of an idea", 'en'))
    test_session.add(i)
    l_11112_111122 = IdeaLink(source=subidea_1_1_1_1_2, target=i)
    test_session.add(l_11112_111122)
    test_session.flush()

    def fin():
        print "finalizer subidea_1_1_1_1_2_2"
        test_session.delete(l_11112_111122)
        test_session.delete(i)
        test_session.flush()
    request.addfinalizer(fin)
    return i
示例#13
0
文件: ideas.py 项目: assembl/assembl
def subidea_1_1_1(request, discussion, subidea_1_1, test_session):
    """An Idea fixture with a idealink to subidea_1_1 fixture::

        root_idea
            |-> subidea_1
                |-> subidea_1_1
                    |-> subidea_1_1_1"""

    from assembl.models import Idea, IdeaLink, LangString
    title = LangString.create(u"Lower government revenue", 'en')
    title.add_value(u'Moins de revenus pour le gouvernement', 'fr')
    i = Idea(title=title,
             discussion=discussion,
             description=LangString.create("Some definition of an idea", 'en'))
    test_session.add(i)
    l_11_111 = IdeaLink(source=subidea_1_1, target=i)
    test_session.add(l_11_111)
    test_session.flush()

    def fin():
        print "finalizer subidea_1_1_1"
        test_session.delete(l_11_111)
        test_session.delete(i)
        test_session.flush()
    request.addfinalizer(fin)
    return i
示例#14
0
def idea_message_column_negative_on_subidea_1_1(request,
                                                test_adminuser_webrequest,
                                                subidea_1_1, test_session):
    from assembl.models import IdeaMessageColumn, LangString

    column = IdeaMessageColumn(idea=subidea_1_1,
                               message_classifier='negative',
                               name=LangString.create('Say my name', 'en'),
                               title=LangString.create(
                                   'Add your point of view against the theme',
                                   'en'),
                               color="red")

    test_session.add(column)
    synthesis = column.create_column_synthesis(
        subject=LangString.create('Be negative!', 'en'),
        body=LangString.create('This is a negative header', 'en'),
        creator_id=test_adminuser_webrequest.authenticated_userid)
    test_session.flush()

    def fin():
        test_session.delete(synthesis)
        test_session.delete(synthesis.idea_links_of_content[0])
        test_session.delete(column)
        test_session.flush()

    request.addfinalizer(fin)
    return column
示例#15
0
def post_draft_for_bright_mirror(
        request, test_session, discussion, moderator_user,
        bright_mirror):
    from assembl.models import Post, Idea, LangString, IdeaRelatedPostLink, PublicationStates
    from graphene.relay import Node
    idea_id = bright_mirror
    raw_id = int(Node.from_global_id(idea_id)[1])
    idea = Idea.get(raw_id)
    p = Post(
        discussion=discussion, creator=moderator_user,
        subject=LangString.create(u"Draft"),
        body=LangString.create(u"A simple draft fiction"),
        type='post', publication_state=PublicationStates.DRAFT,
        message_id="*****@*****.**",
        creation_date = datetime.utcnow() - timedelta(days=7))

    idc = IdeaRelatedPostLink(
        idea=idea,
        creator=moderator_user,
        content=p)

    test_session.add(p)
    test_session.add(idc)
    test_session.flush()

    def fin():
        print "finalizer post_draft_for_bright_mirror"
        test_session.delete(p)
        test_session.delete(idc)
        test_session.flush()

    request.addfinalizer(fin)
    return p
示例#16
0
def post_published_for_bright_mirror_participant(
        request, test_session, discussion, admin_user, participant1_user,
        bright_mirror):
    from assembl.models import Post, Idea, LangString, IdeaRelatedPostLink, PublicationStates
    from graphene.relay import Node
    idea_id = bright_mirror
    raw_id = int(Node.from_global_id(idea_id)[1])
    idea = Idea.get(raw_id)
    p = Post(
        discussion=discussion, creator=participant1_user,
        subject=LangString.create(u"Published by participant"),
        body=LangString.create(u"A simple published fiction by participant"),
        type='post', publication_state=PublicationStates.PUBLISHED,
        message_id="*****@*****.**",
        creation_date = datetime.utcnow())

    idc = IdeaRelatedPostLink(
        idea=idea,
        creator=admin_user,
        content=p)

    test_session.add(p)
    test_session.add(idc)
    test_session.flush()

    def fin():
        print "finalizer post_published_for_bright_mirror"
        test_session.delete(p)
        test_session.delete(idc)
        test_session.flush()

    request.addfinalizer(fin)
    return p
示例#17
0
def root_post_with_tags(request, participant1_user, discussion, test_session,
                        tags):
    """
    From participant1_user
    """
    from assembl.models import Post, LangString
    p = Post(discussion=discussion,
             creator=participant1_user,
             subject=LangString.create(u"a root post"),
             body=LangString.create(u"post body"),
             moderator=None,
             creation_date=datetime(year=2000, month=1, day=1),
             type="post",
             message_id="*****@*****.**")
    p.tags = tags
    test_session.add(p)
    test_session.flush()

    def fin():
        print("finalizer root_post_with_tags")
        p.tags = []
        test_session.delete(p)
        test_session.flush()

    request.addfinalizer(fin)
    return p
示例#18
0
文件: posts.py 项目: shangxor/assembl
def post_related_to_sub_idea_1_1_1(
        request, test_session, discussion, admin_user, subidea_1_1_1):
    from assembl.models import Post, LangString, IdeaRelatedPostLink
    idea = subidea_1_1_1
    p = Post(
        discussion=discussion, creator=admin_user,
        subject=LangString.create(u"A post subject related to sub_idea_1_1_1"),
        body=LangString.create(u"A post body related to sub_idea_1_1_1"),
        creation_date=datetime(2018, 2, 17, 9, 0, 0),  # in the thread phase date range (see phases fixture)
        type='post', message_id="*****@*****.**")

    idc = IdeaRelatedPostLink(
        idea=idea,
        creator=admin_user,
        content=p)

    test_session.add(p)
    test_session.add(idc)
    test_session.flush()

    def fin():
        print "finalizer post_related_to_sub_idea_1_1_1"
        test_session.delete(p)
        test_session.delete(idc)
        test_session.flush()

    request.addfinalizer(fin)
    return p
示例#19
0
文件: ideas.py 项目: pierre56/assembl
def subidea_1_2_1(request, discussion, subidea_1_2, test_session):
    """An Idea fixture with a idealink to subidea_1 fixture::

        root_idea
            |-> subidea_1
                |-> subidea_1_2
                    |-> subidea_1_2_1"""

    from assembl.models import Idea, IdeaLink, LangString
    i = Idea(title=LangString.create(u"Bad for the environment", 'en'),
             discussion=discussion,
             description=LangString.create("Some definition of an idea", 'en'))
    test_session.add(i)
    l_12_121 = IdeaLink(source=subidea_1_2, target=i)
    test_session.add(l_12_121)
    test_session.flush()

    def fin():
        print "finalizer subidea_1_2_1"
        test_session.delete(l_12_121)
        test_session.delete(i)
        test_session.flush()

    request.addfinalizer(fin)
    return i
示例#20
0
def post_related_to_sub_idea_1_participant2(request, test_session, discussion,
                                            participant2_user, subidea_1):
    from assembl.models import Post, LangString, IdeaRelatedPostLink
    idea = subidea_1
    p = Post(discussion=discussion,
             creator=participant2_user,
             subject=LangString.create(u"A post related to sub_idea_1 "),
             body=LangString.create(u"A post related to sub_idea_1"),
             creation_date=datetime(year=2000, month=1, day=6),
             type='post',
             message_id="*****@*****.**")

    idc = IdeaRelatedPostLink(idea=idea, creator=participant2_user, content=p)

    test_session.add(p)
    test_session.add(idc)
    test_session.flush()

    def fin():
        test_session.delete(p)
        test_session.delete(idc)
        test_session.flush()

    request.addfinalizer(fin)
    return p
示例#21
0
def reply_post_2(request, participant1_user, discussion, reply_post_1,
                 test_session):
    """
    From participant1_user, in reply to reply_post_1
    """
    from assembl.models import Post, LangString
    p = Post(discussion=discussion,
             creator=participant1_user,
             subject=LangString.create(u"re2: root post"),
             body=LangString.create(u"post body"),
             creation_date=datetime(year=2000, month=1, day=5),
             type="post",
             message_id="*****@*****.**")
    test_session.add(p)
    test_session.flush()
    p.set_parent(reply_post_1)
    test_session.flush()

    def fin():
        print("finalizer reply_post_2")
        test_session.delete(p)
        test_session.flush()

    request.addfinalizer(fin)
    return p
示例#22
0
def idea_message_column_negative_on_subidea_1_1(request, test_adminuser_webrequest, subidea_1_1, test_session):
    from assembl.models import IdeaMessageColumn, LangString

    column = IdeaMessageColumn(idea=subidea_1_1,
                               message_classifier='negative',
                               name=LangString.create('Say my name', 'en'),
                               title=LangString.create('Add your point of view against the theme', 'en'),
                               color="red")

    test_session.add(column)
    synthesis = column.create_column_synthesis(
        subject=LangString.create('Be negative!', 'en'),
        body=LangString.create('This is a negative header', 'en'),
        creator_id=test_adminuser_webrequest.authenticated_userid
    )
    test_session.flush()

    def fin():
        test_session.delete(synthesis)
        test_session.delete(synthesis.idea_links_of_content[0])
        test_session.delete(column)
        test_session.flush()

    request.addfinalizer(fin)
    return column
示例#23
0
def root_post_1_with_positive_message_classifier(request, participant1_user,
                                                 idea_message_column_positive,
                                                 discussion, test_session):
    """
    From participant1_user
    """
    from assembl.models import Post, LangString
    p = Post(
        discussion=discussion,
        creator=participant1_user,
        subject=LangString.create(u"a root post"),
        body=LangString.create(u"post body"),
        moderator=None,
        creation_date=datetime(year=2000, month=1, day=1),
        type="post",
        message_id="*****@*****.**",
        message_classifier=idea_message_column_positive.message_classifier)
    test_session.add(p)
    test_session.flush()

    def fin():
        print("finalizer root_post_1")
        test_session.delete(p)
        test_session.flush()

    request.addfinalizer(fin)
    return p
示例#24
0
def reply_post_1(request, participant2_user, discussion, root_post_1,
                 test_session):
    """
    From participant2_user, in reply to root_post_1
    """
    from assembl.models import Post, LangString
    p = Post(
        discussion=discussion,
        creator=participant2_user,
        subject=LangString.create(u"re1: root post"),
        body=LangString.create(
            u"post body with some text so we can test harvesting features. I'm writing a very topical comment with an unrelated source, hoping it would make people angry and make them write answers. I have read in '17O Solid-State NMR Spectroscopy of Functional Oxides for Energy Conversion' thesis by Halat, D. M. (2018) that variable-temperature spectra indicate the onset of oxide-ion motion involving the interstitials at 130 °C, which is linked to an orthorhombic−tetragonal phase transition. For the V-doped phases, an oxide-ion conduction mechanism is observed that involves oxygen exchange between the Bi-O sublattice and rapidly rotating VO4 tetrahedral units. The more poorly conducting P-doped phase exhibits only vacancy conduction with no evidence of sublattice exchange, a result ascribed to the differing propensities of the dopants to undergo variable oxygen coordination. So I think it would be a very bad idea to allow hot beverages in coworking spaces. But it looks like people don't really care about scientific evidence around here."
        ),
        creation_date=datetime(year=2000, month=1, day=4),
        type="post",
        message_id="*****@*****.**")
    test_session.add(p)
    test_session.flush()
    p.set_parent(root_post_1)
    test_session.flush()

    def fin():
        print("finalizer reply_post_1")
        test_session.delete(p)
        test_session.flush()

    request.addfinalizer(fin)
    return p
示例#25
0
def timeline_vote_session(request, test_session, discussion):
    from assembl.models import DiscussionPhase, LangString

    phase = DiscussionPhase(
        discussion = discussion,
        identifier = 'voteSession',
        title = LangString.create(u"voteSession phase title fixture", "en"),
        description = LangString.create(u"voteSession phase description fixture", "en"),
        start = datetime(2014, 12, 31, 9, 0, 0),
        end = datetime(2015, 12, 31, 9, 0, 0),
        interface_v1 = False,
        image_url = u'https://example.net/image.jpg'
    )


    # Create the phase
    test_session.add(phase)
    test_session.flush()

    def fin():
        print "finalizer timeline"
        test_session.delete(phase)
        test_session.flush()

    request.addfinalizer(fin)
    return phase
示例#26
0
def subidea_1_1_1_1(request, discussion, subidea_1_1_1, test_session):
    """An Idea fixture with a idealink to subidea_1_1_1 fixture::

        root_idea
            |-> subidea_1
                |-> subidea_1_1
                    |-> subidea_1_1_1
                        |->subidea_1_1_1_1"""

    from assembl.models import Idea, IdeaLink, LangString
    i = Idea(title=LangString.create(u"Austerity yields contraction", 'en'),
             discussion=discussion,
             description=LangString.create("Some definition of an idea", 'en'))
    test_session.add(i)
    l_111_1111 = IdeaLink(source=subidea_1_1_1, target=i)
    test_session.add(l_111_1111)
    test_session.flush()

    def fin():
        print("finalizer subidea_1_1_1_1")
        test_session.delete(l_111_1111)
        test_session.delete(i)
        test_session.flush()
    request.addfinalizer(fin)
    return i
示例#27
0
def subidea_1_1_1(request, discussion, subidea_1_1, test_session):
    """An Idea fixture with a idealink to subidea_1_1 fixture::

        root_idea
            |-> subidea_1
                |-> subidea_1_1
                    |-> subidea_1_1_1"""

    from assembl.models import Idea, IdeaLink, LangString
    title = LangString.create(u"Lower government revenue", 'en')
    title.add_value(u'Moins de revenus pour le gouvernement', 'fr')
    i = Idea(title=title,
             discussion=discussion,
             description=LangString.create("Some definition of an idea", 'en'))
    test_session.add(i)
    l_11_111 = IdeaLink(source=subidea_1_1, target=i)
    test_session.add(l_11_111)
    test_session.flush()

    def fin():
        print("finalizer subidea_1_1_1")
        test_session.delete(l_11_111)
        test_session.delete(i)
        test_session.flush()
    request.addfinalizer(fin)
    return i
示例#28
0
文件: posts.py 项目: shangxor/assembl
def post_related_to_sub_idea_1(
        request, test_session, discussion, admin_user, subidea_1):
    from assembl.models import Post, LangString, IdeaRelatedPostLink
    idea = subidea_1
    p = Post(
        discussion=discussion, creator=admin_user,
        subject=LangString.create(u"A post related to sub_idea_1 "),
        body=LangString.create(u"A post related to sub_idea_1"),
        type='post', message_id="*****@*****.**")

    idc = IdeaRelatedPostLink(
        idea=idea,
        creator=admin_user,
        content=p)

    test_session.add(p)
    test_session.add(idc)
    test_session.flush()

    def fin():
        print "finalizer root_post_en_under_positive_column_of_idea"
        test_session.delete(p)
        test_session.delete(idc)
        test_session.flush()

    request.addfinalizer(fin)
    return p
示例#29
0
def discussion(request, test_session, default_preferences):
    """An empty Discussion fixture with default preferences"""
    from assembl.models import Discussion, LangString
    from assembl.models import Discussion
    #    from assembl.lib.migration import create_default_discussion_data
    with test_session.no_autoflush:
        d = Discussion(topic=u"Jack Layton",
                       slug="jacklayton2",
                       subscribe_to_notifications_on_signup=False,
                       creator=None,
                       session=test_session)
        d.discussion_locales = ['en', 'fr', 'de']
        d.legal_notice = LangString.create(
            u"We need to input the optical HDD sensor!", "en")
        tac = LangString.create(
            u"You can't quantify the driver without quantifying the 1080p JSON protocol!",
            "en")
        tac.add_value(
            u"Vous ne pouvez pas mesurer le driver sans mesurer le protocole JSON en 1080p",
            u"fr")
        d.terms_and_conditions = tac
        test_session.add(d)
        # create_default_discussion_data(d)
        # Don't create default discussion data (permissions, sections) here
        # because it takes too much time to run all tests.
        # If you need sections or permissions in your tests, execute
        # create_default_discussion_data, create_default_discussion_sections
        # or create_default_permissions in your specific test or
        # use discussion_with_default_data fixture.
        # If you do permissions tests, be aware that the admin user
        # having R_SYSADMIN is actually a special case, see
        # auth/utils.py:get_permissions, it doesn't use discussion permissions
        # at all. So you need discussion permissions if you test with the
        # unauthenticated user Everyone or a user not having the R_SYSADMIN role.
    test_session.flush()

    def fin():
        print "finalizer discussion"
        discussion = d
        if inspect(discussion).detached:
            # How did this happen?
            discussion = test_session.query(Discussion).get(d.id)
        test_session.delete(discussion.table_of_contents)
        test_session.delete(discussion.root_idea)
        test_session.delete(discussion.next_synthesis)
        preferences = discussion.preferences
        discussion.preferences = None
        discussion.preferences_id = None
        for ut in discussion.user_templates:
            for ns in ut.notification_subscriptions:
                ns.delete()
            ut.delete()
        test_session.delete(preferences)
        test_session.delete(discussion)
        test_session.flush()

    request.addfinalizer(fin)
    return d
示例#30
0
def announcement_en_fr(request, discussion, en_locale,
                       fr_locale, admin_user, idea_with_en_fr,
                       test_session):
    from assembl.models import LangString, LangStringEntry, IdeaAnnouncement
    title = LangString.create(u'Announce title in English', 'en')
    title.add_entry(LangStringEntry(
                    locale=fr_locale,
                    value=u"Titre d'announce en français",
                    locale_confirmed=True))

    body = LangString.create(u'Announce body in English', 'en')
    body.add_entry(LangStringEntry(
                   locale=fr_locale,
                   value=u"Corps d'announce en français",
                   locale_confirmed=True))
    quote = LangString.create(u'A quote in English', 'en')
    quote.add_entry(LangStringEntry(
                    locale=fr_locale,
                    value=u"Une quote en français",
                    locale_confirmed=True))
    summary = LangString.create(u"Announce summary in English", 'en')
    summary.add_entry(LangStringEntry(
                locale=fr_locale,
                value=u"Announce retenir en Français",
                locale_confirmed=True))
    announce = IdeaAnnouncement(creator=admin_user,
                                last_updated_by=admin_user,
                                title=title,
                                body=body,
                                discussion=discussion,
                                idea=idea_with_en_fr,
                                quote=quote,
                                summary=summary)

    test_session.add(title)
    test_session.add(body)
    test_session.add(summary)
    test_session.add(announce)
    test_session.flush()

    def fin():
        print("finalizer announcement_en_fr")
        test_session.delete(title)
        test_session.delete(body)
        test_session.delete(summary)
        test_session.delete(announce)
        test_session.flush()

    request.addfinalizer(fin)
    return announce
示例#31
0
def test_add_resource(admin_user, discussion, test_session):
    from assembl.models.resource import Resource
    from assembl.models import LangString

    resource = Resource(discussion_id=discussion.id,
                        title=LangString.create(u"a resource"),
                        text=LangString.create(u"Lorem ipsum dolor sit amet"),
                        embed_code=u"<iframe ...>",
                        order=3.0)

    assert resource.title.entries[0].value == u'a resource'
    assert resource.text.entries[0].value == u'Lorem ipsum dolor sit amet'
    assert resource.embed_code == u"<iframe ...>"
    assert resource.order == 3.0
示例#32
0
def sections(request, discussion_with_default_data, test_session):
    """Create default sections."""
    from assembl.models import Section, LangString
    from assembl.models.section import SectionTypesEnum
    discussion_id = discussion_with_default_data.id

    # default sections are created in the discussion_with_default_data fixture
    # via create_default_discussion_data

    sections = []
    # add a custom section
    custom_section = Section(
        discussion_id=discussion_id,
        title=LangString.create(u'GNU is not Unix', 'en'),
        url=u'http://www.gnu.org',
        section_type=SectionTypesEnum.CUSTOM.value,
        order=4.0
    )
    sections.append(custom_section)

    for section in sections:
        test_session.add(section)
    test_session.flush()

    def fin():
        print "finalizer sections"
        for section in sections:
            test_session.delete(section)
        test_session.flush()
    request.addfinalizer(fin)

    return sections
示例#33
0
def test_add_resource(admin_user, discussion, test_session):
    from assembl.models.resource import Resource
    from assembl.models import LangString

    resource = Resource(
        discussion_id=discussion.id,
        title=LangString.create(u"a resource"),
        text=LangString.create(u"Lorem ipsum dolor sit amet"),
        embed_code=u"<iframe ...>",
        order=3.0
    )

    assert resource.title.entries[0].value == u'a resource'
    assert resource.text.entries[0].value == u'Lorem ipsum dolor sit amet'
    assert resource.embed_code == u"<iframe ...>"
    assert resource.order == 3.0
示例#34
0
def sections(request, discussion_with_default_data, test_session):
    """Create default sections."""
    from assembl.models import Section, LangString
    from assembl.models.section import SectionTypesEnum
    discussion_id = discussion_with_default_data.id

    # default sections are created in the discussion_with_default_data fixture
    # via create_default_discussion_data

    sections = []
    # add a custom section
    custom_section = Section(discussion_id=discussion_id,
                             title=LangString.create(u'GNU is not Unix', 'en'),
                             url=u'http://www.gnu.org',
                             section_type=SectionTypesEnum.CUSTOM.value,
                             order=4.0)
    sections.append(custom_section)

    for section in sections:
        test_session.add(section)
    test_session.flush()

    def fin():
        print("finalizer sections")
        for section in sections:
            test_session.delete(section)
        test_session.flush()

    request.addfinalizer(fin)

    return sections
示例#35
0
文件: posts.py 项目: n0izn0iz/assembl
def fully_ambiguous_post(request, test_session, discussion, participant1_user,
                         undefined_locale, fr_locale, en_locale):
    from assembl.models import Content, LangString
    p = Content(discussion=discussion,
                subject=LangString.create(u"testa"),
                body=LangString.create(u"testa"))
    test_session.add(p)
    test_session.flush()

    def fin():
        print "finalizer fully_ambiguous_post"
        test_session.delete(p)
        test_session.flush()

    request.addfinalizer(fin)
    return p
示例#36
0
def post_subject_locale_determined_by_body(
        request, test_session, discussion):
    from assembl.models import Content, LangString
    p = Content(
        discussion=discussion,
        subject=LangString.create(u"testa"),
        body=LangString.create(u"Contenu clairement en français"))
    test_session.add(p)
    test_session.flush()

    def fin():
        print("finalizer post_subject_locale_determined_by_body")
        test_session.delete(p)
        test_session.flush()
    request.addfinalizer(fin)
    return p
示例#37
0
def vote_session(request, test_session, discussion, timeline_vote_session,
                 simple_file, admin_user):
    from assembl.graphql.utils import create_root_thematic
    from assembl.models import Thematic, VoteSession, VoteSessionAttachment, LangString
    vote_session = VoteSession(
        discussion=discussion,
        discussion_phase=timeline_vote_session,
        title=LangString.create(u"vote session fixture", "en"),
        sub_title=LangString.create(u"vote session sub title fixture", "en"),
        instructions_section_title=LangString.create(
            u"vote session instructions title fixture", "en"),
        instructions_section_content=LangString.create(
            u"vote session instructions fixture. Lorem ipsum dolor sit amet",
            "en"),
        propositions_section_title=LangString.create(
            u"vote session propositions section title fixture", "en"))
    attachment = VoteSessionAttachment(discussion=discussion,
                                       document=simple_file,
                                       vote_session=vote_session,
                                       title=u"vote session image fixture",
                                       creator=admin_user,
                                       attachmentPurpose='IMAGE')

    test_session.add(vote_session)
    test_session.add(attachment)
    test_session.flush()

    identifier = 'voteSession{}'.format(vote_session.id)
    root_thematic = create_root_thematic(discussion, identifier)
    test_session.flush()

    def fin():
        print "finalizer vote_session"
        # header_image may have been replaced by another one in a test
        # so be sure to remove attachments, not header_image
        with test_session.no_autoflush as db:
            for attachment in list(vote_session.attachments):
                if attachment.document != simple_file:
                    attachment.document.delete()
                attachment.delete()

            db.delete(root_thematic)
            db.delete(vote_session)
            db.flush()

    request.addfinalizer(fin)
    return vote_session
示例#38
0
文件: posts.py 项目: shangxor/assembl
def extract_comment(request, extract_post_1_to_subidea_1_1, discussion, admin_user, test_session):
    from assembl.models import ExtractComment, LangString
    p = ExtractComment(
        discussion=discussion, creator=admin_user,
        subject=LangString.create(u"comment of extract title"),
        body=LangString.create(u"comment of extract body"),
        message_id="*****@*****.**",
        parent_extract_id=extract_post_1_to_subidea_1_1.id)
    test_session.add(p)
    test_session.flush()

    def fin():
        print "finalizer post_subject_locale_determined_by_creator"
        test_session.delete(p)
        test_session.flush()
    request.addfinalizer(fin)
    return p
示例#39
0
def test_add_discussion(test_session):
    d = Discussion(
        topic=u"Education", slug="education",
        subscribe_to_notifications_on_signup=False,
        creator=None,
        session=test_session)
    d.discussion_locales = ['en', 'fr', 'de']
    d.terms_and_conditions = LangString.create(
        u"Use the haptic JSON system, then you can quantify the cross-platform capacitor!", "en")
    d.legal_notice = LangString.create(
        u"Use the optical SCSI microchip, then you can generate the cross-platform pixel!", "en")
    test_session.flush()
    assert d.topic == u"Education"
    assert d.discussion_locales == ['en', 'fr', 'de']
    assert d.terms_and_conditions.entries[0].value == u"Use the haptic JSON system, then you can quantify the cross-platform capacitor!"  # noqa: E501
    assert d.legal_notice.entries[0].value == u"Use the optical SCSI microchip, then you can generate the cross-platform pixel!"  # noqa: E501
    test_session.delete(d)
示例#40
0
文件: posts.py 项目: assembl/assembl
def post_subject_locale_determined_by_body(
        request, test_session, discussion,
        undefined_locale, fr_locale, en_locale):
    from assembl.models import Content, LangString
    p = Content(
        discussion=discussion,
        subject=LangString.create(u"testa"),
        body=LangString.create(u"Contenu clairement en français"))
    test_session.add(p)
    test_session.flush()

    def fin():
        print "finalizer post_subject_locale_determined_by_body"
        test_session.delete(p)
        test_session.flush()
    request.addfinalizer(fin)
    return p
示例#41
0
文件: posts.py 项目: assembl/assembl
def fully_ambiguous_post(
        request, test_session, discussion, participant1_user,
        undefined_locale, fr_locale, en_locale):
    from assembl.models import Content, LangString
    p = Content(
        discussion=discussion,
        subject=LangString.create(u"testa"),
        body=LangString.create(u"testa"))
    test_session.add(p)
    test_session.flush()

    def fin():
        print "finalizer fully_ambiguous_post"
        test_session.delete(p)
        test_session.flush()
    request.addfinalizer(fin)
    return p
示例#42
0
def post_body_locale_determined_by_creator(
        request, test_session, discussion, admin_user,
        user_language_preference_fr_cookie):
    from assembl.models import Post, LangString
    p = Post(
        discussion=discussion, creator=admin_user,
        subject=LangString.create(u"testa"),
        body=LangString.create(u"testa"),
        message_id="*****@*****.**")
    test_session.add(p)
    test_session.flush()

    def fin():
        print("finalizer post_subject_locale_determined_by_creator")
        test_session.delete(p)
        test_session.flush()
    request.addfinalizer(fin)
    return p
示例#43
0
文件: ideas.py 项目: assembl/assembl
def subidea_1_2(request, discussion, subidea_1, test_session):
    """A subidea fixture with idealink to subidea_1 fixture"""
    from assembl.models import Idea, IdeaLink, LangString
    i = Idea(title=LangString.create(u"Even lower taxes", 'en'),
             discussion=discussion,
             description=LangString.create("The definition of the subidea_1_2", 'en'))
    test_session.add(i)
    l_1_12 = IdeaLink(source=subidea_1, target=i)
    test_session.add(l_1_12)
    test_session.flush()

    def fin():
        print "finalizer subidea_1_2"
        test_session.delete(l_1_12)
        test_session.delete(i)
        test_session.flush()
    request.addfinalizer(fin)
    return i
示例#44
0
def subidea_1_2(request, discussion, subidea_1, test_session):
    """A subidea fixture with idealink to subidea_1 fixture"""
    from assembl.models import Idea, IdeaLink, LangString
    i = Idea(title=LangString.create(u"Even lower taxes", 'en'),
             discussion=discussion,
             description=LangString.create("The definition of the subidea_1_2", 'en'))
    test_session.add(i)
    l_1_12 = IdeaLink(source=subidea_1, target=i)
    test_session.add(l_1_12)
    test_session.flush()

    def fin():
        print("finalizer subidea_1_2")
        test_session.delete(l_1_12)
        test_session.delete(i)
        test_session.flush()
    request.addfinalizer(fin)
    return i
示例#45
0
def synthesis_post_1(request, participant1_user, discussion, test_session, synthesis_1):
    from assembl.models import SynthesisPost, LangString
    p = SynthesisPost(
        discussion=discussion, creator=participant1_user,
        subject=LangString.create(u"a synthesis post"),
        body=LangString.create(u"post body (unused, it's a synthesis...)"),
        message_id="*****@*****.**",
        creation_date=datetime(year=2000, month=1, day=3),
        publishes_synthesis = synthesis_1)
    test_session.add(p)
    test_session.flush()

    def fin():
        print "finalizer synthesis_post_1"
        test_session.delete(p)
        test_session.flush()
    request.addfinalizer(fin)
    return p
示例#46
0
文件: ideas.py 项目: assembl/assembl
def idea_with_en_fr(request, discussion, en_locale,
                    fr_locale, test_session):
    """A top idea with english and french"""
    from assembl.models import Idea, LangString, LangStringEntry

    title = LangString.create(u'Title in english', 'en')
    title.add_entry(LangStringEntry(
                    locale=fr_locale,
                    value=u'Titre en français',
                    locale_confirmed=True))

    synthesis_title = LangString.create(u'What you need to know', 'en')
    synthesis_title.add_entry(LangStringEntry(
                              locale=fr_locale,
                              value=u'A retnir',
                              locale_confirmed=True))

    description = LangString.create(u'Idea description', 'en')
    description.add_entry(LangStringEntry(
                          locale=fr_locale,
                          value=u'Un Description',
                          locale_confirmed=True))

    idea = Idea(title=title,
                discussion=discussion,
                description=description,
                synthesis_title=synthesis_title)

    test_session.add(title)
    test_session.add(synthesis_title)
    test_session.add(description)
    test_session.add(idea)
    test_session.flush()

    def fin():
        print "finalizer idea_with_en_fr"
        test_session.delete(idea)
        test_session.delete(title)
        test_session.delete(synthesis_title)
        test_session.delete(description)
        test_session.flush()

    request.addfinalizer(fin)
    return idea
示例#47
0
文件: posts.py 项目: assembl/assembl
def post_body_locale_determined_by_creator(
        request, test_session, discussion, admin_user,
        user_language_preference_fr_cookie,
        undefined_locale, fr_locale, en_locale):
    from assembl.models import Post, LangString
    p = Post(
        discussion=discussion, creator=admin_user,
        subject=LangString.create(u"testa"),
        body=LangString.create(u"testa"),
        message_id="*****@*****.**")
    test_session.add(p)
    test_session.flush()

    def fin():
        print "finalizer post_subject_locale_determined_by_creator"
        test_session.delete(p)
        test_session.flush()
    request.addfinalizer(fin)
    return p
示例#48
0
def fix_posts_subjects(db, logger):
    from assembl.models import AssemblPost, Idea, LangString
    count = 0
    with transaction.manager:
        for idea in db.query(Idea).filter(Idea.message_view_override == 'messageColumns'):
            for post in idea.get_related_posts_query():
                locale = post.body.first_original().locale.code
                new_post_subject = LangString.create(u'', locale)
                if idea.title:
                    closest_subject_entry = idea.title.closest_entry(locale)
                    if closest_subject_entry:
                        new_post_subject = LangString.create(closest_subject_entry.value, locale)

                logger.info(u'Old subject: %s', post.subject)
                logger.info(u'New subject: %s', new_post_subject)
                post.subject = new_post_subject
                count += 1

    return count
示例#49
0
文件: ideas.py 项目: assembl/assembl
def annnouncement_for_subidea_1_1(request, discussion, en_locale, 
                        fr_locale, admin_user, subidea_1_1,
                        test_session):
    from assembl.models import LangString, LangStringEntry, IdeaAnnouncement
    title = LangString.create(u'Announce title in English', 'en')
    title.add_entry(LangStringEntry(
                    locale=fr_locale,
                    value=u"Titre d'announce en français",
                    locale_confirmed=True))

    body = LangString.create(u'Announce body in English', 'en')
    body.add_entry(LangStringEntry(
                   locale=fr_locale,
                   value=u"Corps d'announce en français",
                   locale_confirmed=True))
    quote = LangString.create(u'A quote in English', 'en')
    quote.add_entry(LangStringEntry(
                    locale=fr_locale,
                    value=u"Une quote en français",
                    locale_confirmed=True))
    announce = IdeaAnnouncement(creator=admin_user,
                                last_updated_by=admin_user,
                                title=title,
                                body=body,
                                discussion=discussion,
                                idea=subidea_1_1,
                                quote=quote)

    test_session.add(title)
    test_session.add(body)
    test_session.add(announce)
    test_session.flush()

    def fin():
        print "finalizer announcement_en_fr"
        test_session.delete(title)
        test_session.delete(body)
        test_session.delete(announce)
        test_session.flush()

    request.addfinalizer(fin)
    return announce
示例#50
0
文件: posts.py 项目: assembl/assembl
def root_post_1(request, participant1_user, discussion, test_session):
    """
    From participant1_user
    """
    from assembl.models import Post, LangString
    p = Post(
        discussion=discussion, creator=participant1_user,
        subject=LangString.create(u"a root post"),
        body=LangString.create(u"post body"), moderator=None,
        creation_date=datetime(year=2000, month=1, day=1),
        type="post", message_id="*****@*****.**")
    test_session.add(p)
    test_session.flush()

    def fin():
        print "finalizer root_post_1"
        test_session.delete(p)
        test_session.flush()
    request.addfinalizer(fin)
    return p
示例#51
0
def test_get_ideas(discussion, test_app, test_session, test_webrequest):
    url = get_url(discussion, 'ideas')
    res = test_app.get(url)
    assert res.status_code == 200

    ideas = json.loads(res.body)
    num_ideas = len(ideas)

    idea = Idea(
        synthesis_title=LangString.create('This is a long test', 'en'),
        title=LangString.create('This is a test', 'en'),
        discussion=discussion
    )
    test_session.add(idea)
    test_session.flush()
    test_session.commit()
    url = get_url(discussion, 'ideas')
    res = test_app.get(url)
    assert res.status_code == 200

    ideas = json.loads(res.body)
    assert len(ideas) == num_ideas + 1
示例#52
0
def timeline_phase2_interface_v1(request, test_app, test_session, discussion, subidea_1, subidea_2):
    from assembl.models import DiscussionPhase, LangString
    phase1 = DiscussionPhase(
        identifier='survey',
        discussion=discussion,
        title=LangString.create('phase 1', 'en'),
        description=LangString.create('A first exploratory phase', 'en'),
        root_idea=subidea_1,
        start=datetime(2014, 12, 31, 9),
        end=datetime(2015, 12, 31, 9),
        interface_v1=True
    )
    test_session.add(phase1)
    phase2 = DiscussionPhase(
        identifier='thread',
        discussion=discussion,
        title=LangString.create('phase 2', 'en'),
        description=LangString.create('A second divergent phase', 'en'),
        root_idea=subidea_2,
        start=datetime(2015, 12, 31, 9, 1),
        end=datetime(2049, 12, 31, 9),
        previous_event=phase1,
        order=2.0,
        interface_v1=True
    )
    test_session.add(phase2)
    test_session.flush()

    def fin():
        print "finalizer timeline"
        phase2.previous_event = None
        phase2.previous_event_id = None
        phase2.delete()
        phase1.delete()

        test_session.flush()

    request.addfinalizer(fin)
    return phase2
示例#53
0
文件: posts.py 项目: assembl/assembl
def reply_post_3(request, participant2_user, discussion,
                 root_post_1, test_session):
    """
    From participant2_user, in reply to reply_post_2
    """
    from assembl.models import Post, LangString
    p = Post(
        discussion=discussion, creator=participant2_user,
        subject=LangString.create(u"re2: root post"),
        body=LangString.create(u"post body"),
        type="post", message_id="*****@*****.**")
    test_session.add(p)
    test_session.flush()
    p.set_parent(root_post_1)
    test_session.flush()

    def fin():
        print "finalizer reply_post_3"
        test_session.delete(p)
        test_session.flush()
    request.addfinalizer(fin)
    return p
示例#54
0
文件: ideas.py 项目: assembl/assembl
def subidea_2(request, discussion, root_idea, test_session):
    """A subidea fixture with a idealink to root idea fixture::

        root_idea
            |-> subidea_1"""

    from assembl.models import Idea, IdeaLink, LangString
    i = Idea(title=LangString.create(u"An idea for another phase", 'en'),
             discussion=discussion,
             description=LangString.create("Some definition of an idea", 'en'))
    test_session.add(i)
    l_r_2 = IdeaLink(source=root_idea, target=i)
    test_session.add(l_r_2)
    test_session.flush()

    def fin():
        print "finalizer subidea_2"
        test_session.delete(l_r_2)
        test_session.delete(i)
        test_session.flush()
    request.addfinalizer(fin)
    return i