def setUp(self):

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

        self.country_1 = CountryFactory.create(name="Afghanistan")
        self.country_2 = CountryFactory.create(name="Albania")

        self.login(self.user.email, 'testing')

        self.project_data = {
            'title': 'Velit esse cillum dolore',
            'slug': 'velit-esse-cillum-dolore',
            'pitch': 'Quis aute iure reprehenderit in voluptate eu fugiat nulla pariatur.',
            'tags': ['okoali', 'kertan', 'lorem'],
            'description': 'Stet clita kasd gubergren.\nNo sea takimata sanctus est Lorem ipsum dolor sit amet. Sanctus sea sed takimata ut vero voluptua.\n\nStet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Sanctus sea sed takimata ut vero voluptua. Excepteur sint obcaecat cupiditat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.',
            'goal': 'Lorem ipsum dolor sit amet. Sanctus sea sed takimata ut vero voluptua. Excepteur sint obcaecat cupiditat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.',
            'destination_impact': 'Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.',
            'amount_asked': 5000,
            'budget': [
                {'description': 'Ghaks', 'amount': 4000},
                {'description': 'Rausno', 'amount': 500},
                {'description': 'Jama Jurnoader', 'amount': 500}
                ]
            }
Пример #2
0
    def test_filter_country(self):
        country1 = CountryFactory.create()
        country2 = CountryFactory.create()

        initiative1 = InitiativeFactory.create(place=GeolocationFactory.create(
            country=country1))
        initiative2 = InitiativeFactory.create(place=GeolocationFactory.create(
            country=country2))
        initiative3 = InitiativeFactory.create(place=GeolocationFactory.create(
            country=country1))
        initiative4 = InitiativeFactory.create(place=GeolocationFactory.create(
            country=country2))

        first = AssignmentFactory.create(status='full', initiative=initiative1)
        ApplicantFactory.create_batch(3, activity=first, status='accepted')

        second = AssignmentFactory.create(status='open',
                                          initiative=initiative3)

        third = AssignmentFactory.create(status='full', initiative=initiative2)
        ApplicantFactory.create_batch(3, activity=third, status='accepted')

        AssignmentFactory.create(status='open', initiative=initiative4)

        response = self.client.get(
            self.url +
            '?sort=popularity&filter[country]={}'.format(country1.id),
            user=self.owner)

        data = json.loads(response.content)

        self.assertEqual(data['meta']['pagination']['count'], 2)

        self.assertEqual(data['data'][0]['id'], str(second.pk))
        self.assertEqual(data['data'][1]['id'], str(first.pk))
Пример #3
0
    def test_user_update_place(self):
        """
        Test updating a user with the api and setting a place.
        """
        user_profile_url = reverse('manage-profile',
                                   kwargs={'pk': self.user_1.pk})
        # Create a user.
        PlaceFactory.create(content_object=self.user_1)

        country = CountryFactory.create()
        data = {
            'email': '*****@*****.**',
            'password': '******',
            'place': {
                'country': country.pk,
                'locality': 'Amsterdam',
                'position': (52.0, 43.4)
            }
        }

        response = self.client.put(user_profile_url,
                                   data,
                                   token=self.user_1_token)
        self.assertEqual(response.status_code, status.HTTP_200_OK,
                         response.data)
        self.assertEqual(response.data['place']['locality'], 'Amsterdam')
        self.assertEqual(response.data['place']['country'], country.pk)
Пример #4
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
        }
Пример #5
0
 def test_geolocation_field(self):
     country = CountryFactory.create()
     geolocation = Geolocation.objects.create(position=Point(
         23.6764778, 43.0682267),
                                              country=country)
     geolocation.save()
     self.assertEqual(geolocation.position, Point(23.6764778, 43.0682267))
Пример #6
0
    def test_abnormal_address_data(self, mock_client):
        # Mock response to creating the payment at docdata
        instance = mock_client.return_value
        instance.create.return_value = {'order_key': 123, 'order_id': 123}

        patch.object(DocdataPaymentAdapter, 'create_payment',
                     fake_create_payment)

        user = BlueBottleUserFactory()
        CountryFactory(name='Netherlands', alpha2_code='NL')

        # Update user address with abnormal line1
        user.address.line1 = '1a'
        user.address.save()

        self.order = OrderFactory.create(user=user)
        self.order_payment = OrderPaymentFactory.create(
            order=self.order,
            payment_method='docdataIdeal',
            integration_data={'default_pm': 'ideal'})

        self.service = PaymentService(order_payment=self.order_payment)

        user_data = self.service.adapter.get_user_data()
        self.assertEqual(user_data['street'], 'Unknown')
Пример #7
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()
Пример #8
0
 def test_ideal_payment_country_with_profile(self, mock_client):
     # Even a yankees should get NL for country when selecting iDEAL.
     instance = mock_client.return_value
     instance.create.return_value = {'order_key': 123, 'order_id': 123}
     user = BlueBottleUserFactory()
     user.address.country = CountryFactory(name='Merica', alpha2_code='US')
     order_payment = OrderPaymentFactory(
         user=user,
         payment_method='docdataIdeal',
         integration_data={'default_pm': 'ideal'})
     order_payment.order.user = user
     self.adapter = DocdataPaymentAdapter(order_payment=order_payment)
     payment = self.adapter.payment
     self.assertEqual(payment.country, 'NL')
Пример #9
0
    def test_user_profile_location_update(self):
        """
        Test that updating your location sets your country
        """
        country = CountryFactory.create()
        location = LocationFactory.create(country=country)
        user_profile_url = "{0}{1}".format(self.user_private_profile_api_url, self.user_1.id)
        changes = {"location": location.id}

        # Profile should not be able to be updated by anonymous users.
        response = self.client.put(user_profile_url, changes, token=self.user_1_token)

        self.assertEqual(response.status_code, status.HTTP_200_OK)
        self.assertEqual(country.id, response.data["address"]["country"])
Пример #10
0
    def test_user_profile_location_update(self):
        """
        Test that updating your location sets your country
        """
        country = CountryFactory.create()
        location = LocationFactory.create(country=country)
        user_profile_url = reverse('manage-profile', kwargs={'pk': self.user_1.id})
        changes = {'location': location.id}

        # Profile should not be able to be updated by anonymous users.
        response = self.client.put(user_profile_url, changes,
                                   token=self.user_1_token)

        self.assertEqual(response.status_code, status.HTTP_200_OK)
        self.assertEqual(country.id, response.data['address']['country'])
Пример #11
0
    def setUp(self):
        super(TestProjectStatusUpdateStatGeneration, self).setUp()

        self.tenant = self.client.tenant

        self.init_projects()
        with patch('bluebottle.analytics.utils.queue_analytics_record'):
            self.theme = ProjectThemeFactory.create(name='Cleaning the beach',
                                                    slug='cleaning-the-beach')
            self.country = CountryFactory.create()
            self.status = ProjectPhaseFactory.create(slug='realised')
            self.project = ProjectFactory.create(theme=self.theme,
                                                 status=self.status,
                                                 country=self.country)
            self.count = ProjectPhase.objects.all().count()
Пример #12
0
 def test_payment_country_with_profile(self, mock_client):
     # When a country is set in profile, that should be used.
     instance = mock_client.return_value
     instance.create.return_value = {'order_key': 123, 'order_id': 123}
     user = BlueBottleUserFactory()
     user.address.country = CountryFactory(name='Netherlands',
                                           alpha2_code='NL')
     order_payment = OrderPaymentFactory(
         user=user,
         payment_method='docdataCreditcard',
         integration_data={'default_pm': 'mastercard'})
     order_payment.order.user = user
     self.adapter = DocdataPaymentAdapter(order_payment=order_payment)
     payment = self.adapter.payment
     self.assertEqual(payment.country, 'NL')
Пример #13
0
    def test_normal_userdata(self, mock_client):
        # Mock response to creating the payment at docdata
        instance = mock_client.return_value
        instance.create.return_value = {'order_key': 123, 'order_id': 123}

        patch.object(DocdataPaymentAdapter, 'create_payment',
                     fake_create_payment)

        user = BlueBottleUserFactory()
        holland = CountryFactory(name='Netherlands', alpha2_code='NL')

        # Update user address
        user.address.line1 = 'Dam 1a'
        user.address.line2 = 'Bovenste bel'
        user.address.city = 'Amsterdam'
        user.address.postal_code = '1000AA'
        user.address.country = holland
        user.address.save()

        self.order = OrderFactory.create(user=user)
        self.order_payment = OrderPaymentFactory.create(
            order=self.order,
            payment_method='docdataIdeal',
            integration_data={'default_pm': 'ideal'})

        self.service = PaymentService(order_payment=self.order_payment)

        user_data = self.service.adapter.get_user_data()
        self.assertEqual(user_data['id'], user.id)
        self.assertEqual(user_data['first_name'], user.first_name)
        self.assertEqual(user_data['last_name'], user.last_name)
        self.assertEqual(user_data['email'], user.email)

        self.assertEqual(user_data['street'], 'Dam')
        self.assertEqual(user_data['house_number'], '1a')
        self.assertEqual(user_data['postal_code'], '1000AA')
        self.assertEqual(user_data['city'], 'Amsterdam')
        self.assertEqual(user_data['country'], 'NL')

        self.assertEqual(user_data['company'], '')
        self.assertEqual(user_data['kvk_number'], '')
        self.assertEqual(user_data['vat_number'], '')
        self.assertEqual(user_data['house_number_addition'], '')
        self.assertEqual(user_data['state'], '')
Пример #14
0
    def setUp(self):
        super(OrderApiTestCase, 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.country = CountryFactory.create(alpha2_code='NL')

        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')
Пример #15
0
    def setUp(self):
        super(OrderApiTestCase, 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.country = CountryFactory.create(alpha2_code='NL')

        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')
Пример #16
0
    def setUp(self):
        super(TestProjectAnalytics, self).setUp()
        self.init_projects()

        self.theme = ProjectThemeFactory.create(name='Cleaning the beach',
                                                slug='cleaning-the-beach')
        self.country = CountryFactory.create()
        self.status = ProjectPhase.objects.get(slug='campaign')
        self.expected_tags = {
            'status': self.status.name,
            'theme_slug': u'cleaning-the-beach',
            'status_slug': self.status.slug,
            'country': self.country.name,
            'theme': u'Cleaning the beach',
            'location': '',
            'location_group': '',
            'type': 'project',
            'sub_type': 'funding',
            'tenant': u'test',
        }
Пример #17
0
    def setUp(self):
        super(TestProjectAnalytics, self).setUp()
        self.init_projects()

        self.theme = ProjectThemeFactory.create(name='Cleaning the beach',
                                                slug='cleaning-the-beach')
        self.country = CountryFactory.create(name='Beachville')
        self.status = ProjectPhase.objects.get(slug='campaign')
        self.expected_tags = {
            'status': self.status.name,
            'theme_slug': u'cleaning-the-beach',
            'status_slug': self.status.slug,
            'country': u'Beachville',
            'theme': u'Cleaning the beach',
            'location': '',
            'location_group': '',
            'type': 'project',
            'sub_type': u'funding',
            'tenant': u'test',
        }
Пример #18
0
 def setUp(self):
     super(GeolocationAdminTest, self).setUp()
     self.country = CountryFactory.create(name='Plopsaland')
     self.user = BlueBottleUserFactory(is_staff=True, is_superuser=True)
     self.admin_add_url = reverse('admin:geo_geolocation_add')
Пример #19
0
	def setUp(self):
		self.country_1 = CountryFactory.create(name="Afghanistan")
		self.country_2 = CountryFactory.create(name="Albania")
Пример #20
0
    def test_location_sets_country(self):
        country = CountryFactory.create()
        location = LocationFactory.create(country=country)

        BlueBottleUserFactory.create(email='*****@*****.**',
                                     location=location)
Пример #21
0
 def setUp(self):
     super(GeoTestCase, self).setUp()
     self.country = CountryFactory.create()
     self.client = JSONAPITestClient()
     self.user = BlueBottleUserFactory.create()
Пример #22
0
 def setUp(self):
     super(GeoTestCase, self).setUp()
     self.country_1 = CountryFactory.create(name="Afghanistan")
     self.country_2 = CountryFactory.create(name="Albania")
Пример #23
0
 def setUp(self):
     from ..management.commands.bulk_import import Command as BulkImportCommand
     self.cmd = BulkImportCommand()
     super(BulkImportTests, self).setUp()
     CountryFactory.create(alpha2_code='NL')
Пример #24
0
    def test_location_sets_country(self):
        country = CountryFactory.create()
        location = LocationFactory.create(country=country)

        BlueBottleUserFactory.create(email='*****@*****.**', location=location)