Example #1
0
    def setUp(self):
        super(WallpostReactionApiIntegrationTest, self).setUp()

        self.manager = BlueBottleUserFactory.create()
        self.manager_token = "JWT {0}".format(
            self.manager.get_jwt_token())
        self.event = EventFactory.create(owner=self.manager)
        self.some_wallpost = TextWallpostFactory.create(content_object=self.event)
        self.another_wallpost = TextWallpostFactory.create()

        self.some_user = BlueBottleUserFactory.create(
            password='******', first_name='someName', last_name='someLast')
        self.some_token = "JWT {0}".format(self.some_user.get_jwt_token())

        self.another_user = BlueBottleUserFactory.create(
            password='******', 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')

        response = self.client.post(
            self.wallpost_reaction_url,
            {
                'text': 'Dit is een test',
                'wallpost': self.some_wallpost.id
            },
            token=self.some_token
        )
        self.reaction_detail_url = reverse('wallpost_reaction_detail', kwargs={'pk': response.data['id']})
    def test_auth_existing_succes(self):
        with self.settings(TOKEN_AUTH=TOKEN_AUTH_SETTINGS):
            # Create user with remote_id with caps
            BlueBottleUserFactory.create(
                remote_id='492882615ACF31C8096B627245D76AE53036C090',
                email='*****@*****.**',
                username='******')

            filename = os.path.join(os.path.dirname(__file__),
                                    'data/valid_response.xml.base64')
            with open(filename) as response_file:
                response = response_file.read()

            request = self._request(
                'post',
                '/sso/auth',
                session={
                    'saml_request_id':
                    '_6273d77b8cde0c333ec79d22a9fa0003b9fe2d75cb'
                },
                HTTP_HOST='www.stuff.com',
                data={'SAMLResponse': response})
            auth_backend = SAMLAuthentication(request)

            # Login should stil work.
            user, created = auth_backend.authenticate()
            self.assertFalse(created)
            self.assertEqual(user.username, 'smartin')
            self.assertEqual(user.email, '*****@*****.**')
            self.assertEqual(user.remote_id,
                             '492882615acf31c8096b627245d76ae53036c090')
Example #3
0
    def setUp(self):
        super(OrganizationsEndpointTestCase, self).setUp()
        self.client = JSONAPITestClient()

        self.user_1 = BlueBottleUserFactory.create()
        self.user_1_token = "JWT {0}".format(self.user_1.get_jwt_token())

        self.user_2 = BlueBottleUserFactory.create()

        self.organization_1 = OrganizationFactory.create(
            owner=self.user_1,
            name='Evil Knight'
        )
        self.organization_2 = OrganizationFactory.create(
            owner=self.user_1,
            name='Evel Knievel'
        )
        self.organization_3 = OrganizationFactory.create(
            owner=self.user_1,
            name='Hanson Kids'
        )
        self.organization_4 = OrganizationFactory.create(
            owner=self.user_1,
            name='Knight Rider'
        )
        self.organization_5 = OrganizationFactory.create(
            owner=self.user_2,
            name='Kids Club'
        )
Example #4
0
    def test_api_manage_organizations_update_other_user(self):
        """
        Tests POSTing new data to the endpoint.
        """
        response = self.client.post(
            reverse('organization_list'),
            json.dumps(self.post_data),
            user=self.user_1)
        self.assertEqual(response.status_code, status.HTTP_201_CREATED)

        # Update description
        org_id = response.data['id']
        self.post_data['data']['id'] = org_id
        self.post_data['data']['attributes']['description'] = 'Bla bla'
        url = reverse('organization_detail', kwargs={'pk': org_id})

        response = self.client.put(
            url,
            json.dumps(self.post_data),
            user=BlueBottleUserFactory.create())

        self.assertEqual(response.status_code, status.HTTP_403_FORBIDDEN)

        response = self.client.patch(
            url,
            json.dumps(self.post_data),
            user=BlueBottleUserFactory.create())

        self.assertEqual(response.status_code, status.HTTP_403_FORBIDDEN)
Example #5
0
    def test_reaction(self):
        reaction_user = BlueBottleUserFactory.create()
        wallpost_user = BlueBottleUserFactory.create()
        wallpost = MediaWallpostFactory.create(
            content_object=self.activity, author=wallpost_user, email_followers=True
        )

        mail.outbox = []

        ReactionFactory.create(
            wallpost=wallpost, author=reaction_user
        )

        self.assertEqual(len(mail.outbox), 2)

        wallpost_owner_mail = mail.outbox[0]

        self.assertEqual(
            wallpost_owner_mail.subject,
            "You have a new post on '{}'".format(self.activity.title)
        )
        owner_mail = mail.outbox[1]

        self.assertEqual(
            owner_mail.subject,
            "You have a new post on '{}'".format(self.activity.title)
        )
Example #6
0
    def setUp(self):
        super(TokenLoginApiTest, self).setUp()

        self.user = BlueBottleUserFactory.create()
        self.other_user = BlueBottleUserFactory.create()

        self.token_login_url = reverse('token-login')
Example #7
0
    def setUp(self):
        super(TaskApiIntegrationTests, self).setUp()

        self.init_projects()

        campaign = ProjectPhase.objects.get(slug='campaign')

        self.some_user = BlueBottleUserFactory.create()
        self.some_token = "JWT {0}".format(self.some_user.get_jwt_token())
        self.some_project = ProjectFactory.create(owner=self.some_user,
                                                  status=campaign)

        self.another_user = BlueBottleUserFactory.create()
        self.another_token = "JWT {0}".format(
            self.another_user.get_jwt_token())
        self.another_project = ProjectFactory.create(owner=self.another_user)

        self.task = TaskFactory.create(project=self.some_project)

        self.skill1 = SkillFactory.create()
        self.skill2 = SkillFactory.create()
        self.skill3 = SkillFactory.create()
        self.skill4 = SkillFactory.create()

        self.task_url = reverse('task-list')
        self.task_preview_url = reverse('task_preview_list')
        self.task_members_url = reverse('task-member-list')
        self.task_detail_url = reverse('task_detail', args=(self.task.pk, ))
Example #8
0
    def setUp(self):
        super(UserApiIntegrationTest, self).setUp()

        self.user_1 = BlueBottleUserFactory.create()
        self.user_1_token = "JWT {0}".format(self.user_1.get_jwt_token())

        self.user_2 = BlueBottleUserFactory.create()
        self.user_2_token = "JWT {0}".format(self.user_2.get_jwt_token())

        # User with partner organization
        self.user_with_partner_organization = BlueBottleUserFactory.create()
        self.user_with_partner_organization_token = "JWT {0}".format(self.user_with_partner_organization.get_jwt_token()
                                                                     )
        self.organization = OrganizationFactory.create(name='Partner Organization',
                                                       slug='partner-organization',
                                                       website='http://partnerorg.nl')
        self.organization_contact = OrganizationContactFactory.create(organization=self.organization)
        self.organization_member = OrganizationMemberFactory.create(organization=self.organization)
        self.user_with_partner_organization.partner_organization = self.organization
        self.user_with_partner_organization.save()

        self.current_user_api_url = reverse('user-current')
        self.manage_profile_url = reverse('manage-profile', args=(self.user_1.pk, ))
        self.user_create_api_url = reverse('user-user-create')
        self.user_password_reset_api_url = reverse('password-reset')
Example #9
0
    def test_filter_on_task_wallpost_list(self):
        """
        Tests that project initiator can post and view task wallposts
        """
        self.project.task_manager = BlueBottleUserFactory.create()
        self.project.promoter = BlueBottleUserFactory.create()
        self.project.save()

        authenticated = Group.objects.get(name='Authenticated')

        authenticated.permissions.remove(
            Permission.objects.get(codename='api_read_wallpost'))
        authenticated.permissions.add(
            Permission.objects.get(codename='api_read_own_wallpost'))

        MediaWallpostFactory.create_batch(3, content_object=self.task)

        response = self.client.get(self.wallpost_url, {
            'parent_id': str(self.task.id),
            'parent_type': 'task'
        },
                                   token=self.owner_token)

        self.assertEqual(response.status_code, status.HTTP_200_OK)
        self.assertEqual(response.data['count'], 3)
Example #10
0
    def setUp(self):
        super(TestDonationRewardStock, self).setUp()

        self.init_projects()

        self.user = BlueBottleUserFactory.create()
        self.user_token = "JWT {0}".format(self.user.get_jwt_token())

        self.project = ProjectFactory.create(amount_asked=5000)
        self.project.set_status('campaign')

        self.reward = RewardFactory(project=self.project, limit=1)

        self.donations_url = reverse('manage-donation-list')
        self.reward_url = reverse('reward-detail', args=(self.reward.pk, ))

        self.donor = BlueBottleUserFactory.create()
        self.donor_token = "JWT {0}".format(self.donor.get_jwt_token())

        self.order = OrderFactory.create(user=self.donor)

        self.donation_data = {
            'order': self.order.id,
            'reward': self.reward.id,
            'amount': {
                'amount': self.reward.amount.amount,
                'currency': str(self.reward.amount.currency)
            },
            'project': self.project.slug,
        }
    def test_create_user_language_not_set(self):
        mail.outbox = []
        BlueBottleUserFactory.create(first_name='Bob',
                                     email='*****@*****.**',
                                     primary_language='bg')
        welcome_email = mail.outbox[0]
        self.assertEqual(welcome_email.to, ['*****@*****.**'])
        # BG translations not set so we should receive default language translation
        self.assertEqual(welcome_email.subject,
                         u'You have been assimilated to Test')
        self.assertTrue(u'You are no longer Bob.' in welcome_email.body)
        self.assertTrue(u'We are borg' in welcome_email.body)

        # Now set BG translations
        self.message.set_current_language('bg')
        self.message.subject = u'Асимилирани сте към {site_name}'
        self.message.body_html = u'Ти вече не си {first_name}.<br/><h1>Ние сме Борг</h1>'
        self.message.body_txt = u'Ти вече не си {first_name}.\nНие сме Борг'
        self.message.save()
        mail.outbox = []

        BlueBottleUserFactory.create(first_name=u'Бубка',
                                     email='*****@*****.**',
                                     primary_language='bg')
        welcome_email = mail.outbox[0]
        self.assertEqual(welcome_email.to, ['*****@*****.**'])
        self.assertEqual(welcome_email.subject, u'Асимилирани сте към Test')
        self.assertTrue(u'Ти вече не си Бубка.' in welcome_email.body)
        self.assertTrue(u'Ние сме Борг' in welcome_email.body)
    def setUp(self):
        self.init_projects()
        self.phase_campaign = ProjectPhase.objects.get(slug='campaign')
        self.country = CountryFactory()

        self.projects = []

        for amount in [500, 100, 1500, 300, 200]:
            self.projects.append(OnePercentProjectFactory.create(amount_asked=amount, status=self.phase_campaign))

        # Some donations to get the popularity going
        # Top 3 after this should be projects 4, 3, 0
        order = OrderFactory()
        DonationFactory(order=order, project=self.projects[3], amount=10)
        DonationFactory(order=order, project=self.projects[3], amount=100)
        DonationFactory(order=order, project=self.projects[3], amount=20)

        DonationFactory(order=order, project=self.projects[4], amount=10)
        DonationFactory(order=order, project=self.projects[4], amount=70)

        DonationFactory(order=order, project=self.projects[0], amount=10)

        order.locked()
        order.succeeded()

        # Since we force the transitions update_amounts isn't triggered by signal, so we run it manually here.
        for project in self.projects:
            project.update_amounts()

        self.user1 = BlueBottleUserFactory.create()
        self.user2 = BlueBottleUserFactory.create()
Example #13
0
    def setUp(self):
        super(EventTransitionTestCase, self).setUp()
        self.client = JSONAPITestClient()
        self.owner = BlueBottleUserFactory()
        self.manager = BlueBottleUserFactory()
        self.other_user = BlueBottleUserFactory()

        self.initiative = InitiativeFactory.create(
            activity_manager=self.manager)
        self.initiative.states.submit()
        self.initiative.states.approve(save=True)
        self.event = EventFactory.create(owner=self.owner,
                                         initiative=self.initiative)

        self.event_url = reverse('event-detail', args=(self.event.id, ))
        self.transition_url = reverse('activity-transition-list')

        self.review_data = {
            'data': {
                'type': 'activities/transitions',
                'attributes': {
                    'transition': 'delete',
                },
                'relationships': {
                    'resource': {
                        'data': {
                            'type': 'activities/events',
                            'id': self.event.pk
                        }
                    }
                }
            }
        }
Example #14
0
    def setUp(self):
        settings.SESSION_ENGINE = 'django.contrib.sessions.backends.file'
        engine = import_module(settings.SESSION_ENGINE)
        store = engine.SessionStore()
        store.save()
        self.session = store
        self.client.cookies[settings.SESSION_COOKIE_NAME] = store.session_key

        self.addCleanup(self._clear_session)

        self.user1 = BlueBottleUserFactory.create()
        self.user1_token = "JWT {0}".format(self.user1.get_jwt_token())

        self.init_projects()
        self.project1 = ProjectFactory.create(amount_asked=5000)
        self.project1.set_status('campaign')

        self.project2 = ProjectFactory.create(amount_asked=3750)
        self.project2.set_status('campaign')

        self.manage_order_list_url = reverse('manage-order-list')
        self.manage_donation_list_url = reverse('manage-donation-list')

        self.user = BlueBottleUserFactory.create()
        self.user_token = "JWT {0}".format(self.user.get_jwt_token())

        self.user2 = BlueBottleUserFactory.create()
        self.user2_token = "JWT {0}".format(self.user2.get_jwt_token())

        self.project = ProjectFactory.create()
        self.order = OrderFactory.create(user=self.user)
Example #15
0
    def setUp(self):
        super(DonationApiTestCase, self).setUp()

        self.create_session()

        self.user1 = BlueBottleUserFactory.create()
        self.user1_token = "JWT {0}".format(self.user1.get_jwt_token())

        self.init_projects()

        self.project1 = ProjectFactory.create(amount_asked=5000)
        self.project1.set_status('campaign')

        self.project2 = ProjectFactory.create(amount_asked=3750)
        self.project2.set_status('campaign')

        self.manage_order_list_url = reverse('manage-order-list')
        self.manage_donation_list_url = reverse('manage-donation-list')

        self.user = BlueBottleUserFactory.create()
        self.user_token = "JWT {0}".format(self.user.get_jwt_token())

        self.user2 = BlueBottleUserFactory.create(is_co_financer=True)
        self.user2_token = "JWT {0}".format(self.user2.get_jwt_token())

        self.project = ProjectFactory.create()
        self.order = OrderFactory.create(user=self.user)

        self.dollar_project = ProjectFactory.create(currencies=['USD'])
        self.multi_project = ProjectFactory.create(currencies=['EUR', 'USD', 'NGN'])
Example #16
0
    def test_results_supporters(self):
        yesterday = now() - timedelta(days=1)
        co_financer = BlueBottleUserFactory(is_co_financer=True)
        user = BlueBottleUserFactory(is_co_financer=False)
        funding = FundingFactory(status='open', owner=user)

        DonationFactory.create(activity=funding,
                               status='succeeded',
                               transition_date=yesterday,
                               user=user,
                               amount=Money(50, 'EUR'))
        DonationFactory.create(activity=funding,
                               status='succeeded',
                               transition_date=yesterday,
                               user=co_financer,
                               amount=Money(50, 'EUR'))
        DonationFactory.create(activity=funding,
                               status='succeeded',
                               transition_date=yesterday,
                               user=co_financer,
                               amount=Money(50, 'EUR'))

        SupporterTotalContent.objects.create_for_placeholder(self.placeholder)

        response = self.client.get(self.url)
        self.assertEquals(response.status_code, status.HTTP_200_OK)

        block = response.data['blocks'][0]
        self.assertEqual(block['type'], 'supporter_total')
        self.assertEqual(len(block['co_financers']), 1)
        self.assertEqual(block['co_financers'][0]['total']['amount'], 100)
Example #17
0
    def test_supporters(self):
        """ Test return value of supporters, users who did a succesful donation """

        project = ProjectFactory.create(amount_asked=1000)
        user1 = BlueBottleUserFactory.create()
        user2 = BlueBottleUserFactory.create()
        user3 = BlueBottleUserFactory.create()

        order1 = OrderFactory.create(user=user1)
        donation1 = DonationFactory(order=order1, amount=20)
        order1.locked()
        order1.failed()

        order2 = OrderFactory.create(user=user2)
        donation2 = DonationFactory(order=order2, amount=25)
        order2.locked()
        order2.succeeded()

        order3 = OrderFactory.create(user=user2)
        donation3 = DonationFactory(order=order3, amount=30)
        order3.locked()
        order3.succeeded()

        order4 = OrderFactory.create(user=user3)
        donation4 = DonationFactory(order=order4, amount=35)
        order4.locked()
        order4.succeeded()

        # User two should be counted once, and user 3 should be counted
        self.assertEqual(self.metrics.calculate_supporters(), 2)
Example #18
0
    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)
Example #19
0
    def setUp(self):
        super(TaskEmailTests, self).setUp()
        self.init_projects()

        self.some_user = BlueBottleUserFactory.create(first_name='King',
                                                      primary_language='fr')
        self.another_user = BlueBottleUserFactory.create(first_name='Kong',
                                                         primary_language='nl')

        self.yet_another_user = BlueBottleUserFactory.create(first_name='Gong',
                                                             primary_language='en')

        self.some_project = ProjectFactory.create()
        self.some_project.owner.primary_language = 'en'

        self.task = TaskFactory.create(
            status=Task.TaskStatuses.in_progress,
            author=self.some_project.owner,
        )

        self.taskmember1 = TaskMemberFactory.create(
            member=self.some_user,
            status=TaskMember.TaskMemberStatuses.applied,
            task=self.task

        )
        self.taskmember2 = TaskMemberFactory.create(
            member=self.another_user,
            status=TaskMember.TaskMemberStatuses.applied,
            task=self.task
        )

        self.task.save()
Example #20
0
    def setUp(self):
        super(StatisticsDateTest, self).setUp()

        user = BlueBottleUserFactory.create()
        other_user = BlueBottleUserFactory.create()

        for diff in (10, 5, 1):
            initiative = InitiativeFactory.create(owner=user)
            past_date = timezone.now() - datetime.timedelta(days=diff)
            initiative.created = past_date
            initiative.save()
            initiative.states.submit()
            initiative.states.approve(save=True)

            event = EventFactory(
                start=past_date,
                initiative=initiative,
                duration=1,
                transition_date=past_date,
                status='succeeded',
                owner=BlueBottleUserFactory.create(),
            )

            ParticipantFactory.create(activity=event,
                                      status='succeeded',
                                      time_spent=1,
                                      user=other_user)
Example #21
0
    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)
Example #22
0
    def setUp(self):
        super(TestPayoutApi, self).setUp()
        self.init_projects()

        self.user1 = BlueBottleUserFactory.create()
        self.user1_token = "JWT {0}".format(self.user1.get_jwt_token())

        self.user2 = BlueBottleUserFactory.create()
        self.user2_token = "JWT {0}".format(self.user2.get_jwt_token())
        financial = Group.objects.get(name='Financial')
        financial.user_set.add(self.user2)

        self.project = ProjectFactory.create(
            status=ProjectPhase.objects.get(slug='campaign'),
            campaign_ended=now(),
            amount_asked=100)
        donation = DonationFactory.create(
            project=self.project,
            amount=100
        )
        donation.save()
        donation.order.locked()
        donation.order.save()
        donation.order.success()
        donation.order.save()
        self.project.save()
        self.project.deadline_reached()

        self.payout_url = reverse('project-payout-detail', kwargs={'pk': self.project.id})
Example #23
0
    def setUp(self):
        super(TestPayoutApi, self).setUp()
        self.client = JSONAPITestClient()
        self.plain_user = BlueBottleUserFactory.create()
        self.plain_token = Token.objects.create(user=self.plain_user)
        self.finance_user = BlueBottleUserFactory.create()
        self.token = Token.objects.create(user=self.finance_user)
        financial = Group.objects.get(name='Financial')
        financial.user_set.add(self.finance_user)

        yesterday = now() - timedelta(days=1)
        payout_account = StripePayoutAccountFactory.create(status='verified')
        self.bank_account = ExternalAccountFactory.create(
            connect_account=payout_account)

        self.funding = FundingFactory.create(deadline=yesterday, status='open')

        self.funding.bank_account = self.bank_account
        self.funding.save()

        donations = DonationFactory.create_batch(4,
                                                 activity=self.funding,
                                                 amount=Money(35, 'EUR'),
                                                 status='succeeded')
        for donation in donations:
            StripePaymentFactory.create(status='succeeded', donation=donation)

        self.funding.states.succeed(save=True)
        self.payout = self.funding.payouts.first()
        self.payout_url = reverse('payout-details',
                                  kwargs={'pk': self.payout.id})
Example #24
0
    def setUp(self):
        super(TaskApiTestcase, self).setUp()

        self.init_projects()

        self.some_user = BlueBottleUserFactory.create()
        self.some_token = "JWT {0}".format(self.some_user.get_jwt_token())

        campaign_status = ProjectPhase.objects.get(slug='campaign')
        self.some_project = ProjectFactory.create(owner=self.some_user,
                                                  status=campaign_status)

        self.task1 = TaskFactory.create(status=Task.TaskStatuses.open,
                                        author=self.some_project.owner,
                                        project=self.some_project,
                                        people_needed=2)

        self.another_user = BlueBottleUserFactory.create()
        self.another_token = "JWT {0}".format(
            self.another_user.get_jwt_token())

        self.yet_another_user = BlueBottleUserFactory.create()
        self.yet_another_token = "JWT {0}".format(
            self.yet_another_user.get_jwt_token())

        self.previews_url = reverse('project_preview_list')
        self.task_preview_url = reverse('task_preview_list')
        self.tasks_url = reverse('task-list')
        self.task_member_url = reverse('task-member-list')
Example #25
0
    def setUp(self):
        super(TestPledgeMails, self).setUp()

        self.init_projects()

        self.user = BlueBottleUserFactory(can_pledge=True)
        self.project_owner = BlueBottleUserFactory(username='******',
                                                   email='*****@*****.**',
                                                   password='******')
        self.organization = OrganizationFactory.create(name='test_org',
                                                       slug='test_org')

        self.project = ProjectFactory(owner=self.project_owner,
                                      organization=self.organization,
                                      title='Project 1',
                                      amount_needed=1111,
                                      amount_asked=1111)
        self.order = OrderFactory.create(user=self.user)
        self.donation = DonationFactory(amount=60,
                                        order=self.order,
                                        project=self.project,
                                        fundraiser=None)

        self.order_payment = OrderPaymentFactory.create(
            order=self.order, payment_method='pledgeStandard')
        self.order_payment.pledged()
        self.order_payment.save()
Example #26
0
    def setUp(self):
        super(DonationApiTestCase, self).setUp()

        self.create_session()

        self.user1 = BlueBottleUserFactory.create()
        self.user1_token = "JWT {0}".format(self.user1.get_jwt_token())

        self.init_projects()

        self.project1 = ProjectFactory.create(amount_asked=5000)
        self.project1.set_status('campaign')

        self.project2 = ProjectFactory.create(amount_asked=3750)
        self.project2.set_status('campaign')

        self.manage_order_list_url = reverse('order-manage-list')
        self.manage_donation_list_url = reverse('manage-donation-list')

        self.user = BlueBottleUserFactory.create()
        self.user_token = "JWT {0}".format(self.user.get_jwt_token())

        self.user2 = BlueBottleUserFactory.create(is_co_financer=True)
        self.user2_token = "JWT {0}".format(self.user2.get_jwt_token())

        self.project = ProjectFactory.create()
        self.order = OrderFactory.create(user=self.user)

        self.dollar_project = ProjectFactory.create(currencies=['USD'])
        self.multi_project = ProjectFactory.create(
            currencies=['EUR', 'USD', 'NGN'])
Example #27
0
    def setUp(self):
        super(TaskApiTestcase, self).setUp()

        self.init_projects()

        self.some_user = BlueBottleUserFactory.create()
        self.some_token = "JWT {0}".format(self.some_user.get_jwt_token())

        campaign_status = ProjectPhase.objects.get(slug='campaign')
        self.some_project = ProjectFactory.create(owner=self.some_user,
                                                  status=campaign_status)

        self.task1 = TaskFactory.create(
            status=Task.TaskStatuses.open,
            author=self.some_project.owner,
            project=self.some_project,
            people_needed=2
        )

        self.another_user = BlueBottleUserFactory.create()
        self.another_token = "JWT {0}".format(self.another_user.get_jwt_token())

        self.yet_another_user = BlueBottleUserFactory.create()
        self.yet_another_token = "JWT {0}".format(
            self.yet_another_user.get_jwt_token())

        self.previews_url = reverse('project_preview_list')
        self.task_preview_url = reverse('task_preview_list')
        self.tasks_url = reverse('task_list')
        self.task_member_url = reverse('task_member_list')
Example #28
0
    def test_total_raised(self):
        """ Calculate the total amount raised by successful donations """
        project1 = ProjectFactory.create(amount_asked=1000)
        project2 = ProjectFactory.create(amount_asked=1000)

        user1 = BlueBottleUserFactory.create()
        user2 = BlueBottleUserFactory.create()
        user3 = BlueBottleUserFactory.create()

        order1 = OrderFactory.create(user=user1)
        donation1 = DonationFactory(order=order1, amount=10, project=project1)
        order1.locked()
        order1.failed()

        order2 = OrderFactory.create(user=user2)
        donation2 = DonationFactory(order=order2, amount=10, project=project1)
        order2.locked()
        order2.succeeded()

        order3 = OrderFactory.create(user=user2)
        donation3 = DonationFactory(order=order3, amount=10, project=project2)
        order3.locked()
        order3.succeeded()

        order4 = OrderFactory.create(user=user3)
        donation4 = DonationFactory(order=order4, amount=10, project=project1)
        order4.locked()
        order4.succeeded()

        # order2, order3, order4 should be counted
        self.assertEqual(self.metrics.calculate_total_raised(), 30)
Example #29
0
    def setUp(self):
        super(ManageProjectListRoleTests, self).setUp()

        self.init_projects()

        campaign = ProjectPhase.objects.get(slug='campaign')

        self.other_user = BlueBottleUserFactory.create()
        self.other_token = "JWT {0}".format(self.other_user.get_jwt_token())

        self.some_user = BlueBottleUserFactory.create()
        self.some_token = "JWT {0}".format(self.some_user.get_jwt_token())

        self.another_user = BlueBottleUserFactory.create()
        self.another_token = "JWT {0}".format(
            self.another_user.get_jwt_token())

        self.project1 = ProjectFactory.create(owner=self.some_user,
                                              status=campaign)

        self.project2 = ProjectFactory.create(owner=self.some_user,
                                              task_manager=self.other_user,
                                              status=campaign)

        self.project3 = ProjectFactory.create(owner=self.another_user,
                                              task_manager=self.another_user,
                                              promoter=self.other_user,
                                              status=campaign)
Example #30
0
    def setUp(self):
        super(MonthlyDonationApiTest, self).setUp()
        self.init_projects()

        self.phase_campaign = ProjectPhase.objects.get(slug='campaign')
        self.country = CountryFactory()

        self.some_project = ProjectFactory.create(amount_asked=500,
                                                  status=self.phase_campaign)
        self.another_project = ProjectFactory.create(
            amount_asked=750, status=self.phase_campaign)

        self.some_user = BlueBottleUserFactory.create()
        self.some_user_token = "JWT {0}".format(self.some_user.get_jwt_token())
        self.another_user = BlueBottleUserFactory.create()
        self.another_user_token = "JWT {0}".format(
            self.another_user.get_jwt_token())

        self.monthly_donation_url = reverse('monthly-donation-list')
        self.monthly_donation_project_url = reverse(
            'monthly-donation-project-list')

        self.monthly_profile = {
            'iban': 'NL13TEST0123456789',
            'bic': 'TESTNL2A',
            'name': 'Nijntje het Konijntje',
            'city': 'Amsterdam',
            'country': self.country.id,
            'amount': 50.00
        }
Example #31
0
    def setUp(self):
        super(MonthlyDonationApiTest, self).setUp()
        self.init_projects()

        self.phase_campaign = ProjectPhase.objects.get(slug='campaign')
        self.country = CountryFactory()

        self.some_project = ProjectFactory.create(amount_asked=500,
                                                  status=self.phase_campaign)
        self.another_project = ProjectFactory.create(amount_asked=750,
                                                     status=self.phase_campaign)

        self.some_user = BlueBottleUserFactory.create()
        self.some_user_token = "JWT {0}".format(self.some_user.get_jwt_token())
        self.another_user = BlueBottleUserFactory.create()
        self.another_user_token = "JWT {0}".format(
            self.another_user.get_jwt_token())

        self.monthly_donation_url = reverse('monthly-donation-list')
        self.monthly_donation_project_url = reverse('monthly-donation-project-list')

        self.monthly_profile = {'iban': 'NL13TEST0123456789',
                                'bic': 'TESTNL2A',
                                'name': 'Nijntje het Konijntje',
                                'city': 'Amsterdam',
                                'country': self.country.id,
                                'amount': 50.00}
    def setUp(self):

        self.init_projects()
        self.phase_campaign = ProjectPhase.objects.get(slug='campaign')

        self._projects = []
        self.projects = dict([(slugify(title), title) for title in [
            u'Women first', u'Mobile payments for everyone!', u'Schools for children'
        ]])

        for slug, title in self.projects.items():
            project = OnePercentProjectFactory.create(title=title, slug=slug, amount_asked=500)
            self._projects.append(project)

            project.amount_donated = 500  # EUR 5.00
            project.status = self.phase_campaign
            project.save()

        self.some_user = BlueBottleUserFactory.create()
        self.another_user = BlueBottleUserFactory.create()

        self.donate_details = {'firstname': 'Pietje',
                               'lastname': 'Paulusma',
                               'email': '*****@*****.**',
                               'address': 'Herengracht 416',
                               'postcode': '1017BZ',
                               'city': 'Amsterdam',
                               'country': 'NL'}
Example #33
0
    def setUp(self):
        super(TaskEmailTests, self).setUp()
        self.some_user = BlueBottleUserFactory.create(first_name='King')
        self.another_user = BlueBottleUserFactory.create(first_name='Kong')

        self.some_project = ProjectFactory.create()

        self.task = TaskFactory.create(
            status=TASK_MODEL.TaskStatuses.in_progress,
            author=self.some_project.owner,
        )

        self.taskmember1 = TaskMemberFactory.create(
            member=self.some_user,
            status=TASKS_MEMBER_MODEL.TaskMemberStatuses.applied,
            task=self.task

        )
        self.taskmember2 = TaskMemberFactory.create(
            member=self.another_user,
            status=TASKS_MEMBER_MODEL.TaskMemberStatuses.applied,
            task=self.task
        )

        self.task.save()
Example #34
0
    def test_pledge_payment_methods(self):
        user = BlueBottleUserFactory.create(can_pledge=False)
        staff_user = BlueBottleUserFactory.create(can_pledge=True)

        methods = get_payment_methods(country="nl", user=user)
        self.assertEqual(len(methods), 1)

        methods = get_payment_methods(country="nl", user=staff_user)
        self.assertEqual(len(methods), 2)
Example #35
0
 def setUp(self):
     super(TestPayoutMethodApi, self).setUp()
     self.user1 = BlueBottleUserFactory.create()
     self.user1_token = "JWT {0}".format(self.user1.get_jwt_token())
     self.user2 = BlueBottleUserFactory.create()
     self.user2_token = "JWT {0}".format(self.user2.get_jwt_token())
     financial = Group.objects.get(name='Financial')
     financial.user_set.add(self.user2)
     self.payoutmethods_url = reverse('payout-method-list')
Example #36
0
    def test_pledge_payment_methods(self):
        user = BlueBottleUserFactory.create(is_staff=False)
        staff_user = BlueBottleUserFactory.create(is_staff=True)

        methods = get_payment_methods(country="nl", user=user)
        self.assertEqual(len(methods), 1)

        methods = get_payment_methods(country="nl", user=staff_user)
        self.assertEqual(len(methods), 2)
    def setUp(self):
        # Required by Project model save method
        self.init_projects()

        self.some_project = OnePercentProjectFactory.create(amount_asked=5000)
        self.another_project = OnePercentProjectFactory.create(amount_asked=5000)

        self.some_user = BlueBottleUserFactory.create()
        self.another_user = BlueBottleUserFactory.create()
Example #38
0
    def setUp(self):
        super(TermsAPITest, self).setUp()

        self.user_1 = BlueBottleUserFactory.create()
        self.user_1_token = 'JWT {0}'.format(self.user_1.get_jwt_token())

        self.user_2 = BlueBottleUserFactory.create()
        self.user_2_token = 'JWT {0}'.format(self.user_2.get_jwt_token())

        self.terms = TermsFactory.create(contents='Awesome terms!')
 def test_save_custom_fields(self):
     member = BlueBottleUserFactory.create(password='******')
     staff = BlueBottleUserFactory.create(is_staff=True)
     CustomMemberFieldSettings.objects.create(name='Department')
     data = member.__dict__
     data['department'] = 'Engineering'
     form = MemberChangeForm(current_user=staff, instance=member, data=data)
     form.save()
     member.refresh_from_db()
     self.assertEqual(member.extra.get().value, 'Engineering')
    def setUp(self):
        self.init_projects()
        self.user = BlueBottleUserFactory.create()
        self.login(username=self.user.email, password='******')

        self.task = TaskFactory.create(people_needed=2, time_needed=8)
        self.task.author = BlueBottleUserFactory.create()
        self.task.save()

        self.task_member = TaskMemberFactory.create(member=self.user, task=self.task)
Example #41
0
 def setUp(self):
     self.user_1 = BlueBottleUserFactory.create()
     self.user_2 = BlueBottleUserFactory.create()
     self.current_user_api_url = '/api/users/current'
     self.user_create_api_url = '/api/users/'
     self.user_profile_api_url = '/api/users/profiles/'
     self.user_settings_api_url = '/api/users/settings/'
     self.user_activation_api_url = '/api/users/activate/'
     self.user_password_reset_api_url = '/api/users/passwordreset'
     self.user_password_set_api_url = '/api/users/passwordset/'
Example #42
0
    def setUp(self):
        super(QuoteTestCase, self).setUp()

        self.author = BlueBottleUserFactory.create()
        self.user = BlueBottleUserFactory.create()
        self.quote1 = QuoteFactory.create(
            author=self.author, user=self.user, quote="The best things in life are free.", language='en')
        self.quote2 = QuoteFactory.create(
            author=self.author, user=self.user, quote="Always forgive your enemies; nothing annoys them so much.",
            language='nl')
Example #43
0
    def setUp(self):
        super(FundraiserAPITestCase, self).setUp()
        self.some_user = BlueBottleUserFactory.create()
        self.some_token = "JWT {0}".format(self.some_user.get_jwt_token())

        self.some_other_user = BlueBottleUserFactory.create()
        self.some__other_token = "JWT {0}".format(self.some_other_user.get_jwt_token())

        self.some_project = ProjectFactory.create(owner=self.some_user, deadline=timezone.now() + timezone.timedelta(days=15))
        self.some_other_project = ProjectFactory.create(owner=self.some_user, deadline=timezone.now() + timezone.timedelta(days=15))
Example #44
0
    def setUp(self):
        super(StatisticsTest, self).setUp()
        self.stats = Statistics()
        Member.objects.all().delete()

        self.some_user = BlueBottleUserFactory.create()
        self.other_user = BlueBottleUserFactory.create()

        self.initiative = InitiativeFactory.create(owner=self.some_user)
        self.initiative.states.submit()
        self.initiative.states.approve(save=True)
 def test_create_user(self):
     mail.outbox = []
     BlueBottleUserFactory.create(first_name='Bob',
                                  email='*****@*****.**',
                                  primary_language='en')
     welcome_email = mail.outbox[0]
     self.assertEqual(welcome_email.to, ['*****@*****.**'])
     self.assertEqual(welcome_email.subject,
                      'You have been assimilated to Test')
     self.assertTrue('You are no longer Bob.' in welcome_email.body)
     self.assertTrue('We are borg' in welcome_email.body)
Example #46
0
    def test_no_welcome_mail(self):
        """
        Test that a welcome mail is sent when a user is created when the setting
        are disabled (= default)
        """
        mail.outbox = []

        # The setup function also creates a user and generates a mail
        self.assertEqual(len(mail.outbox), 0)
        BlueBottleUserFactory.create(email='*****@*****.**')
        self.assertEqual(len(mail.outbox), 0)
Example #47
0
    def setUp(self):
        super(SupporterCountTest, self).setUp()

        # Required by Project model save method
        self.init_projects()

        self.some_project = ProjectFactory.create(amount_asked=5000)
        self.another_project = ProjectFactory.create(amount_asked=5000)

        self.some_user = BlueBottleUserFactory.create()
        self.another_user = BlueBottleUserFactory.create()
Example #48
0
    def setUp(self):
        super(UserProfileUpdateTests, self).setUp()

        self.user_1 = BlueBottleUserFactory.create()
        self.user_2 = BlueBottleUserFactory.create()
        self.current_user_api_url = '/api/users/current'
        self.user_create_api_url = '/api/users/'
        self.user_profile_api_url = '/api/users/profiles/'
        self.user_activation_api_url = '/api/users/activate/'
        self.user_password_reset_api_url = '/api/users/passwordreset'
        self.user_password_set_api_url = '/api/users/passwordset/'
Example #49
0
    def test_no_welcome_mail(self):
        """
        Test that a welcome mail is sent when a user is created when the setting
        are disabled (= default)
        """
        mail.outbox = []

        # The setup function also creates a user and generates a mail
        self.assertEqual(len(mail.outbox), 0)
        BlueBottleUserFactory.create(email='*****@*****.**')
        self.assertEqual(len(mail.outbox), 0)
Example #50
0
    def setUp(self):
        super(SupporterCountTest, self).setUp()

        # Required by Project model save method
        self.init_projects()

        self.some_project = ProjectFactory.create(amount_asked=5000)
        self.another_project = ProjectFactory.create(amount_asked=5000)

        self.some_user = BlueBottleUserFactory.create()
        self.another_user = BlueBottleUserFactory.create()
Example #51
0
    def setUp(self):
        self.some_user = BlueBottleUserFactory.create()
        self.another_user = BlueBottleUserFactory.create()

        self.init_projects()

        self.phase_plan_new = ProjectPhase.objects.get(slug='plan-new')
        self.phase_submitted = ProjectPhase.objects.get(slug='plan-submitted')
        self.phase_campaign = ProjectPhase.objects.get(slug='campaign')

        self.manage_projects_url = reverse('project_manage_list')
        self.manage_budget_lines_url = reverse('project-budgetline-list')
Example #52
0
    def setUp(self):
        super(TestDonationEmails, self).setUp()
        self.init_projects()

        self.user = BlueBottleUserFactory.create(first_name='user')

        self.project_owner = BlueBottleUserFactory.create(
            first_name='projectowner')
        campaign_status = ProjectPhase.objects.get(slug='campaign')
        self.some_project = ProjectFactory.create(owner=self.project_owner,
                                                  status=campaign_status)

        self.order = OrderFactory.create(
            user=self.user,
        )

        self.recurring_order = OrderFactory.create(
            user=self.user,
            order_type="recurring"
        )

        self.donation = DonationFactory.create(
            order=self.order,
            project=self.some_project,
            fundraiser=None
        )

        self.recurring_donation = DonationFactory.create(
            order=self.recurring_order,
            project=self.some_project,
            fundraiser=None
        )

        self.fund_order = OrderFactory.create(
            user=self.user,
        )

        self.fund_project = ProjectFactory.create(owner=self.project_owner,
                                                  status=campaign_status)

        self.fund_owner = BlueBottleUserFactory.create(first_name='fundraiser')

        self.fundraiser_project = FundraiserFactory.create(
            owner=self.fund_owner,
            project=self.fund_project,
        )

        self.fund_donation = DonationFactory.create(
            order=self.fund_order,
            project=self.fund_project,
            fundraiser=self.fundraiser_project
        )
Example #53
0
    def setUp(self):
        self.user_1 = BlueBottleUserFactory.create()
        self.user_1_token = "JWT {0}".format(self.user_1.get_jwt_token())
        
        self.user_2 = BlueBottleUserFactory.create()

        self.organization_1 = OrganizationFactory.create()
        self.organization_2 = OrganizationFactory.create()
        self.organization_3 = OrganizationFactory.create()

        self.member_1 = OrganizationMemberFactory.create(user=self.user_1, organization=self.organization_1)
        self.member_2 = OrganizationMemberFactory.create(user=self.user_1, organization=self.organization_2)
        self.member_3 = OrganizationMemberFactory.create(user=self.user_2, organization=self.organization_3)
Example #54
0
    def setUp(self):
        self.some_wallpost = TextWallPostFactory.create()
        self.another_wallpost = TextWallPostFactory.create()
        
        self.some_user = BlueBottleUserFactory.create(password='******', first_name='someName', last_name='someLast')
        self.some_token = "JWT {0}".format(self.some_user.get_jwt_token())

        self.another_user = BlueBottleUserFactory.create(password='******', 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')
Example #55
0
    def setUp(self):
        super(FollowTests, self).setUp()
        self.init_projects()

        self.some_user = BlueBottleUserFactory.create()
        self.another_user = BlueBottleUserFactory.create()
        self.phase1 = ProjectPhaseFactory.create(slug='realised') # Required model for bb_payouts signals
        self.project = ProjectFactory(owner=self.some_user, status=self.phase1)

        self.task = TaskFactory.create(
            author=self.project.owner,
            project=self.project,
        )
Example #56
0
    def setUp(self):
        super(MonthlyDonationAdminTest, self).setUp()

        self.app.extra_environ['HTTP_HOST'] = str(self.tenant.domain_url)
        self.superuser = BlueBottleUserFactory.create(is_staff=True, is_superuser=True)

        self.init_projects()
        self.phase_campaign = ProjectPhase.objects.get(slug='campaign')
        self.country = CountryFactory()

        self.projects = []

        for amount in [500, 100, 1500, 300, 200]:
            self.projects.append(
                ProjectFactory.create(amount_asked=amount,
                                      status=self.phase_campaign))

        # Some donations to get the popularity going
        # Top 3 after this should be projects 4, 3, 0
        order = OrderFactory()
        DonationFactory(order=order, project=self.projects[3], amount=10)
        DonationFactory(order=order, project=self.projects[3], amount=100)
        DonationFactory(order=order, project=self.projects[3], amount=20)

        DonationFactory(order=order, project=self.projects[4], amount=10)
        DonationFactory(order=order, project=self.projects[4], amount=70)

        DonationFactory(order=order, project=self.projects[0], amount=10)

        order.locked()
        order.save()
        order.success()
        order.save()

        # Since we force the transitions update_amounts isn't triggered by
        # signal, so we run it manually here.
        for project in self.projects:
            project.update_amounts()

        self.user1 = BlueBottleUserFactory.create()
        self.user2 = BlueBottleUserFactory.create()

        # Create a monthly donor with a preferred project
        self.monthly_donor1 = MonthlyDonorFactory(user=self.user1, amount=25)
        self.monthly_donor1_project = MonthlyDonorProjectFactory(
            donor=self.monthly_donor1, project=self.projects[0])

        # Create a monthly donor without preferred projects
        self.monthly_donor2 = MonthlyDonorFactory(user=self.user2, amount=100)
        Project.update_popularity()
Example #57
0
    def setUp(self):
        self.user_1 = BlueBottleUserFactory.create()
        self.user_1_token = "JWT {0}".format(self.user_1.get_jwt_token())

        self.user_2 = BlueBottleUserFactory.create()
        self.user_2_token = "JWT {0}".format(self.user_2.get_jwt_token())

        self.current_user_api_url = '/api/users/current'
        self.user_create_api_url = '/api/users/'
        self.user_profile_api_url = '/api/users/profiles/'
        self.user_settings_api_url = '/api/users/settings/'
        self.user_activation_api_url = '/api/users/activate/'
        self.user_password_reset_api_url = '/api/users/passwordreset'
        self.user_password_set_api_url = '/api/users/passwordset/'
Example #58
0
    def setUp(self):
        super(TestOrderPermissions, self).setUp()

        self.user1 = BlueBottleUserFactory.create()
        self.user1_token = "JWT {0}".format(self.user1.get_jwt_token())

        self.user2 = BlueBottleUserFactory.create()
        self.user2_token = "JWT {0}".format(self.user2.get_jwt_token())

        self.order = OrderFactory.create(user=self.user1,
                                         status=StatusDefinition.SUCCESS)
        self.order_payment = OrderPaymentFactory.create(order=self.order,
                                                        payment_method='mock',
                                                        status=StatusDefinition.SUCCESS)
Example #59
0
    def setUp(self):
        super(JournalModelTests, self).setUp()
        self.init_projects() # loads fixture for project phases

        self.assertEqual(Member.objects.count(), 0)

        self.project_owner = BlueBottleUserFactory.create(email='*****@*****.**', primary_language='en')
        self.assertEqual(Member.objects.count(), 1)

        self.project = ProjectFactory.create(amount_asked=500, owner=self.project_owner)
        self.user = BlueBottleUserFactory.create(first_name='Jane', email='*****@*****.**')

        journals = DonationJournal.objects.all()
        self.assertEqual(journals.count(), 0)
Example #60
0
    def setUp(self):
        super(TestProjectPeopleCount, self).setUp()
        self.init_projects()

        self.project = ProjectFactory.create(title='test', amount_asked=100)
        self.project.status = ProjectPhase.objects.get(slug='campaign')
        self.project.save()

        self.user = BlueBottleUserFactory.create()
        self.another_user = BlueBottleUserFactory.create()

        self.task = TaskFactory.create(
            project=self.project, people_needed=10, status='open')
        self.other_task = TaskFactory.create(
            project=self.project, people_needed=10, status='open')