|
1 | | -""" |
2 | | -This file contains unit tests for the command-line interface (CLI) of the CuBIDS package. |
| 1 | +"""Unit tests for the command-line interface (CLI) of the CuBIDS package. |
3 | 2 |
|
4 | 3 | The tests cover the following functions: |
5 | 4 | - _path_exists: Tests whether a given path exists or not. |
6 | 5 | - _is_file: Tests whether a given path is a file or a directory. |
7 | | -- _get_parser: Tests the creation and configuration of the argument parser. |
8 | | -- _main: Tests the main function of the CLI. |
9 | 6 |
|
10 | 7 | Each test case includes assertions to verify the expected behavior of the corresponding function. |
11 | | -
|
12 | | -Author: [Your Name] |
13 | | -Date: [Current Date] |
14 | 8 | """ |
15 | 9 |
|
16 | 10 | import argparse |
17 | 11 | from functools import partial |
18 | 12 |
|
19 | 13 | import pytest |
20 | 14 |
|
21 | | -from cubids.cli import _get_parser, _is_file, _main, _path_exists |
| 15 | +from cubids.cli import _is_file, _path_exists |
22 | 16 | from cubids.tests.utils import chdir |
23 | 17 |
|
24 | 18 |
|
@@ -106,38 +100,3 @@ def test_is_file(tmp_path): |
106 | 100 | # Test with a non-existing path within an argument parser |
107 | 101 | with pytest.raises(SystemExit): |
108 | 102 | parser.parse_args([str(non_existing_path)]) |
109 | | - |
110 | | - |
111 | | -def _test_get_parser(): |
112 | | - """Test the creation and configuration of the argument parser. |
113 | | -
|
114 | | - This function tests the `_get_parser` function by asserting that the returned object is an |
115 | | - instance of `argparse.ArgumentParser`, and that it has the expected `prog` and `description` |
116 | | - attributes. |
117 | | - Additional assertions can be added to test the configuration of the parser. |
118 | | - """ |
119 | | - parser = _get_parser() |
120 | | - assert isinstance(parser, argparse.ArgumentParser) |
121 | | - assert parser.prog == "cubids" |
122 | | - assert parser.description == "Console script for cubids" |
123 | | - # Add more assertions for the parser configuration |
124 | | - |
125 | | - |
126 | | -def _test_main(): |
127 | | - """Test the main function of the CLI. |
128 | | -
|
129 | | - This function tests the `_main` function by providing different sets of arguments. |
130 | | - It asserts that the function returns the expected exit code (0 or 1) based on the provided |
131 | | - arguments. |
132 | | - """ |
133 | | - # Test the main function with valid arguments |
134 | | - argv = ["validate", "/path/to/dataset"] |
135 | | - assert _main(argv) == 0 |
136 | | - |
137 | | - # Test the main function with invalid arguments |
138 | | - argv = ["invalid-command", "/path/to/dataset"] |
139 | | - assert _main(argv) == 1 |
140 | | - |
141 | | - # Test the main function with missing arguments |
142 | | - argv = [] |
143 | | - assert _main(argv) == 1 |
0 commit comments