-
Notifications
You must be signed in to change notification settings - Fork 206
SG-12945 + SG-12581 : Added localized param to Shotgun object #208
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
1c0014c
151afde
1cfd074
16744ca
f550358
756cfcb
c695d7f
e44943f
f51d242
c5b3647
d8f3443
7f37165
a688c7a
053ccb2
53f98ca
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -184,6 +184,28 @@ def test_authorization(self): | |
expected = "Basic " + b64encode(urllib.parse.unquote(login_password)).strip() | ||
self.assertEqual(expected, headers.get("Authorization")) | ||
|
||
def test_localization_header_default(self): | ||
"""Localization header not passed to server without explicitly setting SG localization config to True""" | ||
self.sg.info() | ||
|
||
args, _ = self.sg._http_request.call_args | ||
(_, _, _, headers) = args | ||
expected_header_value = "auto" | ||
|
||
self.assertEqual(None, headers.get("locale")) | ||
|
||
def test_localization_header_when_localized(self): | ||
"""Localization header passed to server when setting SG localization config to True""" | ||
self.sg.config.localized = True | ||
|
||
self.sg.info() | ||
|
||
args, _ = self.sg._http_request.call_args | ||
(_, _, _, headers) = args | ||
expected_header_value = "auto" | ||
|
||
self.assertEqual("auto", headers.get("locale")) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we probably should test whether the schema content coming back from the server is actually localised. Is this easy to do? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's not hard to do (not sure if we can set the site language from the API, though) but then it would test the server, not the client. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. that makes sense! I was thinking about testing the "receiving end" of the transport, eg. asserting that the received object is a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If I understand correctly, since the encoding/decoding of received objects returned from |
||
|
||
def test_user_agent(self): | ||
"""User-Agent passed to server""" | ||
# test default user agent | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is a UTF-8 encoded string, right? I think we should mention that as part of the docs.
Also, it would be great if @willis102 did a quick CR on this to make sure that this approach still make sense for Python 3!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So yes, this is returning a UTF-8 encoded string in Python 2, and a str in Python 3 (meaning in Python 3 we're not dealing with bytes.) It might be good to mention in the documentation that for Python 2/3 compatibility you can decode the string using
shotgun_api3.lib.six.ensure_text()
, ensuring that the Python3 str object is handled properly. I ran your test code in the branch on Python 2 and 3 and it behaved as I would expect.So, my opinion is that this would be good to mention in the docs but that the current behavior is correct.