Exemplo n.º 1
0
 def test_transform_tshirt(self):
     user = UserFactory.create(userprofile={'tshirt': 9})
     data = UserProfileDetailedSerializer(user.userprofile).data
     tshirt = {'value': 9,
               'english': 'Straight-cut Large',
               'privacy': 'Privileged'}
     eq_(data['tshirt'], tshirt)
Exemplo n.º 2
0
 def test_transform_city(self):
     city = CityFactory.create(name='LA')
     user = UserFactory.create(userprofile={'geo_city': city})
     data = UserProfileDetailedSerializer(user.userprofile).data
     city = {'value': 'LA',
             'privacy': 'Mozillians'}
     eq_(data['city'], city)
Exemplo n.º 3
0
 def test_transform_bio(self):
     user = UserFactory.create(userprofile={'bio': '*foo*'})
     data = UserProfileDetailedSerializer(user.userprofile).data
     bio = {'value': '*foo*',
            'html': '<p><em>foo</em></p>',
            'privacy': 'Mozillians'}
     eq_(data['bio'], bio)
Exemplo n.º 4
0
 def test_transform_region(self):
     region = RegionFactory.create(name='LA')
     user = UserFactory.create(userprofile={'geo_region': region})
     data = UserProfileDetailedSerializer(user.userprofile).data
     region = {'value': 'LA',
               'privacy': 'Mozillians'}
     eq_(data['region'], region)
Exemplo n.º 5
0
 def test_transform_region(self):
     region = RegionFactory.create(name='LA')
     user = UserFactory.create(userprofile={'geo_region': region})
     context = {'request': self.factory.get('/')}
     serializer = UserProfileDetailedSerializer(user.userprofile,
                                                context=context)
     region = {'value': 'LA', 'privacy': 'Mozillians'}
     eq_(serializer.data['region'], region)
Exemplo n.º 6
0
 def test_transform_city(self):
     city = CityFactory.create(name='LA')
     user = UserFactory.create(userprofile={'geo_city': city})
     context = {'request': self.factory.get('/')}
     serializer = UserProfileDetailedSerializer(user.userprofile,
                                                context=context)
     city = {'value': 'LA', 'privacy': 'Mozillians'}
     eq_(serializer.data['city'], city)
Exemplo n.º 7
0
 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)
Exemplo n.º 8
0
 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)
Exemplo n.º 9
0
 def test_transform_tshirt(self):
     user = UserFactory.create(userprofile={'tshirt': 9})
     user.userprofile._groups = Group.objects.none()
     context = {'request': self.factory.get('/')}
     serializer = UserProfileDetailedSerializer(user.userprofile, context=context)
     tshirt = {'value': 9,
               'english': 'Straight-cut Large',
               'privacy': 'Privileged'}
     eq_(serializer.data['tshirt'], tshirt)
Exemplo n.º 10
0
 def test_transform_bio(self):
     user = UserFactory.create(userprofile={'bio': '*foo*'})
     user.userprofile._groups = Group.objects.none()
     context = {'request': self.factory.get('/')}
     serializer = UserProfileDetailedSerializer(user.userprofile, context=context)
     bio = {'value': '*foo*',
            'html': '<p><em>foo</em></p>',
            'privacy': 'Mozillians'}
     eq_(serializer.data['bio'], bio)
Exemplo n.º 11
0
 def test_get_country(self):
     context = {"request": self.factory.get("/")}
     country = CountryFactory.create(name="LA", code2="IO")
     user = UserFactory.create(userprofile={"country": country})
     user.userprofile._groups = Group.objects.none()
     serializer = UserProfileDetailedSerializer(user.userprofile,
                                                context=context)
     country = {"code": "IO", "value": "LA", "privacy": "Mozillians"}
     eq_(serializer.data["country"], country)
Exemplo n.º 12
0
 def test_transform_city(self):
     city = CityFactory.create(name="LA")
     user = UserFactory.create(userprofile={"city": city})
     user.userprofile._groups = Group.objects.none()
     context = {"request": self.factory.get("/")}
     serializer = UserProfileDetailedSerializer(user.userprofile,
                                                context=context)
     city = {"value": "LA", "privacy": "Mozillians"}
     eq_(serializer.data["city"], city)
Exemplo n.º 13
0
 def test_transform_region(self):
     region = RegionFactory.create(name="LA")
     user = UserFactory.create(userprofile={"region": region})
     user.userprofile._groups = Group.objects.none()
     context = {"request": self.factory.get("/")}
     serializer = UserProfileDetailedSerializer(user.userprofile,
                                                context=context)
     region = {"value": "LA", "privacy": "Mozillians"}
     eq_(serializer.data["region"], region)
Exemplo n.º 14
0
 def test_transform_timezone(self):
     user = UserFactory.create(userprofile={'timezone': 'Europe/Athens'})
     timezone_mock = Mock()
     timezone_mock.return_value = 99
     user.userprofile.timezone_offset = timezone_mock
     data = UserProfileDetailedSerializer(user.userprofile).data
     timezone = {'value': 'Europe/Athens',
                 'utc_offset': 99,
                 'privacy': 'Mozillians'}
     eq_(data['timezone'], timezone)
Exemplo n.º 15
0
 def test_transform_bio(self):
     user = UserFactory.create(userprofile={"bio": "*foo*"})
     user.userprofile._groups = Group.objects.none()
     context = {"request": self.factory.get("/")}
     serializer = UserProfileDetailedSerializer(user.userprofile,
                                                context=context)
     bio = {
         "value": "*foo*",
         "html": "<p><em>foo</em></p>",
         "privacy": "Mozillians"
     }
     eq_(serializer.data["bio"], bio)
Exemplo n.º 16
0
 def test_transform_timezone(self):
     user = UserFactory.create(userprofile={'timezone': 'Europe/Athens'})
     user.userprofile._groups = Group.objects.none()
     timezone_mock = Mock()
     timezone_mock.return_value = 99
     user.userprofile.timezone_offset = timezone_mock
     context = {'request': self.factory.get('/')}
     serializer = UserProfileDetailedSerializer(user.userprofile, context=context)
     timezone = {'value': 'Europe/Athens',
                 'utc_offset': 99,
                 'privacy': 'Mozillians'}
     eq_(serializer.data['timezone'], timezone)
Exemplo n.º 17
0
 def test_transform_tshirt(self):
     user = UserFactory.create(userprofile={"tshirt": 9})
     user.userprofile._groups = Group.objects.none()
     context = {"request": self.factory.get("/")}
     serializer = UserProfileDetailedSerializer(user.userprofile,
                                                context=context)
     tshirt = {
         "value": 9,
         "english": "Straight-cut Large",
         "privacy": "Private"
     }
     eq_(serializer.data["tshirt"], tshirt)
Exemplo n.º 18
0
 def test_alternate_emails_idp(self):
     user = UserFactory.create()
     IdpProfile.objects.create(profile=user.userprofile,
                               auth0_user_id='ad|[email protected]',
                               email='*****@*****.**',
                               privacy=1)
     user.userprofile._groups = Group.objects.none()
     context = {'request': self.factory.get('/')}
     serializer = UserProfileDetailedSerializer(user.userprofile,
                                                context=context)
     eq_(len(serializer.data['alternate_emails']), 1)
     eq_(serializer.data['alternate_emails'][0]['email'], '*****@*****.**')
     eq_(serializer.data['alternate_emails'][0]['privacy'], 'Private')
Exemplo n.º 19
0
 def test_alternate_emails_legacy(self):
     user = UserFactory.create()
     ExternalAccount.objects.create(type=ExternalAccount.TYPE_EMAIL,
                                    user=user.userprofile,
                                    identifier='*****@*****.**',
                                    privacy=3)
     user.userprofile._groups = Group.objects.none()
     context = {'request': self.factory.get('/')}
     serializer = UserProfileDetailedSerializer(user.userprofile,
                                                context=context)
     eq_(len(serializer.data['alternate_emails']), 1)
     eq_(serializer.data['alternate_emails'][0]['email'], '*****@*****.**')
     eq_(serializer.data['alternate_emails'][0]['privacy'], 'Mozillians')
Exemplo n.º 20
0
 def test_alternate_emails_legacy(self):
     user = UserFactory.create()
     ExternalAccount.objects.create(
         type=ExternalAccount.TYPE_EMAIL,
         user=user.userprofile,
         identifier="*****@*****.**",
         privacy=3,
     )
     user.userprofile._groups = Group.objects.none()
     context = {"request": self.factory.get("/")}
     serializer = UserProfileDetailedSerializer(user.userprofile,
                                                context=context)
     eq_(len(serializer.data["alternate_emails"]), 1)
     eq_(serializer.data["alternate_emails"][0]["email"], "*****@*****.**")
     eq_(serializer.data["alternate_emails"][0]["privacy"], "Mozillians")
Exemplo n.º 21
0
 def test_alternate_emails_idp(self):
     user = UserFactory.create()
     IdpProfile.objects.create(
         profile=user.userprofile,
         auth0_user_id="ad|[email protected]",
         email="*****@*****.**",
         privacy=1,
     )
     user.userprofile._groups = Group.objects.none()
     context = {"request": self.factory.get("/")}
     serializer = UserProfileDetailedSerializer(user.userprofile,
                                                context=context)
     eq_(len(serializer.data["alternate_emails"]), 1)
     eq_(serializer.data["alternate_emails"][0]["email"], "*****@*****.**")
     eq_(serializer.data["alternate_emails"][0]["privacy"], "Private")
Exemplo n.º 22
0
 def test_transform_timezone(self):
     user = UserFactory.create(userprofile={"timezone": "Europe/Athens"})
     user.userprofile._groups = Group.objects.none()
     timezone_mock = Mock()
     timezone_mock.return_value = 99
     user.userprofile.timezone_offset = timezone_mock
     context = {"request": self.factory.get("/")}
     serializer = UserProfileDetailedSerializer(user.userprofile,
                                                context=context)
     timezone = {
         "value": "Europe/Athens",
         "utc_offset": 99,
         "privacy": "Mozillians"
     }
     eq_(serializer.data["timezone"], timezone)
Exemplo n.º 23
0
    def test_transform_photo(self):
        def _get_url(dimensions):
            return dimensions

        user = UserFactory.create(userprofile={'timezone': 'Europe/Athens'})
        get_photo_url_mock = Mock()
        get_photo_url_mock.side_effect = _get_url
        user.userprofile.get_photo_url = get_photo_url_mock
        data = UserProfileDetailedSerializer(user.userprofile).data
        photo = {'value': '300x300',
                 '150x150': '150x150',
                 '300x300': '300x300',
                 '500x500': '500x500',
                 'privacy': 'Mozillians'}
        eq_(data['photo'], photo)
Exemplo n.º 24
0
    def test_transform_photo(self):
        def _get_url(dimensions):
            return dimensions

        user = UserFactory.create(userprofile={'timezone': 'Europe/Athens'})
        user.userprofile._groups = Group.objects.none()
        context = {'request': self.factory.get('/')}
        get_photo_url_mock = Mock()
        get_photo_url_mock.side_effect = _get_url
        user.userprofile.get_photo_url = get_photo_url_mock
        serializer = UserProfileDetailedSerializer(user.userprofile, context=context)
        photo = {'value': '300x300',
                 '150x150': '150x150',
                 '300x300': '300x300',
                 '500x500': '500x500',
                 'privacy': 'Mozillians'}
        eq_(serializer.data['photo'], photo)
Exemplo n.º 25
0
    def test_transform_photo(self):
        def _get_url(dimensions):
            return dimensions

        user = UserFactory.create(userprofile={"timezone": "Europe/Athens"})
        user.userprofile._groups = Group.objects.none()
        context = {"request": self.factory.get("/")}
        get_photo_url_mock = Mock()
        get_photo_url_mock.side_effect = _get_url
        user.userprofile.get_photo_url = get_photo_url_mock
        serializer = UserProfileDetailedSerializer(user.userprofile,
                                                   context=context)
        photo = {
            "value": "300x300",
            "150x150": "150x150",
            "300x300": "300x300",
            "500x500": "500x500",
            "privacy": "Mozillians",
        }
        eq_(serializer.data["photo"], photo)