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_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))
Пример #4
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)
Пример #5
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"])
Пример #6
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'])
Пример #7
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()
Пример #8
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')
Пример #9
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')
Пример #10
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',
        }
Пример #11
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',
        }
Пример #12
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')
Пример #13
0
    def test_location_sets_country(self):
        country = CountryFactory.create()
        location = LocationFactory.create(country=country)

        BlueBottleUserFactory.create(email='*****@*****.**',
                                     location=location)
Пример #14
0
 def setUp(self):
     super(GeoTestCase, self).setUp()
     self.country = CountryFactory.create()
     self.client = JSONAPITestClient()
     self.user = BlueBottleUserFactory.create()
Пример #15
0
    def test_location_sets_country(self):
        country = CountryFactory.create()
        location = LocationFactory.create(country=country)

        BlueBottleUserFactory.create(email='*****@*****.**', location=location)
Пример #16
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')
Пример #17
0
	def setUp(self):
		self.country_1 = CountryFactory.create(name="Afghanistan")
		self.country_2 = CountryFactory.create(name="Albania")
Пример #18
0
 def setUp(self):
     super(GeoTestCase, self).setUp()
     self.country_1 = CountryFactory.create(name="Afghanistan")
     self.country_2 = CountryFactory.create(name="Albania")