def test_list_mozillians_in_location_city_vouched(self): country = CountryFactory.create() country2 = CountryFactory.create() city = CityFactory(country=country) city2 = CityFactory(country=country) user_listed = UserFactory.create(userprofile={ 'geo_country': country, 'geo_city': city }) UserFactory.create(userprofile={ 'geo_country': country, 'geo_city': city2 }) UserFactory.create() UserFactory.create(vouched=False) UserFactory.create(vouched=False, userprofile={'geo_country': country2}) user = UserFactory.create() with self.login(user) as client: url = reverse('phonebook:list_city', kwargs={ 'country': country.name, 'city': city.name }) response = client.get(url, follow=True) eq_(response.status_code, 200) self.assertTemplateUsed(response, 'phonebook/location_list.html') eq_(response.context['country_name'], country.name) eq_(response.context['city_name'], city.name) eq_(response.context['region_name'], None) eq_(response.context['people'].paginator.count, 1) eq_(response.context['people'].object_list[0], user_listed.userprofile)
def setUp(self): voucher = UserFactory.create() country = CountryFactory() region = RegionFactory() city = CityFactory() self.user = UserFactory.create( userprofile={'vouched': False, 'geo_country': country, 'geo_region': region, 'geo_city': city}) self.user.userprofile.vouch(voucher.userprofile) group = GroupFactory.create() group.add_member(self.user.userprofile) skill = SkillFactory.create() self.user.userprofile.skills.add(skill) self.user.userprofile.externalaccount_set.create(type=ExternalAccount.TYPE_SUMO, identifier='Apitest') self.resource_url = reverse( 'api_dispatch_list', kwargs={'api_name': 'v1', 'resource_name': 'users'}) self.mozilla_app = APIAppFactory.create( owner=self.user, is_mozilla_app=True) self.mozilla_resource_url = urlparams( self.resource_url, app_name=self.mozilla_app.name, app_key=self.mozilla_app.key) self.community_app = APIAppFactory.create( owner=self.user, is_mozilla_app=False) self.community_resource_url = urlparams( self.resource_url, app_name=self.community_app.name, app_key=self.community_app.key)
def test_list_mozillians_in_location_region_n_city_vouched(self): """ Test that only vouched users with the correct country, city and region show up in the list view. """ country = CountryFactory.create() country2 = CountryFactory.create() region = RegionFactory.create(country=country) city = CityFactory(country=country, region=region) city2 = CityFactory(country=country) user_listed = UserFactory.create( userprofile={'geo_country': country, 'geo_region': region, 'geo_city': city}) UserFactory.create( userprofile={'geo_country': country, 'geo_region': region, 'geo_city': city2}) UserFactory.create() UserFactory.create(vouched=False) UserFactory.create(vouched=False, userprofile={'geo_country': country2}) UserFactory.create(userprofile={'geo_country': country}) UserFactory.create(userprofile={'geo_country': country, 'geo_region': region}) user = UserFactory.create() with self.login(user) as client: url = reverse('phonebook:list_region_city', kwargs={'country': country.name, 'region': region.name, 'city': city.name}) response = client.get(url, follow=True) eq_(response.status_code, 200) self.assertJinja2TemplateUsed(response, 'phonebook/location_list.html') eq_(response.context['country_name'], country.name) eq_(response.context['city_name'], city.name) eq_(response.context['region_name'], region.name) eq_(response.context['people'].paginator.count, 1) eq_(response.context['people'].object_list[0], user_listed.userprofile)