Download tasks/data/forward/adwaith-rajesh__loafang.2ccea64/tests/test_patch.diff from Lego-X/ProgramGen: direct link, hf CLI and curl.
- Browser
- Download file 2.71 kB
-
https://huggingface.co/datasets/Lego-X/ProgramGen/resolve/main/tasks/data/forward/adwaith-rajesh__loafang.2ccea64/tests/test_patch.diff
- Command line
-
hf download hf://datasets/Lego-X/ProgramGen/tasks/data/forward/adwaith-rajesh__loafang.2ccea64/tests/test_patch.diff
-
curl -L -o test_patch.diff https://huggingface.co/datasets/Lego-X/ProgramGen/resolve/main/tasks/data/forward/adwaith-rajesh__loafang.2ccea64/tests/test_patch.diff
2.71 kB
| diff --git a/tests/__init__.py b/tests/__init__.py | |
| new file mode 100644 | |
| index 0000000..e69de29 | |
| diff --git a/tests/test_main.py b/tests/test_main.py | |
| new file mode 100644 | |
| --- /dev/null | |
| +++ b/tests/test_main.py | |
| +def test_main(): | |
| + assert True | |
| diff --git a/tests/test_parsers.py b/tests/test_parsers.py | |
| new file mode 100644 | |
| --- /dev/null | |
| +++ b/tests/test_parsers.py | |
| +import pytest | |
| + | |
| +from loafang._dataclasses import Header | |
| +from loafang._parsers import HeaderParser | |
| + | |
| + | |
| +@pytest.mark.parametrize( | |
| + 'input,output', | |
| + ( | |
| + ("GET:test-id:pe", (Header("GET", "test-id", "pe"), None, None)), | |
| + ("GET:test-id:", (Header("GET", "test-id", None), None, None)), | |
| + ("GET:test-id", (Header("GET", "test-id", None), None, None)), | |
| + ("POST:add-user:", (Header("POST", "add-user", None), None, None)), | |
| + ("DELETE:remove-mail", (Header("DELETE", "remove-mail", None), None, None)), | |
| + ) | |
| +) | |
| +def test_header_parser_pass(input, output): | |
| + assert HeaderParser(input).parse() == output | |
| + | |
| + | |
| +@pytest.mark.parametrize( | |
| + 'input,output', | |
| + ( | |
| + ("get", (None, 604, "Missing ID.")), | |
| + ("GETS", (None, 604, "Missing ID.")), | |
| + ("GETS:test-id", (None, 602, "The method 'GETS' does not exists.")), | |
| + ("get:test-id", (None, 602, "The method 'get' does not exists.")), | |
| + ("", (None, 601, "The header cannot be empty.")), | |
| + ("GET:id:pe:test", (None, 600, "The header cannot be more than 3 parts.")), | |
| + ("GET:id:p4", (None, 603, "The property key 'p4' does not exists.")), | |
| + ) | |
| +) | |
| +def test_header_parser_error(input, output): | |
| + assert HeaderParser(input).parse() == output | |
| diff --git a/tests/test_query.py b/tests/test_query.py | |
| new file mode 100644 | |
| --- /dev/null | |
| +++ b/tests/test_query.py | |
| +import pytest | |
| + | |
| +from loafang.query import gen_arg_name | |
| + | |
| + | |
| +@pytest.mark.parametrize( | |
| + 'input,output', | |
| + ( | |
| + ("name", "--name"), | |
| + ("-name", "--name"), | |
| + ("---name", "--name"), | |
| + ("c42", "--c42"), | |
| + ("42", "--42"), | |
| + | |
| + ) | |
| +) | |
| +def test_gen_arg_name(input, output): | |
| + assert gen_arg_name(input) == output | |
| diff --git a/tests/test_utils.py b/tests/test_utils.py | |
| new file mode 100644 | |
| --- /dev/null | |
| +++ b/tests/test_utils.py | |
| +import pytest | |
| + | |
| +from loafang.utils import err_msg | |
| + | |
| + | |
| +@pytest.mark.parametrize( | |
| + ("input", "output"), | |
| + ( | |
| + (600, "Something went wrong."), | |
| + (605, "Invalid data type for the argument in the query."), | |
| + (612, "Execution block with pe property key cannot have an after key"), | |
| + (500, "") | |
| + ) | |
| +) | |
| +def test_err_msg(input, output): | |
| + assert err_msg(input) == output | |