Exemplo n.º 1
0
    def setUp(self):
        """
        Create 26 Project instances.
        """
        self.init_projects()
        self.user = BlueBottleUserFactory.create()

        organization = OrganizationFactory.create()
        organization.save()

        self.campaign_phase = ProjectPhase.objects.get(slug='campaign')
        self.plan_phase = ProjectPhase.objects.get(slug='done-complete')

        for char in 'abcdefghijklmnopqrstuvwxyz':
            # Put half of the projects in the campaign phase.
            if ord(char) % 2 == 1:
                project = OnePercentProjectFactory.create(title=char * 3, slug=char * 3,
                                                          status=self.campaign_phase, organization=organization)
            else:
                project = OnePercentProjectFactory.create(title=char * 3, slug=char * 3,
                                                          status=self.plan_phase, organization=organization)

            project.save()

        self.projects_url = reverse('project_list')
Exemplo n.º 2
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 test_change_project_goal(self):
        plan_phase = ProjectPhase.objects.get(slug='plan-new')
        project = OnePercentProjectFactory.create(title='Project Goal Changes', owner=self.user, status=plan_phase)
        self.visit_path('/my/projects/{0}/goal'.format(project.slug))

        # Check that deadline is set to 30 days now
        days_left = self.browser.find_by_css('.project-days-left strong').first
        self.assertEqual(days_left.text, '30')

        # Let's pick a date
        # Click Next to get a date in the future
        self.assertTrue(self.scroll_to_and_click_by_css(".btn-date-picker"))
        self.browser.find_by_css("[title=Prev]").first.click()
        self.browser.find_by_css("[title=Prev]").first.click()
        self.browser.find_by_css("[title=Prev]").first.click()
        self.browser.find_by_css("[title=Next]").first.click()
        self.assertTrue(self.browser.is_text_present("4"))
        self.browser.find_link_by_text("4").first.click()
        # remember the days left now
        days_left1 = self.browser.find_by_css('.project-days-left strong').first.text

        time.sleep(2)

        self.assertTrue(self.scroll_to_and_click_by_css(".btn-date-picker"))
        self.assertTrue(self.browser.is_text_present("14"))
        self.browser.find_link_by_text("14").first.click()
        days_left2 = self.browser.find_by_css('.project-days-left strong').first.text
        days_diff = int(days_left2) - int(days_left1)

        self.assertEqual(days_diff, 10)
    def setUp(self):
        self.init_projects()

        self.user = BlueBottleUserFactory.create()

        campaign_phase = ProjectPhase.objects.get(name='Campaign')
        for title in [u'Mobile payments for everyone!', u'Schools for children',  u'Women first']:
            project = OnePercentProjectFactory.create(title=title, owner=self.user,
                                                      amount_asked=1000, status=campaign_phase)

        self.visit_path('/projects/schools-for-children')

        # Assert visual donation elements on project page
        self.assert_css(".amount-donated")
        self.assert_css(".project-fund-amount-slider")

        # Bring up the donation modal
        self.assert_css('a[data-action-type="donate"]')
        self.scroll_to_and_click_by_css('a[data-action-type=donate]')

        # Verify the elements of the donation modal
        self.wait_for_element_css('input.donation-input')

        donation_input = self.browser.find_by_css("input.donation-input").first

        # Make a donation of 55 euros (default is 25)
        donation_input.fill('55')
        self.assertEqual(int(donation_input.value), 55)
        self.assert_css(".donation-buttons")
        self.assert_css("#hideMyName")

        # Jump to next step
        self.scroll_to_and_click_by_css(".donate-btn")
    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'}
    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()
Exemplo n.º 7
0
    def test_homepage_with_campaign(self):
        now = timezone.now()
        start, end = now - timedelta(hours=8), now + timedelta(weeks=1)
        Campaign.objects.create(start=start, end=end, title='FooBarCaMpAIgN', target=100000)

        # make a donation before the campaign starts
        order = Order.objects.create(user=self.user, order_number=1)
        Donation.objects.create(amount=1000, user=self.user, project=self.project,
                                status=DonationStatuses.paid, order=order, ready=now-timedelta(days=1))

        # and a couple of donations in campaign, for a total amount of 2000+3000+4000 cents = 90 euros
        for i in range(1,4):
            amount = (i+1)*1000
            Donation.objects.create(amount=amount, user=self.user, project=self.project,
                                    status=DonationStatuses.paid, order=order, ready=now+timedelta(days=i))

        # and one after the campaign
        Donation.objects.create(amount=5000, user=self.user, project=self.project,
                                status=DonationStatuses.paid, order=order, ready=now+timedelta(weeks=2))

        self.project_with_fundraiser = OnePercentProjectFactory.create(amount_asked=50000)
        self.project_with_fundraiser.is_campaign = True
        self.project_with_fundraiser.save()
        self.fundraiser = FundRaiserFactory.create(owner=self.user, project=self.project_with_fundraiser)

        response = self.client.get(self.homepage_url)
        self.assertNotEqual(None, response.data['campaign'])

        self.assertEqual(response.data['campaign']['amount_donated'], '90.00')
Exemplo n.º 8
0
    def setUp(self):
        self.init_projects()
        self.some_project = OnePercentProjectFactory.create(slug='someproject')
        self.another_project = OnePercentProjectFactory.create(slug='anotherproject')

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

        self.some_photo = 'apps/projects/test_images/loading.gif'
        self.another_photo = 'apps/projects/test_images/upload.png'

        self.media_wallposts_url = reverse('media_wallpost_list')
        self.media_wallpost_photos_url = reverse('mediawallpost_photo_list')   

        self.text_wallposts_url = reverse('text_wallpost_list')
        self.wallposts_url = reverse('wallpost_list')
Exemplo n.º 9
0
    def setUp(self):
        """ Create two project instances """
        self.init_projects()
        self.campaign_phase = ProjectPhase.objects.get(slug='campaign')

        self.some_project = OnePercentProjectFactory.create(amount_asked=50000, status=self.campaign_phase)
        self.another_project = OnePercentProjectFactory.create(amount_asked=75000, status=self.campaign_phase)

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

        self.fundraiser = FundRaiserFactory.create(owner=self.some_user, project=self.some_project)
        self.fundraiser2 = FundRaiserFactory.create(owner=self.another_user, project=self.another_project)

        self.current_donations_url = reverse('fund-order-current-donation-list')
        self.current_order_url = reverse('fund-order-current-detail')
        self.fundraiser_list_url = reverse('fundraiser-list')
        self.fundraiser_url = reverse('fundraiser-detail', kwargs={'pk': self.fundraiser.pk})
        self.fundraiser2_url = reverse('fundraiser-detail', kwargs={'pk': self.fundraiser2.pk})
    def test_homepage_with_campaign(self):
        start, end = timezone.now() - timedelta(hours=8), timezone.now() + timedelta(weeks=1)
        Campaign.objects.create(start=start, end=end, title='FooBarCaMpAIgN', target=100000)

        self.project_with_fundraiser = OnePercentProjectFactory.create(amount_asked=50000)
        self.project_with_fundraiser.is_campaign = True
        self.project_with_fundraiser.save()
        self.fundraiser = FundRaiserFactory.create(owner=self.user, project=self.project_with_fundraiser)

        self.visit_homepage()
        self.assertTrue(self.browser.is_text_present('OUR CRAZY FUND-RACERS'))
    def setUp(self):
        """
        Create initial data.
        """
        self.project_with_fundraiser = OnePercentProjectFactory.create(amount_asked=50000)
        self.project_without_fundraiser = OnePercentProjectFactory.create(amount_asked=75000)

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

        self.fundraiser = FundRaiserFactory.create(owner=self.some_user, project=self.project_with_fundraiser)

        self.project_with_fundraiser_url = '/projects/{0}'.format(self.project_with_fundraiser.slug)
        self.project_without_fundraiser_url = '/projects/{0}'.format(self.project_without_fundraiser.slug)

        self.fundraiser_url = '/fundraisers/{0}'.format(self.fundraiser.pk)
        self.new_fundraiser_url = '/project/{0}/new-fundraiser'.format(self.project_without_fundraiser.slug)

        # Force reload by visiting the home
        self.visit_path('')
    def setUp(self):
        self.init_projects()

        self.user = BlueBottleUserFactory.create()

        campaign_phase = ProjectPhase.objects.get(name='Campaign')
        for title in [u'Mobile payments for everyone!', u'Schools for children',  u'Women first']:
            project = OnePercentProjectFactory.create(title=title, owner=self.user,
                                                      amount_asked=1000, status=campaign_phase)

        self.login(self.user.email, 'testing')
Exemplo n.º 13
0
    def setUp(self):
        self.init_projects()
        self.phase_campaign = ProjectPhase.objects.get(slug='campaign')
        self.country = CountryFactory()

        self.some_project = OnePercentProjectFactory.create(amount_asked=500, status=self.phase_campaign)
        self.another_project = OnePercentProjectFactory.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}
Exemplo n.º 14
0
    def test_change_status_to_campaign(self):
        """
        Changing project status to campaign sets the campaign_started field
        """
        project = OnePercentProjectFactory.create(title="testproject", slug="testproject",
                                                  status=ProjectPhase.objects.get(slug='plan-new'))
        self.assertTrue(project.date_submitted is None)
        self.assertTrue(project.campaign_started is None)

        project.status = ProjectPhase.objects.get(slug="campaign")
        project.save()

        self.assertTrue(project.campaign_started is not None)
    def setUp(self):
        self.init_projects()

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

        self.user = BlueBottleUserFactory.create(email='*****@*****.**', primary_language='en')

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

        for slug, title in self.projects.items():
            project = OnePercentProjectFactory.create(title=title, slug=slug, owner=self.user,
                                                      amount_asked=1000, status=campaign_phase)
Exemplo n.º 16
0
    def setUp(self):
        self.init_projects()

        # Create and activate user.
        self.user = BlueBottleUserFactory.create(email='*****@*****.**', primary_language='en')
        title = u'Mobile payments for everyone 2!'

        self.project = OnePercentProjectFactory.create(title=title, slug=slugify(title), amount_asked=100000, owner=self.user)
        self.project.status = ProjectPhase.objects.get(slug='campaign')
        self.project.is_campaign = True
        self.project.money_donated = 0
        self.project.save()

        self.homepage_url = '/api/homepage/en'
Exemplo n.º 17
0
    def setUp(self):

        self.init_projects()

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

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

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

        self.recurring_order_url_base = '/api/fund/recurring/orders/'
        self.recurring_donation_url_base = '/api/fund/recurring/donations/'
        self.recurring_payment_url_base = '/api/fund/recurring/directdebitpayments/'

        self.some_profile = {'first_name': 'Nijntje',
                             'last_name': 'het Konijnje',
                             'email': '*****@*****.**',
                             'address': 'Dam 1',
                             'postal_code': '1001AM',
                             'city': 'Amsterdam',
                             'country': 'NL',
                             'account': '123456789'}
    def setUp(self):
        self.init_projects()

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

        User = get_user_model()
        # Create and activate user.
        self.user = BlueBottleUserFactory.create(email='*****@*****.**', primary_language='en')

        for slug, title in self.projects.items():
            project = OnePercentProjectFactory.create(title=title, slug=slug, amount_asked=100000, owner=self.user)
            project.amount_donated = 0
            project.save()
Exemplo n.º 19
0
    def _create_donation(self, user=None, amount=None, project=None, status=DonationStatuses.new):
        """ Helper method for creating donations."""
        if not project:
            project = OnePercentProjectFactory.create()
            project.save()

        if not user:
            user = BlueBottleUserFactory.create()

        if not amount:
            amount = Decimal('10.00')

        order = Order.objects.create()
        donation = Donation.objects.create(user=user, amount=amount, status=status, project=project, order=order)

        return donation
Exemplo n.º 20
0
    def test_campaign_project_got_funded_allow_overfunding(self):
        """
        A project gets funded and allows overfunding. The project status does not change, the campaign_funded field
        is populated but the campaign_ended field is not populated
        """
        project = OnePercentProjectFactory.create(title="testproject", slug="testproject",
                                                  status=ProjectPhase.objects.get(slug="campaign"),
                                                  amount_asked=100)

        self.assertTrue(project.campaign_ended is None)
        self.assertTrue(project.campaign_funded is None)

        donation = DonationFactory.create(user=self.user, project=project, amount=10000)

        self.assertTrue(project.campaign_ended is None)
        self.assertTrue(project.campaign_funded is not None)
        self.assertEquals(project.status, ProjectPhase.objects.get(slug="campaign"))
Exemplo n.º 21
0
    def test_campaign_project_not_funded(self):
        """
        A donation is made but the project is not funded. The status doesn't change and neither the campaign_ended
        or campaign_funded are populated.
        """
        project = OnePercentProjectFactory.create(title="testproject", slug="testproject",
                                                  status=ProjectPhase.objects.get(slug="campaign"),
                                                  amount_asked=100)

        self.assertTrue(project.campaign_ended is None)
        self.assertTrue(project.campaign_funded is None)

        donation = DonationFactory.create(user=self.user, project=project, amount=99)

        self.assertTrue(project.campaign_ended is None)
        self.assertTrue(project.campaign_funded is None)
        self.assertEquals(project.status, ProjectPhase.objects.get(slug="campaign"))
    def setUp(self):
        self.init_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)
            project.status = ProjectPhase.objects.get(slug="campaign")
            project.save()
            self.some_project = project

        self.project_list_url = '{0}/en/?_escaped_fragment_=/projects'.format(self.live_server_url)
        self.project_url = '{0}/en/?_escaped_fragment_=/projects/{1}'.format(self.live_server_url, self.some_project.slug)

        self.crawl_client = self.client_class(SERVER_NAME=self.server_thread.host, SERVER_PORT=self.server_thread.port)
    def setUp(self):
        self.init_projects()
        self.skill = SkillFactory.create()
        self.project = OnePercentProjectFactory.create()
        self.project.owner = BlueBottleUserFactory.create()
        self.project.save()
        self.login(username=self.project.owner.email, password='******')

        self.task1 = {
            'title': 'Hora est labora',
            'description': 'In nec convallis felis. Quisque iaculis augue nec eros convallis, non rutrum velit mattis.',
            'location': 'Vestibulum nisi dui',
            'end_goal': 'World peace',
            'people_needed': 8,
            'time_needed': 4,
            'skill': self.skill.id
        }
Exemplo n.º 24
0
    def test_campaign_project_got_funded_no_overfunding(self):
        """
        A project gets a donation and gets funded. The project does not allow overfunding so the status changes,
        the campaign funded field is populated and campaign_ended field is populated
        """
        organization = OrganizationFactory.create()
        project = OnePercentProjectFactory.create(title="testproject", slug="testproject",
                                                  organization=organization,
                                                  status=ProjectPhase.objects.get(slug="campaign"),
                                                  amount_asked=100, allow_overfunding=False)

        self.assertTrue(project.campaign_ended is None)
        self.assertTrue(project.campaign_funded is None)

        donation = DonationFactory.create(user=self.user, project=project, amount=10000)

        loaded_project = Project.objects.get(pk=project.pk)
Exemplo n.º 25
0
    def test_project_expired(self):
        """
        The deadline of a project expires but its not funded. The status changes, the campaign_ended field is populated
        with the deadline, the campaign_funded field is empty.
        """
        project = OnePercentProjectFactory.create(title="testproject", slug="testproject",
                                                  status=ProjectPhase.objects.get(slug="campaign"),
                                                  amount_asked=100)

        self.assertTrue(project.campaign_ended is None)
        self.assertTrue(project.campaign_funded is None)

        project.deadline = timezone.now() - timedelta(days=10)
        project.save()

        self.assertEquals(project.campaign_ended, project.deadline)
        self.assertTrue(project.campaign_funded is None)
        self.assertEquals(project.status, ProjectPhase.objects.get(slug="done-incomplete"))
    def setUp(self):
        self.init_projects()

        super(ProjectWallPostSeleniumTests, self).setUp()
        self.user = BlueBottleUserFactory.create()

        owner = BlueBottleUserFactory.create()

        self.project = OnePercentProjectFactory.create(owner=owner)
        self.project.save()

        self.post1 = {
            'text': 'Ziltch emit doler omit et dametis!'
        }
        self.post2 = {
            'title': 'Hora est',
            'text': 'Rolum dohar in amuet redicer...'
        }
Exemplo n.º 27
0
    def setUp(self):
        super(PayoutTestCase, self).setUp()

        # Set up a project ready for payout
        organization = OrganizationFactory.create()
        organization.save()
        self.project = OnePercentProjectFactory.create(organization=organization, amount_asked=50)

        # Update phase to campaign.
        self.project.status = ProjectPhase.objects.get(slug='campaign')
        self.project.save()

        self.order = OrderFactory.create()

        self.donation = DonationFactory.create(
            project=self.project,
            order=self.order,
            amount=60
        )
        self.donation.save()
Exemplo n.º 28
0
from ..choices import PayoutRules, PayoutLineStatuses
from onepercentclub.tests.factory_models.donation_factories import DonationFactory
from onepercentclub.tests.factory_models.project_factories import OnePercentProjectFactory
from onepercentclub.tests.utils import OnePercentTestCase
from ..utils import date_timezone_aware


class PayoutTestCase(SepaXMLTestMixin, OnePercentTestCase):
    """ Testcase for Payouts. """

    def setUp(self):
        """ Setup a project ready for payout. """

        self.init_projects()

        self.project = OnePercentProjectFactory.create()

        # Update phase to campaign.
        self.project.status = ProjectPhase.objects.get(slug='campaign')
        self.project.save()

        self.donation = DonationFactory.create(
            project=self.project,
            voucher=None,
            donation_type=Donation.DonationTypes.one_off,
            amount=1500
        )

        super(PayoutTestCase, self).setUp()

    def test_save(self):
Exemplo n.º 29
0
 def setUp(self):
     self.project_owner = BlueBottleUserFactory.create(email='*****@*****.**', primary_language='en')
     self.project = OnePercentProjectFactory.create(amount_asked=50000, owner=self.project_owner)
     self.user = BlueBottleUserFactory.create(first_name='Jane')