Beispiel #1
0
def test_get_thematics_no_video(discussion, graphql_request, test_session):
    title = u"Comprendre les dynamiques et les enjeux"
    title = models.LangString.create(title, locale_code="fr")
    root_thematic = create_root_thematic(discussion, "survey")
    thematic = models.Thematic(discussion_id=discussion.id,
                               title=title,
                               identifier="survey")
    test_session.add(
        models.IdeaLink(source=root_thematic, target=thematic, order=1.0))
    test_session.commit()
    thematic_gid = to_global_id('Thematic', thematic.id)

    res = schema.execute(
        u'query { thematics(identifier:"survey") { id, title, description, numPosts, numContributors, questions { title }, video {title, descriptionTop, descriptionBottom, descriptionSide, htmlCode} } }',
        context_value=graphql_request)
    assert json.loads(json.dumps(res.data)) == {
        u'thematics': [{
            u'description': None,
            u'id': thematic_gid,
            u'numContributors': 0,
            u'numPosts': 0,
            u'questions': [],
            u'title': u'Comprendre les dynamiques et les enjeux',
            u'video': None
        }]
    }
Beispiel #2
0
def create_root_thematic(discussion, identifier):
    """Create the root thematic (hidden) for the given phase `identifier`
    on `discussion`.
    """
    short_title = u'Phase {}'.format(identifier)
    root_thematic = models.Thematic(
        discussion_id=discussion.id,
        title=langstring_from_input_entries(
            [{'locale_code': 'en', 'value': short_title}]),
        identifier=identifier,
        hidden=True)
    discussion.root_idea.children.append(root_thematic)
    return root_thematic
Beispiel #3
0
def test_get_thematics_with_video(discussion, graphql_request, test_session):
    title = u"Comprendre les dynamiques et les enjeux"
    title = models.LangString.create(title, locale_code="fr")
    video_title = models.LangString.create(
        u"Laurent Alexandre, chirurgien et expert en intelligence artificielle nous livre ses prédictions pour le 21e siècle.",
        locale_code="fr")
    video_desc_top = models.LangString.create(
        u"Personne ne veut d'un monde où on pourrait manipuler nos cerveaux et où les états pourraient les bidouiller",
        locale_code="fr")
    video_desc_bottom = models.LangString.create(u"Calise de tabarnak",
                                                 locale_code="fr")
    video_desc_side = models.LangString.create(u"Putain", locale_code="fr")
    root_thematic = create_root_thematic(discussion, "survey")
    thematic = models.Thematic(
        discussion_id=discussion.id,
        title=title,
        identifier="survey",
        video_title=video_title,
        video_description_top=video_desc_top,
        video_description_bottom=video_desc_bottom,
        video_description_side=video_desc_side,
        video_html_code=u"<object>....</object>",
    )
    test_session.add(
        models.IdeaLink(source=root_thematic, target=thematic, order=1.0))
    test_session.commit()
    thematic_gid = to_global_id('Thematic', thematic.id)

    res = schema.execute(
        u'query { thematics(identifier:"survey") { id, title, description, numPosts, numContributors, questions { title }, video {title, descriptionTop, descriptionBottom, descriptionSide, htmlCode} } }',
        context_value=graphql_request)
    assert json.loads(json.dumps(res.data)) == {
        u'thematics': [{
            u'description': None,
            u'id': thematic_gid,
            u'numContributors': 0,
            u'numPosts': 0,
            u'questions': [],
            u'title': u'Comprendre les dynamiques et les enjeux',
            u'video': {
                u'title':
                u"Laurent Alexandre, chirurgien et expert en intelligence artificielle nous livre ses prédictions pour le 21e siècle.",
                u'descriptionTop':
                u"Personne ne veut d'un monde où on pourrait manipuler nos cerveaux et où les états pourraient les bidouiller",
                u'descriptionBottom': u"Calise de tabarnak",
                u'descriptionSide': u"Putain",
                u'htmlCode': u"<object>....</object>",
            }
        }]
    }
Beispiel #4
0
def create_root_thematic(phase):
    """Create the root thematic (hidden) for the given phase `phase`.
    """
    title = u'Phase {}'.format(phase.identifier)
    root_thematic = models.Thematic(discussion_id=phase.discussion.id,
                                    title=langstring_from_input_entries([{
                                        'locale_code':
                                        'en',
                                        'value':
                                        title
                                    }]),
                                    hidden=True)
    phase.discussion.root_idea.children.append(root_thematic)
    phase.is_thematics_table = True
    phase.root_idea = root_thematic
    return root_thematic