Exemplo n.º 1
0
 def test_change_locale_to_hyphen(self):
     """
     Should convert Facebook's underscore locales to hyphen locales.
     """
     payload = tests.create_payload(locale='en_GB')
     signed_request = tests.create_signed_request(payload)
     self.request.REQUEST['signed_request'] = signed_request
     unwrapped_payload = utils.unwrap_signed_request(self.request)
     eq_(unwrapped_payload['user']['locale'], 'en-GB')
Exemplo n.º 2
0
 def test_change_locale_to_hyphen(self):
     """
     Should convert Facebook's underscore locales to hyphen locales.
     """
     payload = tests.create_payload(locale="en_GB")
     signed_request = tests.create_signed_request(payload)
     self.request.REQUEST["signed_request"] = signed_request
     unwrapped_payload = utils.unwrap_signed_request(self.request)
     eq_(unwrapped_payload["user"]["locale"], "en-GB")
Exemplo n.º 3
0
 def test_change_locale_to_hyphen(self):
     """
     Should convert Facebook's underscore locales to hyphen locales.
     """
     payload = tests.create_payload(locale='en_GB')
     signed_request = tests.create_signed_request(payload)
     self.request.REQUEST['signed_request'] = signed_request
     unwrapped_payload = utils.unwrap_signed_request(self.request)
     eq_(unwrapped_payload['user']['locale'], 'en-GB')
Exemplo n.º 4
0
 def test_normal_unwrap(self):
     """
     Should unwrap and return the encoded dictionary.
     """
     payload = tests.create_payload(locale='en_GB')
     signed_request = tests.create_signed_request(payload)
     self.request.REQUEST['signed_request'] = signed_request
     # Use hyphen in payload's locale to match util's transformation
     payload['user']['locale'] = 'en-GB'
     eq_(utils.unwrap_signed_request(self.request), payload)
Exemplo n.º 5
0
 def test_normal_unwrap(self):
     """
     Should unwrap and return the encoded dictionary.
     """
     payload = tests.create_payload(locale="en_GB")
     signed_request = tests.create_signed_request(payload)
     self.request.REQUEST["signed_request"] = signed_request
     # Use hyphen in payload's locale to match util's transformation
     payload["user"]["locale"] = "en-GB"
     eq_(utils.unwrap_signed_request(self.request), payload)
Exemplo n.º 6
0
 def test_normal_unwrap(self):
     """
     Should unwrap and return the encoded dictionary.
     """
     payload = tests.create_payload(locale='en_GB')
     signed_request = tests.create_signed_request(payload)
     self.request.REQUEST['signed_request'] = signed_request
     # Use hyphen in payload's locale to match util's transformation
     payload['user']['locale'] = 'en-GB'
     eq_(utils.unwrap_signed_request(self.request), payload)
Exemplo n.º 7
0
def create_response(view, locale='en_US', remove_locale=False, get=None,
                    app_data=None):
    payload = tests.create_payload(locale=locale, app_data=app_data)
    if remove_locale:
        del payload['user']['locale']

    request_factory = RequestFactory()
    request = request_factory.post(tests.DUMMY_PATH,
        {'signed_request': tests.create_signed_request(payload)})
    if get:
        query_dict = QueryDict('').copy()
        query_dict.update(get)
        request.GET = query_dict

    return view(request), request
Exemplo n.º 8
0
def create_response(view,
                    locale='en_US',
                    remove_locale=False,
                    get=None,
                    app_data=None):
    payload = tests.create_payload(locale=locale, app_data=app_data)
    if remove_locale:
        del payload['user']['locale']

    request_factory = RequestFactory()
    request = request_factory.post(
        tests.DUMMY_PATH,
        {'signed_request': tests.create_signed_request(payload)})
    if get:
        query_dict = QueryDict('').copy()
        query_dict.update(get)
        request.GET = query_dict

    return view(request), request