当前位置: 首页>>代码示例>>Python>>正文


Python wallposts.TextWallpostFactory类代码示例

本文整理汇总了Python中bluebottle.test.factory_models.wallposts.TextWallpostFactory的典型用法代码示例。如果您正苦于以下问题:Python TextWallpostFactory类的具体用法?Python TextWallpostFactory怎么用?Python TextWallpostFactory使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了TextWallpostFactory类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: setUp

    def setUp(self):
        super(WallpostReactionApiIntegrationTest, self).setUp()
        self.some_wallpost = TextWallpostFactory.create()
        self.another_wallpost = TextWallpostFactory.create()
        
        self.some_user = BlueBottleUserFactory.create(password='testing', first_name='someName', last_name='someLast')
        self.some_token = "JWT {0}".format(self.some_user.get_jwt_token())

        self.another_user = BlueBottleUserFactory.create(password='testing2', first_name='anotherName', last_name='anotherLast')
        self.another_token = "JWT {0}".format(self.another_user.get_jwt_token())

        self.wallpost_reaction_url = reverse('wallpost_reaction_list')
        self.wallpost_url = reverse('wallpost_list')
        self.text_wallpost_url = reverse('text_wallpost_list')
开发者ID:maykinmedia,项目名称:bluebottle,代码行数:14,代码来源:test_api.py

示例2: test_no_duplicate_follow

    def test_no_duplicate_follow(self):
        """ Test that no duplicate followers are created """
        self.assertEqual(Follow.objects.count(), 0)
        commenter = BlueBottleUserFactory.create()

        # Create a text Wallpost for our dummy project
        some_wallpost = TextWallpostFactory.create(content_object=self.project, author=self.another_user, text="test1", email_followers=False)
        self.assertEqual(Follow.objects.count(), 1) #Side-effectg of creating the wallpost

        another_wallpost = TextWallpostFactory.create(content_object=self.project, author=commenter, text="test2", email_followers=False)

        self.assertEqual(Follow.objects.count(), 2)
        # Make sure to inspect the second Follow object, this is the Follow object for the Reaction
        self.assertEqual(Follow.objects.all()[1].followed_object, self.project)
        self.assertEqual(Follow.objects.all()[1].user, commenter)
开发者ID:maykinmedia,项目名称:bluebottle,代码行数:15,代码来源:test_models.py

示例3: test_wallpost_no_mail

    def test_wallpost_no_mail(self):
        """ Test that followers don't get an email if email_followers is false. Email_followers boolean is false by default on wallpost model"""
        self.assertEqual(len(mail.outbox), 0)
        self.assertEqual(Follow.objects.count(), 0)
        commenter = BlueBottleUserFactory.create()
        commenter2 = BlueBottleUserFactory.create()

        # Create follower by creating a donation

        order = OrderFactory.create(user=self.another_user, status=StatusDefinition.CREATED)
        # Make sure to set Fundraiser to None. Otherwise, a fundraiser is created
        donation = DonationFactory(order=order, amount=35, project=self.project, fundraiser=None)

        # Create follower by creating a task owner

        task_owner1 = BlueBottleUserFactory.create()

        task = TaskFactory.create(
            author=task_owner1,
            project=self.project
        )

        # Verify we have two followers
        self.assertEqual(Follow.objects.count(), 2)

        # Create a text Wallpost for our dummy project
        some_wallpost = TextWallpostFactory.create(content_object=self.project, author=self.project.owner, text="test1", email_followers=False)

        self.assertEqual(Follow.objects.count(), 2)

        # Some other emails are sent, so we do not compare the mail count. Instead we look at the subject
        for email in mail.outbox:
            self.assertTrue("New wallpost on" not in email.subject)
开发者ID:pombredanne,项目名称:bluebottle,代码行数:33,代码来源:test_models.py

示例4: test_new_reaction_by_c_on_wallpost_b_on_project_by_a

    def test_new_reaction_by_c_on_wallpost_b_on_project_by_a(self):
        """
        Project by A + Wallpost by B + Reaction by C => Mail to (project owner) A + Mail to (reaction author) B
        """
        # Object by A
        # |
        # +-- Wallpost by B
        #     |
        #     +-- Reaction by A
        #     |
        #     +-- Reaction by B
        #     |
        #     +-- Reaction by C (+)

        w = TextWallpostFactory.create(content_object=self.project_1, author=self.user_b)
        Reaction.objects.create(text='Hello world', wallpost=w, author=self.user_a)
        Reaction.objects.create(text='Hello world', wallpost=w, author=self.user_b)

        # Empty outbox.
        mail.outbox = []
        Reaction.objects.create(text='Hello world', wallpost=w, author=self.user_c)

        # Mailbox should contain an email to project owner.
        self.assertEqual(len(mail.outbox), 2)
        m1 = mail.outbox[0]
        m2 = mail.outbox[1]

        self.assertListEqual([m2.to[0], m1.to[0]], [self.user_a.email, self.user_b.email])
开发者ID:maykinmedia,项目名称:bluebottle,代码行数:28,代码来源:test_api.py

示例5: test_not_follow_own_task

    def test_not_follow_own_task(self):
        """ Test that users do not follow their own task page """
        self.assertEqual(Follow.objects.count(), 0)

        some_wallpost = TextWallpostFactory.create(content_object=self.task, author=self.some_user, text="test1")

        self.assertEqual(Follow.objects.count(), 0)
开发者ID:pombredanne,项目名称:bluebottle,代码行数:7,代码来源:test_models.py

示例6: test_new_reaction_by_b_on_wallpost_a_on_project_by_a

    def test_new_reaction_by_b_on_wallpost_a_on_project_by_a(self):
        """
        Project by A + Wallpost by A + Reaction by B => Mail to (reaction author) A.
        """
        # Object by A
        # |
        # +-- Wallpost by A
        # |   |
        # |   +-- Reaction by A
        # |   |
        # |   +-- Reaction by B (+)

        w = TextWallpostFactory.create(content_object=self.project_1, author=self.user_a)

        Reaction.objects.create(text='Hello world', wallpost=w, author=self.user_a)

        # Empty outbox.
        mail.outbox = []
        Reaction.objects.create(text='Hello world', wallpost=w, author=self.user_b)

        # Mailbox should contain an email to author of reaction a.
        self.assertEqual(len(mail.outbox), 1)
        m = mail.outbox[0]

        self.assertEqual(m.to, [self.user_a.email])
开发者ID:maykinmedia,项目名称:bluebottle,代码行数:25,代码来源:test_api.py

示例7: test_no_mail_no_campaign_notifications

    def test_no_mail_no_campaign_notifications(self):
        """ Test that users who have campaign_notifications turned off don't get email """
        task_owner1 = BlueBottleUserFactory.create(campaign_notifications=False)

        task = TaskFactory.create(
            author=task_owner1,
            project=self.project
        )

        # Add extra project and owner that should not get any email
        project_owner = BlueBottleUserFactory.create(campaign_notifications=False)
        project2 = ProjectFactory(owner=project_owner, status=self.phase1)

        # Create a follower by donating
        donator1 = BlueBottleUserFactory.create(campaign_notifications=False)
        order = OrderFactory.create(user=donator1, status=StatusDefinition.CREATED)
        donation = DonationFactory(order=order, amount=35, project=self.project, fundraiser=None)

        # Create a follower by being a fundraiser for the project
        fundraiser_person = BlueBottleUserFactory.create(campaign_notifications=False)
        fundraiser = FundraiserFactory(project=self.project, owner=fundraiser_person)

        self.assertEqual(Follow.objects.count(), 3)

        # Project owner creates a wallpost and emails followers
        some_wallpost_2 = TextWallpostFactory.create(content_object=self.project, author=self.project.owner, text="test2", email_followers=True)

        mail_count = 0

        # People who should get an email: self.some_user, task_owner1, fundraiser_person, commenter, and donator1
        receivers = []
        for email in mail.outbox:
            if "New wallpost on" in email.subject:
                mail_count += 1
        self.assertEqual(mail_count, 0)
开发者ID:pombredanne,项目名称:bluebottle,代码行数:35,代码来源:test_models.py

示例8: test_wallpost_mail_project

    def test_wallpost_mail_project(self):
        """ Test that the relevant people get an email when the email_followers option is selected for a project """

        # On a project page, task owners, fundraisers, and people who donated,  get a mail.

        # Create a follower by being a task owner
        task_owner1 = BlueBottleUserFactory.create()

        task = TaskFactory.create(
            author=task_owner1,
            project=self.project
        )

        # Add extra project and owner that should not get any email
        project_owner = BlueBottleUserFactory.create()
        project2 = ProjectFactory(owner=project_owner, status=self.phase1)

        # iLeaving a wallpost should not create a follower
        commenter = BlueBottleUserFactory.create()
        some_wallpost = TextWallpostFactory.create(content_object=self.project, author=commenter, text="test1", email_followers=False)

        # Create a follower by donating
        donator1 = BlueBottleUserFactory.create()
        order = OrderFactory.create(user=donator1, status=StatusDefinition.CREATED)
        donation = DonationFactory(order=order, amount=35, project=self.project, fundraiser=None)

        # Create a follower by being a fundraiser for the project
        fundraiser_person = BlueBottleUserFactory.create()
        fundraiser = FundraiserFactory(project=self.project, owner=fundraiser_person)

        self.assertEqual(Follow.objects.count(), 3)

        # Project owner creates a wallpost and emails followers
        some_wallpost_2 = TextWallpostFactory.create(content_object=self.project, author=self.project.owner, text="test2", email_followers=True)

        mail_count = 0

        # People who should get an email: self.some_user, task_owner1, fundraiser_person, commenter, and donator1
        receivers = [task_owner1.email, fundraiser_person.email, donator1.email]
        for email in mail.outbox:
            if "New wallpost on" in email.subject:
                mail_count += 1
                self.assertTrue(email.to[0] in receivers)
                receivers.remove(email.to[0])
        self.assertEqual(mail_count, 3)
        self.assertEqual(receivers, [])
开发者ID:pombredanne,项目名称:bluebottle,代码行数:46,代码来源:test_models.py

示例9: test_create_follow_wallpost_task

    def test_create_follow_wallpost_task(self):
        """ Test that a Follow object is created when a user leaves a wallpost on a task """
        self.assertEqual(Follow.objects.count(), 0)

        # Create a text Wallpost for our dummy project
        some_wallpost = TextWallpostFactory.create(content_object=self.task, author=self.another_user)

        self.assertEqual(Follow.objects.count(), 1)
        self.assertEqual(Follow.objects.all()[0].followed_object, self.task)
        self.assertEqual(Follow.objects.all()[0].user, self.another_user)
开发者ID:maykinmedia,项目名称:bluebottle,代码行数:10,代码来源:test_models.py

示例10: test_create_follow_wallpost_project

    def test_create_follow_wallpost_project(self):
        """ Test that a Follow object is created between the user and the project when a wallpost is created """ 
        self.assertEqual(Follow.objects.count(), 0)

        # Create a text Wallpost for our dummy project
        some_wallpost = TextWallpostFactory.create(content_object=self.project, author=self.another_user)

        self.assertEqual(Follow.objects.count(), 1)
        self.assertEqual(Follow.objects.all()[0].followed_object, self.project)
        self.assertEqual(Follow.objects.all()[0].user, self.another_user)
开发者ID:maykinmedia,项目名称:bluebottle,代码行数:10,代码来源:test_models.py

示例11: test_new_wallpost_by_a_on_project_by_a

    def test_new_wallpost_by_a_on_project_by_a(self):
        """
        Project by A + Wallpost by A => No mails.
        """
        # Object by A
        # |
        # +-- Wallpost by A (+)

        post = TextWallpostFactory.create(content_object=self.project_1, author=self.user_a)

        # Mailbox should not contain anything.
        self.assertEqual(len(mail.outbox), 0)
开发者ID:maykinmedia,项目名称:bluebottle,代码行数:12,代码来源:test_api.py

示例12: test_wallpost_mail_fundraiser

    def test_wallpost_mail_fundraiser(self):
        """ Test that the relevant people get an email when the email_followers option is selected for a fundraiser """
        
        # On a Fundraiser page, people who posted to the wall and who donated get an email --> Followers
        self.assertEqual(Follow.objects.count(), 0)

        fundraiser_person = BlueBottleUserFactory.create()
        fundraiser = FundraiserFactory(project=self.project, owner=fundraiser_person)

        donator1 = BlueBottleUserFactory.create()
        order = OrderFactory.create(user=donator1, status=StatusDefinition.CREATED)
        donation = DonationFactory(order=order, amount=35, project=self.project, fundraiser=None)

        donator2 = BlueBottleUserFactory.create()
        order2 = OrderFactory.create(user=donator2, status=StatusDefinition.CREATED)
        donation = DonationFactory(order=order2, amount=35, project=self.project, fundraiser=None)

        commenter = BlueBottleUserFactory.create()
        commenter_post = TextWallpostFactory.create(content_object=fundraiser, author=commenter, text="test_commenter", email_followers=False)

        some_wallpost = TextWallpostFactory.create(content_object=fundraiser, author=fundraiser_person, text="test_fundraiser", email_followers=True)

        mail_count = 0

        self.assertEqual(Follow.objects.count(), 4)
        for follower in Follow.objects.all():
            follower.followed_object = self.project

        # When the fundraiser sends an email to the followers he doesn't get one himself
        receivers = [donator1.email, donator2.email, commenter.email]

        for email in mail.outbox:
            if "New wallpost on" in email.subject:
                mail_count += 1
                self.assertTrue(email.to[0] in receivers)
                receivers.remove(email.to[0])

        self.assertEqual(mail_count, 3)
        self.assertEqual(receivers, [])
开发者ID:maykinmedia,项目名称:bluebottle,代码行数:39,代码来源:test_models.py

示例13: test_new_wallpost_by_b_on_task_by_a

    def test_new_wallpost_by_b_on_task_by_a(self):
        """
        Task by A + Wallpost by B => Mail to (task owner) A
        """
        # Object by A
        # |
        # +-- Wallpost by B (+)

        post = TextWallpostFactory.create(content_object=self.task_1, author=self.user_b)

        # Mailbox should contain an email to project owner.
        self.assertEqual(len(mail.outbox), 1)
        m = mail.outbox[0]

        self.assertEqual(m.to, [self.user_a.email])
开发者ID:maykinmedia,项目名称:bluebottle,代码行数:15,代码来源:test_api.py

示例14: test_tags_generation

    def test_tags_generation(self, queue_mock):
        project = ProjectFactory.create()
        donation = DonationFactory.create(project=project)

        wallpost = TextWallpostFactory.create()
        expected_tags = {
            'type': 'wallpost',
            'tenant': u'test'
        }
        expected_fields = {
            'id': wallpost.id,
            'user_id': wallpost.author.id
        }

        args, kwargs = queue_mock.call_args
        self.assertEqual(kwargs['tags'], expected_tags)
        self.assertEqual(kwargs['fields'], expected_fields)
开发者ID:jfterpstra,项目名称:bluebottle,代码行数:17,代码来源:test_models.py

示例15: test_new_wallpost_by_b_on_project_by_a

    def test_new_wallpost_by_b_on_project_by_a(self):
        """
        Project by A + Wallpost by B => Mail to (project owner) A
        """
        # Object by A
        # |
        # +-- Wallpost by B (+)

        post = TextWallpostFactory.create(
            content_object=self.project_1, author=self.user_b)

        # Mailbox should contain an email to project owner.
        self.assertEqual(len(mail.outbox), 1)
        m = mail.outbox[0]

        self.assertEqual(m.to, [self.user_a.email])
        self.assertEqual(m.activated_language, self.user_a.primary_language)
开发者ID:pombredanne,项目名称:bluebottle,代码行数:17,代码来源:test_api.py


注:本文中的bluebottle.test.factory_models.wallposts.TextWallpostFactory类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。