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
파일: test_api.py 프로젝트: raux/bluebottle
    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")