本文整理汇总了Python中mozillians.phonebook.tests._get_privacy_fields函数的典型用法代码示例。如果您正苦于以下问题:Python _get_privacy_fields函数的具体用法?Python _get_privacy_fields怎么用?Python _get_privacy_fields使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了_get_privacy_fields函数的18个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: test_date_mozillian_validates_in_different_locales
def test_date_mozillian_validates_in_different_locales(self):
"""Tests if date_mozillian validates when profile language is e.g. 'es'.
Related bug 914448.
"""
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,
'date_mozillian_year': '2013',
'date_mozillian_month': '1',
'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',
'contribution_section': ''
}
data.update(_get_privacy_fields(MOZILLIANS))
url = reverse('phonebook:profile_edit', prefix='/es/')
with self.login(user) as client:
response = client.post(url, data=data, follow=True)
eq_(response.status_code, 200)
开发者ID:Acidburn0zzz,项目名称:mozillians,代码行数:28,代码来源:test_views_misc.py
示例2: test_wrong_section
def test_wrong_section(self):
"""When a wrong section is given in request.POST, 404 is raised."""
user = UserFactory.create(vouched=False)
with override_script_prefix('/en-US/'):
url = reverse('phonebook:profile_edit')
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-0-id': '',
'language_set-0-userprofile': '',
'language_set-0-code': 'en',
'language_set-1-id': '',
'language_set-1-userprofile': '',
'language_set-1-code': 'fr',
'language_set-MAX_NUM_FORMS': '1000',
'language_set-INITIAL_FORMS': '0',
'language_set-TOTAL_FORMS': '2',
'foo_section': '',
}
data.update(_get_privacy_fields(MOZILLIANS))
with self.login(user) as client:
response = client.post(url, data=data, follow=True)
eq_(response.status_code, 404)
开发者ID:akatsoulas,项目名称:mozillians,代码行数:30,代码来源:test_profile_edit.py
示例3: test_languages_get_saved
def test_languages_get_saved(self):
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-0-id': '',
'language_set-0-userprofile': '',
'language_set-0-code': 'en',
'language_set-1-id': '',
'language_set-1-userprofile': '',
'language_set-1-code': 'fr',
'language_set-MAX_NUM_FORMS': '1000',
'language_set-INITIAL_FORMS': '0',
'language_set-TOTAL_FORMS': '2',
'languages_section': ''
}
data.update(_get_privacy_fields(MOZILLIANS))
with override_script_prefix('/en-US/'):
url = reverse('phonebook:profile_edit')
with self.login(user) as client:
response = client.post(url, data=data, follow=True)
eq_(response.status_code, 200)
profile = UserProfile.objects.get(pk=user.userprofile.pk)
eq_(set(profile.language_set.values_list('code', flat=True)), set(['en', 'fr']))
开发者ID:akatsoulas,项目名称:mozillians,代码行数:32,代码来源:test_profile_edit.py
示例4: test_succesful_registration
def test_succesful_registration(self, info_mock):
user = UserFactory.create(first_name='', last_name='')
ok_(not UserProfile.objects.filter(full_name='foo bar').exists())
country = Country.objects.get(name='Greece')
with override_script_prefix('/en-US/'):
url = reverse('phonebook:profile_edit')
data = {
'full_name': 'foo bar',
'email': '[email protected]',
'username': 'foobar',
'country': country.id,
'optin': True,
'registration_section': '',
'g-recaptcha-response': 'PASSED'
}
data.update(_get_privacy_fields(MOZILLIANS))
with self.login(user) as client:
response = client.post(url, data, follow=True)
eq_(response.status_code, 200)
ok_(info_mock.called)
ok_(UserProfile.objects.get(full_name='foo bar'))
def tearDown(self):
del os.environ['NORECAPTCHA_TESTING']
开发者ID:akatsoulas,项目名称:mozillians,代码行数:26,代码来源:test_profile_edit.py
示例5: test_date_mozillian_validates_in_different_locales
def test_date_mozillian_validates_in_different_locales(self):
"""Tests if date_mozillian validates when profile language is e.g. 'es'.
Related bug 914448.
"""
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,
"date_mozillian_year": "2013",
"date_mozillian_month": "1",
"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))
url = reverse("phonebook:profile_edit", prefix="/es/")
with self.login(user) as client:
response = client.post(url, data=data, follow=True)
eq_(response.status_code, 200)
开发者ID:kaushikmit,项目名称:mozillians,代码行数:27,代码来源:test_views_misc.py
示例6: 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
示例7: test_languages_get_saved
def test_languages_get_saved(self):
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-0-id": "",
"language_set-0-userprofile": "",
"language_set-0-code": "en",
"language_set-1-id": "",
"language_set-1-userprofile": "",
"language_set-1-code": "fr",
"language_set-MAX_NUM_FORMS": "1000",
"language_set-INITIAL_FORMS": "0",
"language_set-TOTAL_FORMS": "2",
}
data.update(_get_privacy_fields(MOZILLIANS))
url = reverse("phonebook:profile_edit", prefix="/en-US/")
with self.login(user) as client:
response = client.post(url, data=data, follow=True)
eq_(response.status_code, 200)
profile = UserProfile.objects.get(pk=user.userprofile.pk)
eq_(set(profile.language_set.values_list("code", flat=True)), set(["en", "fr"]))
开发者ID:jensonk9,项目名称:mozillians,代码行数:30,代码来源:test_profile_edit.py
示例8: test_location_region_required_if_city
def test_location_region_required_if_city(self, mock_reverse_geocode):
mock_reverse_geocode.return_value = (self.country, self.region, self.city)
self.data.update({'savecity': True})
self.data.update(_get_privacy_fields(MOZILLIANS))
form = LocationForm(data=self.data)
ok_(not form.is_valid())
ok_('saveregion' in form.errors)
开发者ID:Acidburn0zzz,项目名称:mozillians,代码行数:8,代码来源:test_profile_edit.py
示例9: test_location_city_region_optout
def test_location_city_region_optout(self, mock_reverse_geocode):
mock_reverse_geocode.return_value = (self.country, self.region, self.city)
self.data.update(_get_privacy_fields(MOZILLIANS))
form = LocationForm(data=self.data)
eq_(form.is_valid(), True)
eq_(form.instance.geo_country, self.country)
eq_(form.instance.geo_region, None)
eq_(form.instance.geo_city, None)
开发者ID:Acidburn0zzz,项目名称:mozillians,代码行数:8,代码来源:test_profile_edit.py
示例10: test_location_region_required_if_city
def test_location_region_required_if_city(self, mock_reverse_geocode):
mock_reverse_geocode.return_value = (self.country, self.region, self.city)
self.data.update({'savecity': True})
self.data.update(_get_privacy_fields(MOZILLIANS))
form = ProfileForm(data=self.data)
with self.assertRaises(ValidationError):
ok_(not form.is_valid())
form.clean()
开发者ID:pace-noge,项目名称:mozillians,代码行数:9,代码来源:test_profile_edit.py
示例11: test_location_api_not_called_when_latlang_unchanged
def test_location_api_not_called_when_latlang_unchanged(self, mock_reverse_geocode):
mock_reverse_geocode.return_value = (self.country, self.region, self.city)
self.data["lng"] = self.user.userprofile.lng
self.data["lat"] = self.user.userprofile.lat
self.data.update(_get_privacy_fields(MOZILLIANS))
initial = {"lat": self.user.userprofile.lat, "lng": self.user.userprofile.lng}
form = ProfileForm(data=self.data, initial=initial)
ok_(form.is_valid())
ok_(not mock_reverse_geocode.called)
开发者ID:jensonk9,项目名称:mozillians,代码行数:10,代码来源:test_profile_edit.py
示例12: test_location_profile_save_connectionerror
def test_location_profile_save_connectionerror(self, mock_requests):
mock_requests.get.return_value.raise_for_status.side_effect = ConnectionError
error_country = Country.objects.create(name='Error', mapbox_id='geo_error')
self.data.update(_get_privacy_fields(MOZILLIANS))
url = reverse('phonebook:profile_edit', prefix='/en-US/')
with self.login(self.user) as client:
response = client.post(url, data=self.data, follow=True)
userprofile = UserProfile.objects.get(user=self.user)
eq_(response.status_code, 200)
eq_(userprofile.geo_country, error_country)
开发者ID:Acidburn0zzz,项目名称:mozillians,代码行数:11,代码来源:test_profile_edit.py
示例13: test_location_api_called_when_latlng_changed
def test_location_api_called_when_latlng_changed(self, mock_reverse_geocode):
mock_reverse_geocode.return_value = (self.country, self.region, self.city)
self.data['lat'] = 40
self.data['lng'] = 20
self.data.update(_get_privacy_fields(MOZILLIANS))
initial = {
'lat': self.user.userprofile.lat,
'lng': self.user.userprofile.lng
}
form = LocationForm(data=self.data, initial=initial)
ok_(form.is_valid())
ok_(mock_reverse_geocode.called)
开发者ID:Acidburn0zzz,项目名称:mozillians,代码行数:13,代码来源:test_profile_edit.py
示例14: test_succesful_registration
def test_succesful_registration(self, info_mock):
user = UserFactory.create(first_name='', last_name='')
url = reverse('phonebook:profile_edit', prefix='/en-US/')
data = {
'full_name': 'foo bar',
'email': '[email protected]',
'username': 'foobar',
'lat': 40.005814,
'lng': -3.42071,
'optin': True,
'registration_section': ''
}
data.update(_get_privacy_fields(MOZILLIANS))
with self.login(user) as client:
response = client.post(url, data, follow=True)
eq_(response.status_code, 200)
ok_(info_mock.called)
开发者ID:Acidburn0zzz,项目名称:mozillians,代码行数:18,代码来源:test_profile_edit.py
示例15: test_location_data_required
def test_location_data_required(self):
user = UserFactory.create(email='[email protected]')
data = {'full_name': user.userprofile.full_name,
'email': user.email,
'username': user.username,
'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(), False)
ok_(form.errors.get('lat'))
ok_(form.errors.get('lng'))
开发者ID:agbiyani,项目名称:mozillians,代码行数:18,代码来源:test_profile_edit.py
示例16: _upload_photo
def _upload_photo(self, user, file_path):
"""Helper for the next methods."""
data = {'full_name': user.userprofile.full_name,
'email': user.email,
'country': user.userprofile.country,
'username': user.username,
'photo': open(file_path, 'rb'),
'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))
url = reverse('phonebook:profile_edit', prefix='/en-US/')
with self.login(user) as client:
response = client.post(url, data=data, follow=True)
eq_(response.status_code, 200)
开发者ID:CodeBreaker24,项目名称:mozillians,代码行数:19,代码来源:test_views_misc.py
示例17: test_location_data_required
def test_location_data_required(self):
user = UserFactory.create(email="[email protected]")
data = {
"full_name": user.userprofile.full_name,
"email": user.email,
"username": user.username,
"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(), False)
ok_(form.errors.get("lat"))
ok_(form.errors.get("lng"))
开发者ID:jensonk9,项目名称:mozillians,代码行数:19,代码来源:test_profile_edit.py
示例18: _upload_photo
def _upload_photo(self, user, file_path):
"""Helper for the next methods."""
data = {
"full_name": user.userprofile.full_name,
"email": user.email,
"country": user.userprofile.country,
"username": user.username,
"photo": open(file_path, "rb"),
"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))
url = reverse("phonebook:profile_edit", prefix="/en-US/")
with self.login(user) as client:
response = client.post(url, data=data, follow=True)
eq_(response.status_code, 200)
开发者ID:J0WI,项目名称:mozillians,代码行数:20,代码来源:test_views_misc.py
注:本文中的mozillians.phonebook.tests._get_privacy_fields函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论