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()
def test_adding_a_discussion_automatically_adds_participant_user_template_for_notifications( test_session): discussion = Discussion( topic=u"How great is Assembl's notification architecture?", slug="notification-architecture", subscribe_to_notifications_on_signup=True, creator=None, session=test_session) # Creation of a discussion includes automatic creation of a default user template for role participant on this discussion, which is meant to be used for default notification subscriptions assert len(discussion.user_templates) > 0 participant_role = test_session.query(Role).filter_by( name=R_PARTICIPANT).one() user_templates_for_role_participant = test_session.query( UserTemplate).filter_by(discussion=discussion, for_role=participant_role).all() assert len(user_templates_for_role_participant) > 0 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()
def test_cache_key(test_session): d = Discussion(topic=u"John Doe", slug="johndoe", subscribe_to_notifications_on_signup=False, creator=None, session=test_session) fn = test_cache_key result = d.generate_redis_key(fn) expected_result = "test_cache_key_" + str(d.id) + "_21_42" assert result(d, 21, 42) == expected_result 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()