kopia lustrzana https://github.com/ihabunek/toot
Fix language specification
Old API docs claimed to require ISO 639-2 format, testing determines that that ISO 639-1 is required instead.pull/268/head
rodzic
c3bf0f3bb0
commit
47be3a762a
|
@ -61,7 +61,7 @@ def test_post_with_options(mock_post, mock_uuid, capsys):
|
||||||
'--sensitive',
|
'--sensitive',
|
||||||
'--spoiler-text', 'Spoiler!',
|
'--spoiler-text', 'Spoiler!',
|
||||||
'--reply-to', '123a',
|
'--reply-to', '123a',
|
||||||
'--language', 'hrv',
|
'--language', 'hr',
|
||||||
]
|
]
|
||||||
|
|
||||||
mock_post.return_value = MockResponse({
|
mock_post.return_value = MockResponse({
|
||||||
|
@ -77,7 +77,7 @@ def test_post_with_options(mock_post, mock_uuid, capsys):
|
||||||
'sensitive': True,
|
'sensitive': True,
|
||||||
'spoiler_text': "Spoiler!",
|
'spoiler_text': "Spoiler!",
|
||||||
'in_reply_to_id': '123a',
|
'in_reply_to_id': '123a',
|
||||||
'language': 'hrv',
|
'language': 'hr',
|
||||||
}, headers={"Idempotency-Key": "up-the-irons"})
|
}, headers={"Idempotency-Key": "up-the-irons"})
|
||||||
|
|
||||||
out, err = capsys.readouterr()
|
out, err = capsys.readouterr()
|
||||||
|
|
|
@ -192,6 +192,18 @@ def test_post_scheduled_in(app, user, run):
|
||||||
assert delta.total_seconds() < 5
|
assert delta.total_seconds() < 5
|
||||||
|
|
||||||
|
|
||||||
|
def test_post_language(app, user, run):
|
||||||
|
out = run("post", "test", "--language", "hr")
|
||||||
|
status_id = _posted_status_id(out)
|
||||||
|
status = api.fetch_status(app, user, status_id)
|
||||||
|
assert status["language"] == "hr"
|
||||||
|
|
||||||
|
out = run("post", "test", "--language", "zh")
|
||||||
|
status_id = _posted_status_id(out)
|
||||||
|
status = api.fetch_status(app, user, status_id)
|
||||||
|
assert status["language"] == "zh"
|
||||||
|
|
||||||
|
|
||||||
def test_media_attachments(app, user, run):
|
def test_media_attachments(app, user, run):
|
||||||
assets_dir = path.realpath(path.join(path.dirname(__file__), "assets"))
|
assets_dir = path.realpath(path.join(path.dirname(__file__), "assets"))
|
||||||
|
|
||||||
|
|
|
@ -17,10 +17,10 @@ VISIBILITY_CHOICES = ['public', 'unlisted', 'private', 'direct']
|
||||||
|
|
||||||
def language(value):
|
def language(value):
|
||||||
"""Validates the language parameter"""
|
"""Validates the language parameter"""
|
||||||
if len(value) != 3:
|
if len(value) != 2:
|
||||||
raise ArgumentTypeError(
|
raise ArgumentTypeError(
|
||||||
"Invalid language specified: '{}'. Expected a 3 letter "
|
"Invalid language. Expected a 2 letter abbreviation according to "
|
||||||
"abbreviation according to ISO 639-2 standard.".format(value)
|
"the ISO 639-1 standard."
|
||||||
)
|
)
|
||||||
|
|
||||||
return value
|
return value
|
||||||
|
|
Ładowanie…
Reference in New Issue