Fix language specification

Old API docs claimed to require ISO 639-2 format, testing determines
that that ISO 639-1 is required instead.
This commit is contained in:
Ivan Habunek 2022-12-11 23:03:08 +01:00
parent c3bf0f3bb0
commit 47be3a762a
No known key found for this signature in database
GPG Key ID: CDBD63C43A30BB95
3 changed files with 17 additions and 5 deletions

View File

@ -61,7 +61,7 @@ def test_post_with_options(mock_post, mock_uuid, capsys):
'--sensitive',
'--spoiler-text', 'Spoiler!',
'--reply-to', '123a',
'--language', 'hrv',
'--language', 'hr',
]
mock_post.return_value = MockResponse({
@ -77,7 +77,7 @@ def test_post_with_options(mock_post, mock_uuid, capsys):
'sensitive': True,
'spoiler_text': "Spoiler!",
'in_reply_to_id': '123a',
'language': 'hrv',
'language': 'hr',
}, headers={"Idempotency-Key": "up-the-irons"})
out, err = capsys.readouterr()

View File

@ -192,6 +192,18 @@ def test_post_scheduled_in(app, user, run):
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):
assets_dir = path.realpath(path.join(path.dirname(__file__), "assets"))

View File

@ -17,10 +17,10 @@ VISIBILITY_CHOICES = ['public', 'unlisted', 'private', 'direct']
def language(value):
"""Validates the language parameter"""
if len(value) != 3:
if len(value) != 2:
raise ArgumentTypeError(
"Invalid language specified: '{}'. Expected a 3 letter "
"abbreviation according to ISO 639-2 standard.".format(value)
"Invalid language. Expected a 2 letter abbreviation according to "
"the ISO 639-1 standard."
)
return value