Example #1
0
    def test_generate_vote_url(self, mk_user, conversation_db):
        request = mock.Mock()
        request.META = {
            "wsgi.url_scheme": "http",
            "HTTP_HOST": "ejplatform.local"
        }
        request.POST = {"custom-domain": "http://ejplatform.local"}
        user = mk_user(email="*****@*****.**")
        comment_1 = conversation_db.create_comment(user,
                                                   "comment 1",
                                                   status="approved",
                                                   check_limits=False)
        form_data = {"template_type": "mautic"}
        generator = TemplateGenerator(conversation_db, request, form_data)
        vote_url = generator._get_voting_url()

        expected_url = ("http://ejplatform.local/conversations/{}/{}"
                        "?comment_id={}&action=vote&origin=campaign".format(
                            conversation_db.id, conversation_db.slug,
                            comment_1.id))

        assert vote_url == expected_url
Example #2
0
    def test_generate_vote_url_with_board(self, mk_board, mk_conversation,
                                          mk_user):
        request = mock.Mock()
        request.META = {
            "wsgi.url_scheme": "http",
            "HTTP_HOST": "ejplatform.local"
        }
        request.POST = {"custom-domain": "http://ejplatform.local"}
        board = mk_board()
        user = mk_user(email="*****@*****.**")
        conversation = mk_conversation(author=user)
        comment_1 = conversation.create_comment(user, "comment 1", "approved")
        board.add_conversation(conversation)
        form_data = {"template_type": "mautic"}
        generator = TemplateGenerator(conversation, request, form_data)
        vote_url = generator._get_voting_url()

        expected_url = ("http://ejplatform.local/{}/conversations/{}/{}"
                        "?comment_id={}&action=vote&origin=campaign".format(
                            board.slug, conversation.id, conversation.slug,
                            comment_1.id))

        assert vote_url == expected_url