• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python tests.CountryFactory类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中mozillians.geo.tests.CountryFactory的典型用法代码示例。如果您正苦于以下问题:Python CountryFactory类的具体用法?Python CountryFactory怎么用?Python CountryFactory使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了CountryFactory类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: test_list_mozillians_in_location_region_vouched

 def test_list_mozillians_in_location_region_vouched(self):
     country = CountryFactory.create()
     country2 = CountryFactory.create()
     region = RegionFactory.create(country=country)
     region2 = RegionFactory.create(country=country)
     user_listed = UserFactory.create(
         userprofile={'geo_country': country,
                      'geo_region': region})
     UserFactory.create(
         userprofile={'geo_country': country,
                      'geo_region': region2})
     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_region',
             kwargs={'country': country.name, 'region': region.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'], None)
     eq_(response.context['region_name'], region.name)
     eq_(response.context['people'].paginator.count, 1)
     eq_(response.context['people'].object_list[0], user_listed.userprofile)
开发者ID:ariestiyansyah,项目名称:mozillians,代码行数:27,代码来源:test_views_list.py


示例2: test_update_basket_task

    def test_update_basket_task(self, mock_basket):
        # When a user is created or added to a group, the appropriate
        # calls to update basket are made
        email = '[email protected]'
        token = 'footoken'
        mock_basket.lookup_user.return_value = {
            'email': email,
        }
        mock_basket.subscribe.return_value = {
            'token': token,
        }
        country = CountryFactory.create(name='Greece', code='gr')
        city = CityFactory.create(name='Athens', country=country)
        user = UserFactory.create(
            email=email,
            userprofile={'geo_country': country,
                         'geo_city': city})
        mock_basket.subscribe.reset_mock()  # forget that subscribe was called
        group = GroupFactory.create(name='Web Development',
                                    functional_area=True)
        GroupFactory.create(name='Marketing', functional_area=True)
        data = {'country': 'gr',
                'city': 'Athens',
                'WEB_DEVELOPMENT': 'Y',
                'MARKETING': 'N'}

        group.add_member(user.userprofile)

        # We just added a group, we should not need to subscribe anything
        ok_(not mock_basket.subscribe.called)
        # But we do need to update their phonebook record
        mock_basket.request.assert_called_with(
            'post', 'custom_update_phonebook', token=token, data=data)
开发者ID:Ruwan-Ranganath,项目名称:mozillians,代码行数:33,代码来源:test_tasks.py


示例3: test_location_city_region_optout

    def test_location_city_region_optout(self, mock_reverse_geocode):
        country = CountryFactory.create(mapbox_id='country1', name='Petoria')
        region = RegionFactory.create(country=country, mapbox_id='region1', name='Ontario')
        city = CityFactory.create(region=region, mapbox_id='city1', name='Toronto')
        mock_reverse_geocode.return_value = (country, region, city)
        user = UserFactory.create(email='[email protected]')
        data = {'full_name': user.userprofile.full_name,
                'email': user.email,
                'username': user.username,
                'lat': 40.005814,
                'lng': -3.42071,
                'externalaccount_set-MAX_NUM_FORMS': '1000',
                'externalaccount_set-INITIAL_FORMS': '0',
                'externalaccount_set-TOTAL_FORMS': '0',
                'language_set-MAX_NUM_FORMS': '1000',
                'language_set-INITIAL_FORMS': '0',
                'language_set-TOTAL_FORMS': '0',
            }
        data.update(_get_privacy_fields(MOZILLIANS))

        form = ProfileForm(data=data)
        eq_(form.is_valid(), True)
        eq_(form.instance.geo_country, country)
        eq_(form.instance.geo_region, None)
        eq_(form.instance.geo_city, None)
开发者ID:agbiyani,项目名称:mozillians,代码行数:25,代码来源:test_profile_edit.py


示例4: test_duplicate_results

    def test_duplicate_results(self):
        """Test that in case mapbox API returns a country already stored in DB
        with diferrent mapbox_id, we gracefully update all entries and foreign keys
        with the latest mapbox data."""

        country = CountryFactory.create(mapbox_id='42')
        user = UserFactory.create(userprofile={'geo_country': country})

        result = {
            'country': {
                'name': country.name,
                'id': '24'
            }
        }

        result_to_country(result)

        country_qs = Country.objects.filter(name=country.name)
        eq_(country_qs.count(), 1)
        eq_(country_qs[0].mapbox_id, '24')
        ok_(not Country.objects.filter(mapbox_id='42').exists())

        userprofile = UserProfile.objects.get(pk=user.userprofile.id)
        eq_(userprofile.geo_country.name, country.name)
        eq_(userprofile.geo_country.mapbox_id, '24')
开发者ID:Acidburn0zzz,项目名称:mozillians,代码行数:25,代码来源:test_lookup.py


示例5: test_get_country

 def test_get_country(self):
     country = CountryFactory.create(name='LA', code='IO')
     user = UserFactory.create(userprofile={'geo_country': country})
     data = UserProfileDetailedSerializer(user.userprofile).data
     country = {'code': 'IO',
                'value': 'LA',
                'privacy': 'Mozillians'}
     eq_(data['country'], country)
开发者ID:Xidharth,项目名称:mozillians,代码行数:8,代码来源:test_api_v2.py


示例6: test_search_country

 def test_search_country(self):
     country = CountryFactory.create(code="fr")
     user = UserFactory.create(userprofile={"geo_country": country})
     url = urlparams(self.mozilla_resource_url, country=user.userprofile.geo_country.code)
     client = Client()
     response = client.get(url, follow=True)
     data = json.loads(response.content)
     eq_(len(data["objects"]), 1)
     eq_(data["objects"][0]["id"], user.userprofile.id)
开发者ID:jensonk9,项目名称:mozillians,代码行数:9,代码来源:test_api.py


示例7: test_get_country

 def test_get_country(self):
     context = {'request': self.factory.get('/')}
     country = CountryFactory.create(name='LA', code='IO')
     user = UserFactory.create(userprofile={'geo_country': country})
     serializer = UserProfileDetailedSerializer(user.userprofile, context=context)
     country = {'code': 'IO',
                'value': 'LA',
                'privacy': 'Mozillians'}
     eq_(serializer.data['country'], country)
开发者ID:GVRGowtham,项目名称:mozillians,代码行数:9,代码来源:test_api_v2.py


示例8: test_update_country_name

 def test_update_country_name(self):
     # If country name has changed, we update our database
     country = CountryFactory.create()
     # Mapbox returns same country ID, but new improved country name
     new_name = 'Democratic Republic of %s' % country.name
     result = {'country': {'id': country.mapbox_id,
                           'name': new_name}}
     country = result_to_country(result)
     country = Country.objects.get(pk=country.pk)
     eq_(new_name, country.name)
开发者ID:TechnoAyan,项目名称:mozillians,代码行数:10,代码来源:test_lookup.py


示例9: test_list_mozillians_in_location_country_invalid_page

 def test_list_mozillians_in_location_country_invalid_page(self):
     country = CountryFactory.create()
     UserFactory.create(userprofile={'geo_country': country})
     UserFactory.create(userprofile={'geo_country': country})
     user = UserFactory.create()
     with self.login(user) as client:
         url = reverse('phonebook:list_country', kwargs={'country': country.name})
         url = urlparams(url, page='invalid')
         response = client.get(url, follow=True)
     eq_(response.status_code, 200)
     eq_(response.context['people'].number, 1)
开发者ID:ariestiyansyah,项目名称:mozillians,代码行数:11,代码来源:test_views_list.py


示例10: test_with_region

 def test_with_region(self):
     country = CountryFactory.create()
     result = {
         'province': {
             'name': 'NC',
             'id': 'ID'
         }
     }
     region = result_to_region(result, country)
     eq_('NC', region.name)
     eq_('ID', region.mapbox_id)
     eq_(country, region.country)
开发者ID:TechnoAyan,项目名称:mozillians,代码行数:12,代码来源:test_lookup.py


示例11: test_search_combined_skills_country

 def test_search_combined_skills_country(self):
     country = CountryFactory.create(code="fr")
     user_1 = UserFactory.create(userprofile={"geo_country": country})
     UserFactory.create(userprofile={"geo_country": country})
     skill = SkillFactory.create()
     user_1.userprofile.skills.add(skill)
     client = Client()
     url = urlparams(self.mozilla_resource_url, skills=skill.name, country=country.code)
     response = client.get(url, follow=True)
     data = json.loads(response.content)
     eq_(len(data["objects"]), 1)
     eq_(data["objects"][0]["id"], user_1.userprofile.id)
开发者ID:jensonk9,项目名称:mozillians,代码行数:12,代码来源:test_api.py


示例12: test_lat_lng_does_point_to_country

 def test_lat_lng_does_point_to_country(self):
     # If form includes lat/lng, must point to some country; succeeds if so
     user = UserFactory.create(email='[email protected]')
     data = model_to_dict(user.userprofile)
     # Try again, with valid data
     data['lng'] = 35.918596
     data['lat'] = -79.083799
     country = CountryFactory.create()
     form = LocationForm(data=data, instance=user.userprofile)
     with patch('mozillians.users.models.UserProfile.reverse_geocode'):
         # Pretend that geocoding does come up with a country
         user.userprofile.geo_country = country
         ok_(form.is_valid())
开发者ID:GVRGowtham,项目名称:mozillians,代码行数:13,代码来源:test_forms.py


示例13: test_update_name

 def test_update_name(self):
     # If region name has changed, we update our database
     country = CountryFactory.create()
     region = RegionFactory.create(country=country)
     new_name = 'New %s' % region.name
     result = {
         'province': {
             'name': new_name,
             'id': region.mapbox_id,
         }
     }
     result_to_region(result, country)
     region = Region.objects.get(pk=region.pk)
     eq_(new_name, region.name)
开发者ID:TechnoAyan,项目名称:mozillians,代码行数:14,代码来源:test_lookup.py


示例14: test_list_mozillians_in_location_country_second_page

 def test_list_mozillians_in_location_country_second_page(self):
     country = CountryFactory.create()
     UserFactory.create(userprofile={'geo_country': country})
     user_listed_2 = (UserFactory.create(userprofile={'geo_country': country}))
     user = UserFactory.create()
     with self.login(user) as client:
         url = reverse('phonebook:list_country', kwargs={'country': country.name})
         url = urlparams(url, page=2)
         response = client.get(url, follow=True)
     eq_(response.status_code, 200)
     eq_(response.context['people'].paginator.count, 2)
     eq_(response.context['people'].paginator.num_pages, 2)
     eq_(response.context['people'].number, 2)
     eq_(response.context['people'].object_list[0],
         user_listed_2.userprofile)
开发者ID:ariestiyansyah,项目名称:mozillians,代码行数:15,代码来源:test_views_list.py


示例15: test_list_mozillians_in_location_region_n_city_vouched

 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.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'], region.name)
     eq_(response.context['people'].paginator.count, 1)
     eq_(response.context['people'].object_list[0], user_listed.userprofile)
开发者ID:ariestiyansyah,项目名称:mozillians,代码行数:36,代码来源:test_views_list.py


示例16: test_with_city

 def test_with_city(self):
     country = CountryFactory.create()
     region = RegionFactory.create(country=country)
     result = {
         'city': {
             'name': 'Carrboro',
             'id': '1234',
             'lat': 0.0,
             'lon': 0.0,
         }
     }
     city = result_to_city(result, country, region)
     eq_('Carrboro', city.name)
     eq_('1234', city.mapbox_id)
     eq_(region, city.region)
     eq_(country, city.country)
开发者ID:TechnoAyan,项目名称:mozillians,代码行数:16,代码来源:test_lookup.py


示例17: test_country

 def test_country(self, mock_result_to_region, mock_result_to_country):
     # If country in results, builds a Country object, passes result to result_to_region
     result = {
         'country': {'id': 'mapbox_id', 'name': 'Petoria'},
     }
     mock_result_to_country.return_value = CountryFactory.create(mapbox_id='mapbox_id',
                                                                 name='Petoria')
     mock_result_to_region.return_value = None
     country, region, city = result_to_country_region_city(result)
     ok_(region is None)
     ok_(city is None)
     ok_(country is not None)
     ok_(isinstance(country, Country))
     eq_('mapbox_id', country.mapbox_id)
     eq_('Petoria', country.name)
     mock_result_to_region.assert_called_with(result, country)
开发者ID:TechnoAyan,项目名称:mozillians,代码行数:16,代码来源:test_lookup.py


示例18: setUp

 def setUp(self):
     self.user = UserFactory.create(email='[email protected]')
     self.data = {
         'full_name': self.user.userprofile.full_name,
         'email': self.user.email,
         'username': self.user.username,
         'lat': 40.005814,
         'lng': -3.42071,
         'externalaccount_set-MAX_NUM_FORMS': '1000',
         'externalaccount_set-INITIAL_FORMS': '0',
         'externalaccount_set-TOTAL_FORMS': '0',
         'language_set-MAX_NUM_FORMS': '1000',
         'language_set-INITIAL_FORMS': '0',
         'language_set-TOTAL_FORMS': '0',
     }
     self.country = CountryFactory.create(mapbox_id='country1', name='Petoria')
     self.region = RegionFactory.create(country=self.country, mapbox_id='reg1', name='Ontario')
     self.city = CityFactory.create(region=self.region, mapbox_id='city1', name='Toronto')
开发者ID:pace-noge,项目名称:mozillians,代码行数:18,代码来源:test_profile_edit.py


示例19: test_extract_document

    def test_extract_document(self):
        country = CountryFactory.create(name="Greece", code="gr")
        region = RegionFactory.create(name="attika", country=country)
        city = CityFactory.create(name="athens", region=region, country=country)
        user = UserFactory.create(
            userprofile={
                "geo_city": city,
                "geo_region": region,
                "allows_community_sites": False,
                "allows_mozilla_sites": False,
                "geo_country": country,
                "full_name": "Nikos Koukos",
                "bio": "This is my bio",
            }
        )
        profile = user.userprofile
        group_1 = GroupFactory.create()
        group_2 = GroupFactory.create()
        skill_1 = SkillFactory.create()
        skill_2 = SkillFactory.create()
        LanguageFactory.create(code="fr", userprofile=profile)
        LanguageFactory.create(code="en", userprofile=profile)
        group_1.add_member(profile)
        group_2.add_member(profile)
        profile.skills.add(skill_1)
        profile.skills.add(skill_2)

        result = UserProfile.extract_document(user.userprofile.id)
        ok_(isinstance(result, dict))
        eq_(result["id"], profile.id)
        eq_(result["is_vouched"], profile.is_vouched)
        eq_(result["region"], region.name)
        eq_(result["city"], city.name)
        eq_(result["allows_community_sites"], profile.allows_community_sites)
        eq_(result["allows_mozilla_sites"], profile.allows_mozilla_sites)
        eq_(result["country"], country.name)
        eq_(result["fullname"], profile.full_name.lower())
        eq_(result["name"], profile.full_name.lower())
        eq_(result["bio"], profile.bio)
        eq_(result["has_photo"], False)
        eq_(result["groups"], [group_1.name, group_2.name])
        eq_(result["skills"], [skill_1.name, skill_2.name])
        eq_(set(result["languages"]), set([u"en", u"fr", u"english", u"french", u"français"]))
开发者ID:J0WI,项目名称:mozillians,代码行数:43,代码来源:test_models.py


示例20: setUp

 def setUp(self):
     self.user = UserFactory.create(
         email="[email protected]", userprofile={"geo_country": None, "geo_region": None, "geo_city": None}
     )
     self.data = {
         "full_name": self.user.userprofile.full_name,
         "email": self.user.email,
         "username": self.user.username,
         "lat": 40.005814,
         "lng": -3.42071,
         "externalaccount_set-MAX_NUM_FORMS": "1000",
         "externalaccount_set-INITIAL_FORMS": "0",
         "externalaccount_set-TOTAL_FORMS": "0",
         "language_set-MAX_NUM_FORMS": "1000",
         "language_set-INITIAL_FORMS": "0",
         "language_set-TOTAL_FORMS": "0",
     }
     self.country = CountryFactory.create(mapbox_id="country1", name="Petoria")
     self.region = RegionFactory.create(country=self.country, mapbox_id="reg1", name="Ontario")
     self.city = CityFactory.create(region=self.region, mapbox_id="city1", name="Toronto")
开发者ID:jensonk9,项目名称:mozillians,代码行数:20,代码来源:test_profile_edit.py



注:本文中的mozillians.geo.tests.CountryFactory类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python models.Group类代码示例发布时间:2022-05-27
下一篇:
Python urlresolvers.reverse函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap