Esempio n. 1
0
    def setUp(self):
        super(TokenLoginApiTest, self).setUp()

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

        self.token_login_url = reverse('token-login')
Esempio n. 2
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'])
Esempio n. 3
0
    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')
Esempio n. 4
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'
        )
Esempio n. 5
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)
Esempio n. 6
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)
Esempio n. 7
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')
Esempio n. 8
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)
        )
Esempio n. 9
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()
Esempio n. 10
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}
Esempio n. 11
0
    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)
Esempio n. 12
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)
Esempio n. 13
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)
Esempio n. 14
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)
Esempio n. 15
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')
Esempio n. 16
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']})
Esempio n. 17
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'])
    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'}
Esempio n. 19
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)
    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()
Esempio n. 21
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
        }
Esempio n. 22
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()
Esempio n. 23
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)
Esempio n. 24
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)
Esempio n. 25
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,
        }
Esempio n. 26
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})
Esempio n. 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')
Esempio n. 28
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})
Esempio n. 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)
Esempio n. 30
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, ))
Esempio n. 31
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)
Esempio n. 32
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)
Esempio n. 33
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')
Esempio n. 34
0
    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()
    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)
Esempio n. 36
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))
Esempio n. 37
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/'
Esempio n. 38
0
 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')
Esempio n. 39
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')
Esempio n. 40
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!')
Esempio n. 41
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)
Esempio n. 42
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()
Esempio n. 43
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)
Esempio n. 44
0
    def setUp(self):
        super(UserDataExportTest, 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_export_url = reverse('user-export')
Esempio n. 45
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)
Esempio n. 46
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()
Esempio n. 47
0
 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)
Esempio n. 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/'
Esempio n. 49
0
    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)

        # A user creates a fundraiser
        fundraiser_person = BlueBottleUserFactory.create()
        fundraiser = FundraiserFactory(project=self.project,
                                       owner=fundraiser_person)

        # Two people donate to the fundraiser
        donator1 = BlueBottleUserFactory.create()
        order = OrderFactory.create(user=donator1,
                                    status=StatusDefinition.CREATED)
        DonationFactory(order=order, amount=35,
                        project=self.project,
                        fundraiser=fundraiser)
        order.locked()
        order.success()
        order.save()

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

        order2.locked()
        order2.success()
        order2.save()

        # The fundraiser owner creates a wallpost to followers
        TextWallpostFactory.create(content_object=fundraiser,
                                   author=fundraiser_person,
                                   text="test_fundraiser",
                                   email_followers=True)

        mail_count = 0
        self.assertEqual(Follow.objects.count(), 3)

        # When the fundraiser sends an email to the followers he doesn't get one himself
        receivers = [donator1.email, donator2.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, 2)
        self.assertEqual(receivers, [])
Esempio n. 50
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')
Esempio n. 51
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
        )
Esempio n. 52
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,
        )
Esempio n. 53
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')
Esempio n. 54
0
    def setUp(self):
        super(TestPinnedWallpost, self).setUp()

        self.initiator = BlueBottleUserFactory.create()
        self.initiator_token = "JWT {0}".format(self.initiator.get_jwt_token())

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

        self.initiative = InitiativeFactory.create(owner=self.initiator)

        self.wallpost_url = reverse('wallpost_list')
        self.text_wallpost_url = reverse('text_wallpost_list')
Esempio n. 55
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)
Esempio n. 56
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)
Esempio n. 57
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)
Esempio n. 58
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/'
Esempio n. 59
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()
Esempio n. 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')