Skip to content

Commit

Permalink
Made a small fix
Browse files Browse the repository at this point in the history
  • Loading branch information
BrentBlanckaert committed Dec 12, 2024
1 parent e14c758 commit 65fb097
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 13 deletions.
15 changes: 9 additions & 6 deletions tested/nat_translation.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,12 +120,15 @@ def translate_contexts(contexts: list, language: str) -> list:
result = []
for context in contexts:
assert isinstance(context, dict)
print(f"context: {context}")
if "script" in context or "testcases" in context:
key_to_set = "script" if "script" in context else "testcases"
raw_testcases = context.get(key_to_set)
assert isinstance(raw_testcases, list)
context[key_to_set] = translate_testcases(raw_testcases, language)
key_to_set = "script" if "script" in context else "testcases"
raw_testcases = context.get(key_to_set)
assert isinstance(raw_testcases, list)
context[key_to_set] = translate_testcases(raw_testcases, language)
if "files" in context:
files = context.get("files")
if isinstance(files, NaturalLanguageMap):
assert language in files
context["files"] = files[language]
result.append(context)

return result
Expand Down
14 changes: 7 additions & 7 deletions tests/test_dsl_yaml.py
Original file line number Diff line number Diff line change
Expand Up @@ -1360,11 +1360,13 @@ def test_natural_translate_unit_test():
description: !natural_language
en: "Ten"
nl: "Tien"
files:
- name: "file.txt"
url: "media/workdir/file.txt"
- name: "fileNL.txt"
url: "media/workdir/fileNL.txt"
files: !natural_language
en:
- name: "file.txt"
url: "media/workdir/file.txt"
nl:
- name: "fileNL.txt"
url: "media/workdir/fileNL.txt"
- testcases:
- statement: !natural_language
en: 'result = Trying(11)'
Expand Down Expand Up @@ -1400,8 +1402,6 @@ def test_natural_translate_unit_test():
files:
- name: file.txt
url: media/workdir/file.txt
- name: fileNL.txt
url: media/workdir/fileNL.txt
- testcases:
- statement: result = Trying(11)
- expression: result
Expand Down

0 comments on commit 65fb097

Please sign in to comment.